unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* progress report on nyacc
@ 2015-09-18 23:29 Matt Wette
  0 siblings, 0 replies; only message in thread
From: Matt Wette @ 2015-09-18 23:29 UTC (permalink / raw)
  To: guile-user

My wife always says, “It’s the journey, not the destination.”  Well, I started out wanting to generate a parser for modelica and ended up writing a parser-generator and several parsers.  Now I’m working on translators.   My parser-generator is called nyacc.   The example parsers I’m working are for C99, modelica, matlab, and javascript.   The parsers output the parse tree in SXML and I’m using foldts*-values from (sxml fold) to do the translation.  Here is an illustration of the progress I’m making on javascript, from source code to output from guile.  — Matt

var x;
x = Math.sqrt(26.01);
x += 1;
x

==(parser)==> 

(SourceElements
  (VariableStatement
    (VariableDeclarationList
      (VariableDeclaration (Identifier "x"))))
  (EmptyStatement)
  (AssignmentExpression
    (PrimaryExpression (Identifier "x"))
    (assign)
    (CallExpression
      (obj-ref
        (PrimaryExpression (Identifier "Math"))
        (Identifier "sqrt"))
      (ArgumentList
        (PrimaryExpression (NumericLiteral "26.01")))))
  (EmptyStatement)
  (AssignmentExpression
    (PrimaryExpression (Identifier "x"))
    (add-assign)
    (PrimaryExpression (NumericLiteral "1")))
  (EmptyStatement)
  (PrimaryExpression (Identifier "x")))

==(foldts*-values)==> 

(begin
  (define x (@@ (jslib) undefined))
  (set! (toplevel x)
    (apply (apply (@@ (jslib) lkup)
                  (@@ (jslib) Math)
                  (const "sqrt"))
           (const 26.01)))
  (set! (toplevel x)
    (apply (@@ (jslib) JS+) (toplevel x) (const 1)))
  (toplevel x))

==(compile)==> 

6.1000000000000005




^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2015-09-18 23:29 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-18 23:29 progress report on nyacc Matt Wette

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).