javacc-7.0.4.grammars.ExpressParser.jj Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of javacc Show documentation
Show all versions of javacc Show documentation
JavaCC modified by Tencent blueking.
The newest version!
/***************************************************************************************************************************************
** DESCRIPTION: EXPRESS Grammar and Scanner to be used with JavaCC
** FILENAME: ExpressParser.jj
** DATE: MAR 1998 - (Initial grammar)
** UPDATE: OCT 1998 - (Production 294 correction)
**
** Contributed by Jason Goodman - [email protected]
*************************************************************************************************************************************/
options {
LOOKAHEAD = 2;
STATIC = false;
}
PARSER_BEGIN(ExpressParser)
public class ExpressParser{
//
// MAIN class used for command line parsing
//
public static void main(String args[]) {
ExpressParser parser;
if (args.length == 0) {
System.out.println("ExpressParser: Reading from standard input . . .");
parser = new ExpressParser(System.in);
}
else if (args.length == 1) {
System.out.println("ExpressParser: Reading from file " + args[0] + " . . .");
try {
parser = new ExpressParser(new java.io.FileInputStream(args[0]));
}
catch (java.io.FileNotFoundException e) {
System.out.println("Express Parser: File " + args[0] + " not found.");
return;
}
}
else {
System.out.println("ExpressParser: Usage is one of:");
System.out.println(" java ExpressParser < inputfile");
System.out.println("OR");
System.out.println(" java ExpressParser inputfile");
return;
}
try {
parser.syntax();
System.out.println("ExpressParser: source parsed successfully.");
}
catch (ParseException e) {
System.out.println(e.getMessage());
System.out.println("ExpressParser: Encountered errors during parse.");
}
} // end main
} // end class ExpressParser
PARSER_END(ExpressParser)
/************************************************
*************************************************
** Tokens
*************************************************
************************************************/
SKIP : /* WHITE SPACE */
{
" "
| "\t"
| "\n"
| "\r"
| "\f"
}
SPECIAL_TOKEN : /* COMMENTS */
{
|
}
TOKEN : {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
TOKEN : {
| <#HEX_LITERAL: "0" ["x","X"] ()+>
| <#HEX_DIGIT: ["0"-"9","a"-"f","A"-"F"]>
| <#OCTAL_LITERAL: "0" (["0"-"7"])*>
| )? >
| <#EXPONENT: ["e","E"] (["+","-"])? (["0"-"9"])+>
| | | | | " " )* "\'" >
| <#ESCAPED_CHAR: "\\" (["n","t","b","r","f","\\","\'","\""]) >
| <#PRINT_CHAR: "~" | "!" | "@" | "#" | "$" | "%" | "^" |"&" | "*" | "(" | | "_" | "-" | "+" | "=" | "|" | "{" | "}" | "[" | "]" | ":" | ";" | "," | "." | "<" | ">" | "/" | "?" | "~" | "`" >
| )+ "\"">
|
| >
| <#ENCODED_CHARACTER: >
| ( | | "_")*>
| <#LETTER: ["A"-"Z", "a"-"z"]>
| <#DIGIT: ["0"-"9"]>
}
TOKEN :
{
< LPAREN: "(" >
| < RPAREN: ")" >
| < LBRACE: "{" >
| < RBRACE: "}" >
| < LBRACKET: "[" >
| < RBRACKET: "]" >
| < SEMICOLON: ";" >
| < COLON: ":" >
| < COMMA: "," >
| < DOT: "." >
}
TOKEN :
{
< ASSIGN: ":=" >
| < GT: ">" >
| < LT: "<" >
| < LTE: "<=" >
| < GTE: ">=" >
| < QMARK: "?" >
| < POWER: "**" >
| < BSLASH: "\\" >
| < NE: "<>" >
| < EQ: "=" >
| < ASSIGN_NE: ":<>:">
| < ASSIGN_EQ: ":=:">
| < PLUS: "+" >
| < MINUS: "-" >
| < STAR: "*">
| < SLASH: "/">
| < SC_OR: "||" >
| < SRS: "<*" >
| < BIT_OR: "|" >
}
/************************************************
*************************************************
** Grammar
*************************************************
************************************************/
/********** PRODUCTION 140 **********/
void simple_id() : {}
{
}
/********** PRODUCTION 145 **********/
void attribute_ref() : {}
{
attribute_id()
}
/********** PRODUCTION 146 **********/
void constant_ref() : {}
{
constant_id()
}
/********** PRODUCTION 147 **********/
void entity_ref() : {}
{
entity_id()
}
/********** PRODUCTION 148 **********/
void enumeration_ref() : {}
{
enumeration_id()
}
/********** PRODUCTION 149 **********/
void function_ref() : {}
{
function_id()
}
/********** PRODUCTION 150 **********/
void parameter_ref() : {}
{
parameter_id()
}
/********** PRODUCTION 151 **********/
void procedure_ref() : {}
{
procedure_id()
}
/********** PRODUCTION 152 **********/
void schema_ref() : {}
{
schema_id()
}
/********** PRODUCTION 153 **********/
void type_label_ref() : {}
{
type_label_id()
}
/********** PRODUCTION 154 **********/
void type_ref() : {}
{
type_id()
}
/********** PRODUCTION 155 **********/
void variable_ref() : {}
{
variable_id()
}
/********** PRODUCTION 156 **********/
void abstract_supertype_declaration() : {}
{
(subtype_constraint())?
}
/********** PRODUCTION 157 **********/
void actual_parameter_list() : {}
{
parameter() ( parameter())*
}
/********** PRODUCTION 158 **********/
void add_like_op() : {}
{
| | |
}
/********** PRODUCTION 159 **********/
void aggregate_initializer() : {}
{
(element() ( element())*)?
}
/********** PRODUCTION 160 **********/
void aggregate_source() : {}
{
simple_expression()
}
/********** PRODUCTION 161 **********/
void aggregate_type() : {}
{
( type_label())? parameter_type()
}
/********** PRODUCTION 162 **********/
void aggregation_types() : {}
{
array_type()
| bag_type()
| list_type()
| set_type()
}
/********** PRODUCTION 163 **********/
void algorithm_head() : {}
{
(declaration())* (constant_decl())? (local_decl())
}
/********** PRODUCTION 164 **********/
void alias_stmt() : {}
{
variable_id() general_ref() (qualifier())* (stmt())+
}
/********** PRODUCTION 165 **********/
void array_type() : {}
{
bound_spec() ()? ()? base_type()
}
/********** PRODUCTION 166 **********/
void assignment_stmt() : {}
{
general_ref() (qualifier())* expression()
}
/********** PRODUCTION 167 **********/
void attribute_decl() : {}
{
attribute_id() | qualified_attribute()
}
/********** PRODUCTION 168 **********/
void attribute_id() : {}
{
simple_id()
}
/********** PRODUCTION 169 **********/
void attribute_qualifier() : {}
{
attribute_ref()
}
/********** PRODUCTION 170 **********/
void bag_type() : {}
{
(bound_spec())? base_type()
}
/********** PRODUCTION 171 **********/
void base_type() : {}
{
aggregation_types()
| simple_types()
| named_types()
}
/********** PRODUCTION 172 **********/
void binary_type() : {}
{
(width_spec())?
}
/********** PRODUCTION 173 **********/
void boolean_type() : {}
{
}
/********** PRODUCTION 174 **********/
void bound_1() : {}
{
numeric_expression()
}
/********** PRODUCTION 175 **********/
void bound_2() : {}
{
numeric_expression()
}
/********** PRODUCTION 176 **********/
void bound_spec() : {}
{
bound_1() bound_2()
}
/********** PRODUCTION 177 **********/
void built_in_constant() : {}
{
| | |
}
/********** PRODUCTION 178 **********/
void built_in_function() : {}
{
| | | | | |
| | | | |
| | | | |
| | | | | |
| | | | |
|
}
/********** PRODUCTION 179 **********/
void built_in_procedure() : {}
{
|
}
/********** PRODUCTION 180 **********/
void case_action() : {}
{
case_label() ( case_label())* stmt()
}
/********** PRODUCTION 181 **********/
void case_label() : {}
{
expression()
}
/********** PRODUCTION 182 **********/
void case_stmt() : {}
{
selector() (case_action())* ( stmt())?
}
/********** PRODUCTION 183 **********/
void compound_stmt() : {}
{
(stmt())+
}
/********** PRODUCTION 184 **********/
void constant_body() : {}
{
constant_id() base_type() expression()
}
/********** PRODUCTION 185 **********/
void constant_decl() : {}
{
(constant_body())+
}
/********** PRODUCTION 186 **********/
void constant_factor() : {}
{
built_in_constant() | constant_ref()
}
/********** PRODUCTION 187 **********/
void constant_id() : {}
{
simple_id()
}
/********** PRODUCTION 188 **********/
void constructed_types() : {}
{
enumeration_type() | select_type()
}
/********** PRODUCTION 189 **********/
void declaration() : {}
{
entity_decl() | function_decl() | procedure_decl() | type_decl()
}
/********** PRODUCTION 190 **********/
void derived_attr() : {}
{
attribute_decl() base_type() expression()
}
/********** PRODUCTION 191 **********/
void derive_clause() : {}
{
(derived_attr())+
}
/********** PRODUCTION 192 **********/
void domain_rule() : {}
{
(label() )? expression()
}
/********** PRODUCTION 193 **********/
void element() : {}
{
expression() ( repetition())?
}
/********** PRODUCTION 194 **********/
void entity_body() : {}
{
(explicit_attr())* (derive_clause())? (inverse_clause())? (unique_clause())? (where_clause())?
}
/********** PRODUCTION 195 **********/
void entity_constructor() : {}
{
entity_ref() (expression() ( expression())*)?
}
/********** PRODUCTION 196 **********/
void entity_decl() : { }
{
entity_head() entity_body()
}
/********** PRODUCTION 197 **********/
void entity_head() : { }
{
entity_id() (subsuper())?
}
/********** PRODUCTION 198 **********/
void entity_id() : {}
{
simple_id()
}
/********** PRODUCTION 199 **********/
void enumeration_id() : {}
{
simple_id()
}
/********** PRODUCTION 200 **********/
void enumeration_reference() : {}
{
(type_ref() )? enumeration_ref()
}
/********** PRODUCTION 201 **********/
void enumeration_type() : {}
{
enumeration_id() ( enumeration_id())*
}
/********** PRODUCTION 202 **********/
void escape_stmt() : {}
{