/* auxiliary expressions */
LETTER = ['A'-'Z']|['a'-'z'];
DIGIT = ['0'-'9'];
HEX_DIGIT = ['0'-'9']|['A'-'F']|['a'-'f'];
escape_characters = '"' | '''' | '\\' |
'b' | 'f' | 'n' | 'r' | 't' ;
// delimiters = ' ' | ',' | '.' | ':' | ';' |
'(' | ')' | '\n' | '\t' | '[' | ']' | '-' | '=' | '+' | '/' | '?' | '\'' |
'\"' ;
STAR = '*';
SLASH = '/';
//dump = ' ' | '\n' | '(' | ')';
STAR_SLASH = '*' | '/' ;
parentheses = '(' | ')';
quotes = '''' | '"' ;
single_quote_backslash = '''' | '\\';
double_quote_backslash = '"' | '\\';
/* regular expressions - for lex */
'/' '*' ( ( (-'*')+ ('*')+ )|('*')+ ) ( (
-('*'|'/') ) (-'*')* ('*')+ )* '/';
'/' '/' (-'\n')* '\n';
#NAME = LETTER ( LETTER | DIGIT | '_' )* {lcase260};
#TOKN_NAME = '#' LETTER ( LETTER | DIGIT |
'_' )* {lcase261};
#CHAR = '''' ( -single_quote_backslash | ''''
'''' | '\\' escape_characters ) ''''
{lcase263};
#STRING = '"' ( -double_quote_backslash
| '"' '"' | '\\' escape_characters )* '"' {lcase262};
#HEX_STRING = ##CASE("X") ''''
HEX_DIGIT+ ''''
| '\'' '\\' ##CASE("x")
HEX_DIGIT+ '\'' {lcase264};
#LTGT = '<' | '>';
/*
#HEY = x'0';
#HEY2 = x'2';
#hey3 = x'0' x'2' x'4';
*/
#PDECLARE = "##" (
##CASE("PARS_DECLARE" | "PDCL") );
#LDECLARE = "##" (
##CASE("LEX_DECLARE" | "LDCL") );
#CONTROL = "##" (
##CASE("CONTROL" | "CTL") );
#RETURN = "##"
##CASE("RETURN");
#LUF_RTN = "##" ##CASE("LUF_RTN");
#LEX_STRING = "##"
##CASE("LEX_STRING");
#START = "##"
##CASE("START");
#PPATH = "##"
##CASE("PPATH") ' '* '(' (-')')+ ')' {lcase265a};
#LPATH = "##"
##CASE("LPATH") ' '* '(' (-')')+ ')' {lcase265b};
#CASE = "##" ##CASE("CASE");
#LVERSION = "##" (
##CASE("LEX_VERSION" | "LEXV") );
#PVERSION = "##" (
##CASE("PARS_VERSION" | "PARSV") );
#NUMBER = DIGIT+;
' ' +;
'\n'+;
//
(-dump)+;
#TEST = "TOM "" \" \' \\
END TOM" '\'' '''' '"' '\"' '\\'
'\b' '\f' '\n'
'\r' '\t' ;
/*#TEST = "TOM "" END TOM" ;*/
##lpath(LEX\*.java);
##LDCL {
ParsRec first;
##cTl int token;
String lex_string;
}
##LUF_rtn Object item;
##LEX_string String lex_string;
##ppath(PARS\*.java);
##PDCL {
RStack stack;
z_pass z; /* parser function sends addr */
##CoNTrOl int prod_no;
Lex lex;
}
##lexv 1;
##parsv 1;
//test of comment
##start(S);
/* productions */
S -> GEN;
GEN -> AUX_EXPR
| TOKN_DEF {pcase003}
| DMY_DEF {pcase003}
| PROD
| START ';' {pcase061}
| PATH
| LUF_RTN
| LEX_STR
| DECLARE {pcase069}
| ';' {pcase003a}
| LEX_VERSION
| PARS_VERSION
;
GEN -> GEN AUX_EXPR
| GEN TOKN_DEF {pcase007}
| GEN DMY_DEF {pcase007}
| GEN PROD
| GEN START ';' {pcase062}
|
GEN PATH
| GEN LUF_RTN
| GEN LEX_STR
| GEN DECLARE {pcase069}
| GEN ';' {pcase003a}
| GEN LEX_VERSION
| GEN PARS_VERSION
;
AUX_EXPR -> #NAME '=' CHAR_LIST ';'
{pcase010};
CHAR_LIST -> #CHAR {pcase011a}
| CHAR_LIST '|' #CHAR {pcase012a}
| '[' #CHAR '-' #CHAR ']' {pcase012b}
| CHAR_LIST '|' '[' #CHAR '-'
#CHAR ']' {pcase012c};
DMY_DEF -> RULE ';' {pcase013};
TOKN_DEF -> TOKN_NAME_LIST '=' RULE
';' {pcase014a}
| TOKN_NAME_LIST '=' RULE INCLUDE
';' {pcase014b};
TOKN_NAME_LIST -> #TOKN_NAME {pcase015}
| TOKN_NAME_LIST ','
#TOKN_NAME {pcase016};
PROD -> #NAME "->" ';' {pcase022c}
| #NAME "->" INCLUDE
';' {pcase022d}
| #NAME "->"
PROD_ALTERNATES ';' {pcase017e}
| START "->"
PROD_ALTERNATES ';' {pcase060e};
PROD_ALTERNATES -> PROD_ITEM_LIST {pcase019}
| PROD_ITEM_LIST
INCLUDE {pcase019a}
| PROD_ALTERNATES '|'
PROD_ITEM_LIST {pcase020}
| PROD_ALTERNATES '|'
PROD_ITEM_LIST INCLUDE {pcase020a};
// #NAME is a prod_name . . . maybe it can
also be an AUX_EXPR name
PROD_ITEM -> #NAME {pcase024a}
| #NAME PRECEDENCE
| #TOKN_NAME {pcase025a}
| #TOKN_NAME PRECEDENCE
| #CHAR {pcase026b}
| #CHAR PRECEDENCE
| #STRING {pcase026a}
| #STRING PRECEDENCE;
PROD_ITEM_LIST -> PROD_ITEM {pcase024b}
| PROD_ITEM_LIST PROD_ITEM
{pcase024c};
// | {pcase024d}; //*****************************??????????????????
RULE -> ORED_REG_EXPR
| REG_EXPR;
STRING_LIST -> #STRING {pcase011d}
//
| #CHAR // {pcase011d}
//
| STRING_LIST '|' #CHAR // {pcase012d}
| STRING_LIST '|' #STRING {pcase012d};
// I thought that
#TOKN_NAME could be added to this list, but this could lead
// to impossible
recursions. Instead, maybe only allow
#TOKN_NAME's with no
// TOKN_NAME's,
thus no recursion. I'm not sure if
syntax or sematics is the
// way to go.
REG_TERM -> #NAME {pcase034}
// | #TOKN_NAME
| #CHAR {pcase035}
| #STRING {pcase035}
| '-' #NAME {pcase036}
// | '-' #TOKN_NAME
/* a #STRING here is used as a CHAR_LIST */
| '-' #CHAR {pcase037}
| '-' #STRING {pcase037}
| '(' REG_EXPR ')' {pcase038}
| '(' ORED_REG_EXPR ')' {pcase039}
| #HEX_STRING {pcase066}
| '-' #HEX_STRING {pcase067}
| #CASE '(' STRING_LIST ')'
{pcase035d}
| '-' '(' CHAR_LIST ')' {pcase037a};
/* -(. . .) not a valid regular expression
construct? */
REG_EXPR -> REG_TERM
| REG_TERM '?' {pcase041}
| REG_TERM '+' {pcase042}
| REG_TERM '*' {pcase043}
| REG_EXPR REG_EXPR {pcase044};
ORED_REG_EXPR -> REG_EXPR '|'
REG_EXPR {pcase045}
| ORED_REG_EXPR '|' REG_EXPR
{pcase046};
NUMBER_LIST -> #NUMBER {pcase047}
| NUMBER_LIST ',' #NUMBER
{pcase047a};
PRECEDENCE -> "##(" #LTGT
NUMBER_LIST ")##";
INCLUDE -> '{' #NAME '}' {pcase057b}
| '{' '}' {pcase058d};
START -> #START '(' #NAME ')' {pcase059};
PATH -> #PPATH ';' {pcase063b}
| #LPATH ';' {pcase063c};
DECLARE -> #PDECLARE '{' DECLARE_LIST '}'
{pcase071}
| #PDECLARE DECLARE_ITEM {pcase071a}
| #LDECLARE '{' DECLARE_LIST '}'
{pcase071b}
| #LDECLARE DECLARE_ITEM {pcase071c};
DECLARE_LIST -> DECLARE_ITEM {pcase072a}
| DECLARE_CTL_ITEM {pcase072a}
| DECLARE_RTN_ITEM
| DECLARE_LIST
DECLARE_ITEM {pcase072}
| DECLARE_LIST DECLARE_CTL_ITEM
{pcase072}
| DECLARE_LIST DECLARE_RTN_ITEM
{};
DECLARE_ITEM -> DECLARE_TYPE #NAME ';'
{pcase075}
| #NAME #NAME ';' {pcase078};
DECLARE_CTL_ITEM -> #CONTROL
"int" #NAME ';' {pcase077};
DECLARE_RTN_ITEM -> #RETURN #NAME #NAME
';' {};
DECLARE_TYPE -> "char" {pcase079}
| "int" {pcase080}
| "String"
{pcase081};
LUF_RTN -> #LUF_RTN DECLARE_ITEM
{pcase085};
LEX_STR -> #LEX_STRING DECLARE_ITEM
{pcase085a};
LEX_VERSION -> #LVERSION #NUMBER ';'
{pcase096a};
PARS_VERSION -> #PVERSION #NUMBER ';'
{pcase096b};
// #BAD = (-delimiters)+;