Name: skT88420 Date: 07/22/99
Use JavaCC 1.1 (from metamata.com) to convert the file below.
Then use javac-ea to compile.
It crashes with NullPointerException and the request to submit a bug report.
The program as such compiles ok, e.g., with JDK 1.2.2 javac.
// based on examples by Chuck McManis
// recognize arithmetic expressions
PARSER_BEGIN(Calc0) // must define parser class
public class Calc0 {
public static void main (String args []) {
Calc0 parser = new Calc0(System.in);
for (;;)
try {
if (parser.expr() == -1)
System.exit(0);
} catch (Exception e) {
e.printStackTrace(); System.exit(1);
}
}
}
PARSER_END(Calc0)
SKIP: // defines input to be ignored
{ " " | "\r" | "\t"
}
TOKEN: // defines token names
{ < EOL: "\n" >
| < CONSTANT: ( <DIGIT> )+ > // re: 1 or more
| < #DIGIT: ["0" - "9"] > // private re
}
int expr(): // expr: sum \n
{} // -1 at eof, 0 at eol
{ sum() <EOL> { return 1; }
| <EOL> { return 0; }
| <EOF> { return -1; }
}
void sum(): // sum: product { +- product }
{}
{ product() ( ( "+" | "-" ) product() )*
}
void product(): // product: term { *%/ term }
{}
{ term() ( ( "*" | "%" | "/" ) term() )*
}
void term(): // term: +term | -term | (sum) | number
{}
{ "+" term()
| "-" term()
| "(" sum() ")"
| <CONSTANT>
}
(Review ID: 88251)
======================================================================
- duplicates
-
JDK-4238511 javac-ea crash on empty switch/default
- Closed