Browse Source

update test grammar. A bug in antlr3.0.1 python template was producing bad code.

rtree
Marc Poulhiès 12 years ago
parent
commit
7996c83a5e
  1. 2
      build-parser.sh
  2. 25
      grammar/OpenAir.g
  3. 3
      test-parser.py

2
build-parser.sh

@ -0,0 +1,2 @@
mkdir -p python/generated
cd grammar && antlr3 -o ../python/generated/ OpenAir.g && cd -

25
grammar/OpenAir.g

@ -1,7 +1,7 @@
grammar OpenAir;
options {
language=Python;
language=Python;
}
tokens {
@ -34,22 +34,19 @@ tokens {
}
file
: zone NEWLINE EOF
;
zone
: INCLUDE WS* EQ WS* (YES|NO) WS*
: include title EOF
;
NEWLINE
: '\r'? '\n'
;
title : (TITLE EQ YES EOL)
;
WS
: (' '|'\t'|'\n'|'\r')+ {skip();}
;
include : (INCLUDE EQ YES EOL)
;
EOL : '\r'? '\n';
WS : (' ' |'\t' )+ {$channel = HIDDEN;} ;
ZONE_TITLE
: ('a'..'z'|'A'..'Z'|'0'..'9'|'.'|' ')+'\r'? '\n'
;

3
test-parser.py

@ -20,4 +20,5 @@ char_stream = antlr3.ANTLRStringStream(s)
lexer = OpenAirLexer(char_stream)
tokens = antlr3.CommonTokenStream(lexer)
parser = OpenAirParser(tokens)
parser.file()
parser.zone()
##parser.file()

Loading…
Cancel
Save