parser: regenerate with comments in line annotations
[nit.git] / contrib / nitcc / src / nitcc.sablecc
index 984cc3c..d435c77 100644 (file)
@@ -7,7 +7,7 @@ Lexer
 id = ('a'..'z')('a'..'z'|'0'..'9'|'_')*;
 
 // A printable character (inside strings)
-ch = ' ' .. '~';
+ch = ' ' ...;
 
 // Literal strings
 str = '\'' (ch-'\\'-'\''|'\\'ch)* '\'';
@@ -15,10 +15,13 @@ str = '\'' (ch-'\\'-'\''|'\\'ch)* '\'';
 // A char by decimal ascii
 ch_dec = '#' ('0'..'9')+ ;
 
+// A char by hexadecimal ascii
+ch_hex = '#' ('x'|'X') ('0'..'9'|'a'..'z'|'A'..'Z')+ ;
+
 // A single-line comment
 comment = '//' ch* '\n'?;
 
-any = '\t'..'~';
+any = '\t' ...;
 not_star = any - '*';
 not_star_not_slash = not_star - '/';
 
@@ -61,15 +64,19 @@ re3 {-> re} =
        {plus:} re3 '+' |
        {shortest:} 'Shortest' '(' re ')' |
        {longest:} 'Longest' '(' re ')' |
+       {prefixes:} 'Prefixes' '(' re ')' |
        {id:} id |
        {par:} '(' re ')' |
        {class:} text '.' '.' text |
+       {openclass:} text '.' '.' '.' |
        {any:} 'Any' |
+       {end:} 'End' |
        {text:} text ;
 
 text {-> re} =
        {str:} str |
-       {ch_dec:} ch_dec ;
+       {ch_dec:} ch_dec |
+       {ch_hex:} ch_hex ;
 
 parser_part = 'Parser' ign? rej? prod*;
 
@@ -77,7 +84,7 @@ ign = 'Ignored' elem_list ';' ;
 
 rej = 'Rejected' elem_list ';' ;
 
-prod = id ptrans? '=' alts ';';
+prod = id ptrans? '=' alts priority* ';';
 
 ptrans = '{' '->' id '}';
 atrans = '{' '->' '}';
@@ -106,4 +113,9 @@ elem =
        {plus:} elem '+' |
        {empty:} 'Empty' ;
 
+priority =
+       {left:} 'Left' alts |
+       {right:} 'Right' alts |
+       {unary:} 'Unary' alts ;
+
 tree_part = 'Tree' prod*;