Overview ^

These are some rumblings on using ANTLR 3 for Parrot bc, or with Parrot in general.

Parsing in general ^

ANTLR 3 ^

See http://www.antlr.org/v3/index.html.

Running ^

Bc.java needs to find the needed classes. This works for me:

  export ANTLR_HOME=/home/bernhard/devel/ANTLR/antlr-3
  export PARROT_HOME=/home/bernhard/devel/Parrot/repos/parrot
  export CLASSPATH=$ANTLR_HOME/lib/antlr-2.7.6.jar:$ANTLR_HOME/lib/antlr-3.0b4.jar:$ANTLR_HOME/lib/stringtemplate-2.3b9.jar:$PARROT_HOME/languages/bc/grammar/antlr_3:$PARROT_HOME/languages/bc 

And see the targest maintain-java, build-java, test-java in bc/Makefile.

Syntax ^

Lexer, Parser and TreeParser are in the same file, speak grammar. C and C++ style comments are accepted.

'+' is one or many

'( )' is for grouping '|' as for alternation "''" Sring delimeter, honoring '\t', '\n', '\r'

'{ }' are actions ';' delimits rules 'grammar <name>', set name of Parser, Name of autogenerated Lexer is generated from it

Tell to generate an AST and set lookahead options { output=AST; ASTLabelType=CommonTree; k = 2; }

'Sigil $' is for referencing alternations in actions, Lexer items only ???, also for setting returns

'->' Is for tree construction '^^' Makes a mother '^' Is for matching of tree nodes '[]' declaration and passing of parameters

@members declare additional member variables in the parser class

@init ??

scope a stack for symbols

{ channel = 99; } put match into Nirwana

Lexer ^

The lexer specification can be in the parser specification. A lexer grammar is automatically generated. 'protected' is gone.

Parser ^

TreeParser ^

StringTemplate ^

ANTLR Backends ^

Java ^

Python ^

Perl5 ^

ANTLR and Parrot ^

Backend for Parrot ^

Parrot bc ^

Glossary ^

AUTHOR ^

Bernhard Schmalhofer - <Bernhard.Schmalhofer@gmx.de>

SEE ALSO ^

  L<http://www.antlr.org/>
  L<http://www.antlr.org/v3/index.html>
  L<http://www.antlr.org/wiki/display/ANTLR3/Welcome+to+ANTLR+V3>
  L<http://www.antlr.org:8080/pipermail/antlr-dev/>


parrot