[antlr-interest] Hello & Parsing an AST

Guido 14.08.99 at gmx.de
Wed Aug 2 04:55:42 PDT 2006


Hi @all,

just a short "Hello" from a newbie (from Germany). I started using the
eclpise plugin to use antlr to convert a proprietary code into XML.

I managed to build a parser & lexer but got stuck after generating the AST.

This is an example File to parse...
*****
Ident
Src Sys: sys X1 Lang: Ger new
Code: NameOfScript

Code
Start Script "NameOfScript"
  Def Var "x" : int
  Def Var "y" : bool
  Start SubScript "Test1"
   [...]
  End SubScript
  Start SubScript "Test2"
   [...]
  End SubScript
End Script
*****

...and this a part of the parser...
*****
start
  : head "Code"^ script;
head
  : "Ident" "Src" "Sys" (STRING)+ "Lang"
     COLON (STRING)+ "Code" COLON STRING;
script
  : "Start" "Script" STRING (def)* (subScript)* "End" "Script"
[...]
*****

...and finally I want to generate s.t. like this:
*****
<SCRIPT name="NameOfScript" srcSys="sys X1" lang="Ger new">
  <DEF name="x" type="int">
  <DEF name="y" type="bool">
  <SUBSCRIPT name="Test1">
   [...]
  </SUBSCRIPT>
  <SUBSCRIPT name="Test2">
   [...]
  </SUBSCRIPT>
</SCRIPT>
*****

My problem: Up to now I didn't manage to build a Tree Parser, so I would
appreciate any hint...

Thanks,
Guido



More information about the antlr-interest mailing list