forked from zaach/jison
/
bnf.jisonlex
28 lines (25 loc) · 993 Bytes
/
bnf.jisonlex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
%%
\s+ {/* skip whitespace */}
"//".* {/* skip comment */}
"/*"[^*]*"*" {return yy.lexComment(this);}
[a-zA-Z][a-zA-Z0-9_-]* {return 'ID';}
'"'[^"]+'"' {yytext = yytext.substr(1, yyleng-2); return 'STRING';}
"'"[^']+"'" {yytext = yytext.substr(1, yyleng-2); return 'STRING';}
":" {return ':';}
";" {return ';';}
"|" {return '|';}
"%%" {return '%%';}
"%prec" {return 'PREC';}
"%start" {return 'START';}
"%left" {return 'LEFT';}
"%right" {return 'RIGHT';}
"%nonassoc" {return 'NONASSOC';}
"%lex"[\w\W]*?"/lex" {return 'LEX_BLOCK';}
"%"[a-zA-Z]+[^\n]* {/* ignore unrecognized decl */}
"<"[a-zA-Z]*">" { /* ignore type */}
"{{"[\w\W]*?"}}" {yytext = yytext.substr(2, yyleng-4); return 'ACTION';}
"{"[^}]*"}" {yytext = yytext.substr(1, yyleng-2); return 'ACTION';}
"%{"(.|\n)*?"%}" {yytext = yytext.substr(2, yytext.length-4);return 'ACTION';}
. {/* ignore bad characters */}
<<EOF>> {return 'EOF';}
%%