// GrammarName = ABB
// ExtractedType = BCounter
A : A '+' B | 'a' ;
B : 'b' ;
// GrammarName = SLR
// ExtractedType = SLR2
S : L '=' R | R ;
L : '*' R | 'id' ;
R : L ;
// GrammarName = Calc
// ExtractedType = FinalValue
Additive : Additive '+' Multiplicative
| Additive '-' Multiplicative
| Multiplicative ;
Multiplicative : Multiplicative '*' Primary
| Multiplicative '/' Primary
| Primary ;
Primary : '(' Additive ')'
| 'number' ;
//--------------------------------------------
'number' : %%[0-9]+%% ; // 暂时只处理非负数的四则运算
PreRegex : 'refVt' ;
// 'refVt' : %%\<'([ -&]|\\'|[(-\[]|\\\\)+'\>%% ;
'refVt' : %%(\\|[Y-\\])+%% ;
// GrammarName=Grammar
// ExtractedType=GrammarDraft
//-------------Syntax Statements-----------------
StatementList : StatementList Statement | Statement ;
Statement : SyntaxProduction | LexiProduction ;
SyntaxProduction : 'Vn' ':' CandidateList ';' ;
CandidateList : CandidateList '|' Candidate | Candidate ;
Candidate : VList | 'empty' ; // candidate is a list of V or the keyword(empty)
VList : VList V | V ;
V : 'Vn' | 'Vt' ; // V is Vn or Vt.
LexiProduction : 'Vt' ':' 'pattern' ';' ;
//--------------Lexi Statements------------------
'Vn' : %%[a-zA-Z_][a-zA-Z0-9_]*%% ; // identifier
'Vt' : %%'([ -&]|\\'|[(-\[]|\\\\|[\]-~])+'%% ; // any char or \'
'pattern' : %%[%]{2}[ -~]([^%]|%[^%])*[%]{2}%% ; // %%xxx%%
// GrammarName = Ints
// ExtractedType = IntArray
Ints : Ints Int | Int ;
Int : 'integer' ;
'integer' : %%[0-9]+%% ;
// GrammarName = Ints2
// ExtractedType = Ints2Array
Ints : Ints ',' Int | Int ;
Int : 'integer' ;
'integer' : %%[0-9]+%% ;
// GrammarName = LALR1Error
// ExtractedType = LALR1Error2
S : 'a' A 'd' | 'b' B 'd' | 'a' B 'e' | 'b' A 'e' ;
A : 'c' ;
B : 'c' ;
// GrammarName = Numbers
// ExtractedType = NumberArray
Numbers : Numbers Number | Number ;
Number : 'integer' | 'float' ;
'integer' : %%[0-9]+%% ;
'float' : %%[0-9]+\.[0-9]+%% ;
// something(...) between %%...%%
// GrammarName=Pattern
// ExtractedType=TokenDraft
// VnRegulations:
Pattern : PreRegex Regex PostRegex ;
PreRegex : 'refVt' | empty ;
PostRegex : '/' Regex | empty ;
Regex : Regex '|' Bunch | Bunch;
Bunch : Bunch Unit | Unit ;
Unit : 'char' Repeat | '.' Repeat | 'scope' Repeat | '(' Regex ')' Repeat ;
Repeat : '?' | '+' | '*' | '{' 'min' UpperBound '}' | empty ;
UpperBound : ',' 'max' | ',' | empty ;
// VtRegex:
'refVt' : %%\<'([ -&]|\\'|[(-~])+'\>%% ; // start with <' and end with '>
'min' : %%<'{'>[0-9]+%% ;
'max' : %%<','>[0-9]+%% ;
// 'char' is a letter or an escape
'char' : %%[ !"#%&',]|-|[0-9:;<=>@A-Z_`a-z~]|\\[$()*+]|\\-|\\[./<>?]|\\\[|\\\\|\\\]|\\\^|\\\{|\\\||\\\}|\\u[0-9a-fA-F]{4}%% ;
//'scope' : %%\[((firstLetter1)(char)*|\^(firstLetter2)(char)*)\]%% ; // a-z or A-Z or ...
//firstLetter1 = \\u[0-9]{4}|\\t|\\n|\\r|\\-|[ -Z]|\[|\\\\|]|\\\^|[_-~]
//firstLetter2 = \\u[0-9]{4}|\\t|\\n|\\r|\\-|[ -Z]|\[|\\\\|]|\^|\\\^|[_-~]
//char = \\u[0-9]{4}|\\t|\\n|\\r|\\-|[ -Z]|\\\[|\\\\|\\\]|\^|\\\^|[_-~]
'scope' : %%\[((\\u[0-9]{4}|\\t|\\n|\\r|\\-|[ -Z]|\[|\\\\|]|\\\^|[_-~])(\\u[0-9]{4}|\\t|\\n|\\r|\\-|[ -Z]|\\\[|\\\\|\\\]|\^|\\\^|[_-~])*|\^(\\u[0-9]{4}|\\t|\\n|\\r|\\-|[ -Z]|\[|\\\\|]|\^|\\\^|[_-~])(\\u[0-9]{4}|\\t|\\n|\\r|\\-|[ -Z]|\\\[|\\\\|\\\]|\^|\\\^|[_-~])*)\]%% ; // a-z or A-Z or ...
// GrammarName = Postfix
// ExtractedType = Postfix2
// 4 VnRegulations:
Items : Items Item | Item ;
Item : 'entityId' '=' 'refEntity' ;
// 2 VtPatterns:
'entityId' : %%[0-9]+/=%% ;
'refEntity' : %%[0-9]+%% ;
// GrammarName = Prefix
// ExtractedType = Prefix2
// 4 VnRegulations:
Items : Items Item | Item ;
Item : 'entityId' '=' 'refEntity' ;
// 2 VtPatterns:
'entityId' : %%[0-9]+%% ;
'refEntity' : %%<'='>[0-9]+%% ;
// GrammarName = SAB
// ExtractedType = SAB2
S : A 'a' 's' | B 'b' 's' | 'd' ;
A : 'a' ;
B : 'c' | empty;
// GrammarName = Scope
// ExtractedType = ResolvedScope
Scope : '[' 'firstItem1' RangeItems ']' ;
Scope : '[^' 'firstItem2' RangeItems ']' ;
Scope : '[' 'firstItem1' ']' ;
Scope : '[^' 'firstItem2' ']' ;
RangeItems : RangeItems RangeItem | RangeItem ;
RangeItem : 'char' ;
// \uNNNN \t \n \r 口 ! " # $ % & '
// ( ) * + , - . /
// 0 1 2 3 4 5 6 7 8 9
// : ; < = > ? @
// A B C D E F G H I J K L M
// N O P Q R S T U V W X Y Z
// [ \ ] ^ _ `
// a b c d e f g h i j k l m
// n o p q r s t u v w x y z
// { | } ~
// escape: \ ^
'firstItem1' : %%<'['>\\u[0-9]{4}|\\t|\\n|\\r|\\-|[ -Z]|\[|\\\\|]|\\\^|[_-~]%% ;
// escape: \
'firstItem2' : %%<'[^'>\\u[0-9]{4}|\\t|\\n|\\r|\\-|[ -Z]|\[|\\\\|]|\^|\\\^|[_-~]%% ;
// escape: [ \ ]
'char' : %%\\u[0-9]{4}|\\t|\\n|\\r|\\-|[ -Z]|\\\[|\\\\|\\\]|\^|\\\^|[_-~]%% ;
//GrammarName=SES
//ExtractedType=SES2
S : N V N ; //[0]
N : 's' // [1]
| 't' // [2]
| 'g' // [3]
| 'w' ;//[4]
V : 'e' // [5]
| 'd' ;// [6]
V : 'Vt' ;
'Vt' : %%'([ -&]|\\'|[(-\[]|\\\\|[\]-~])+'%% ;
// GrammarName=GLSL
// ExtractedType=ShaderModel
translation_unit : external_declaration ;
translation_unit : translation_unit external_declaration ;
external_declaration : function_definition ;
external_declaration : declaration ;
function_definition : function_prototype compound_statement_no_new_scope ;
variable_identifier : 'identifier' ;
primary_expression : variable_identifier ;
primary_expression : 'number' ;
primary_expression : BOOLCONSTANT ;
primary_expression : '(' expression ')' ;
BOOLCONSTANT : 'true' ;
BOOLCONSTANT : 'false' ;
postfix_expression : primary_expression ;
postfix_expression : postfix_expression '[' integer_expression ']' ;
postfix_expression : function_call ;
postfix_expression : postfix_expression '.' FIELD_SELECTION ;
postfix_expression : postfix_expression '++' ;
postfix_expression : postfix_expression '--' ;
FIELD_SELECTION : 'identifier' ;
integer_expression : expression ;
function_call : function_call_or_method ;
function_call_or_method : function_call_generic ;
function_call_generic : function_call_header_with_parameters ')' ;
function_call_generic : function_call_header_no_parameters ')' ;
function_call_header_no_parameters : function_call_header 'void' ;
function_call_header_no_parameters : function_call_header ;
function_call_header_with_parameters : function_call_header assignment_expression ;
function_call_header_with_parameters : function_call_header_with_parameters ',' assignment_expression ;
function_call_header : function_identifier '(' ;
function_identifier : type_specifier ;
function_identifier : postfix_expression ;
unary_expression : postfix_expression ;
unary_expression : '++' unary_expression ;
unary_expression : '--' unary_expression ;
unary_expression : unary_operator unary_expression ;
unary_operator : '+' ;
unary_operator : '-' ;
unary_operator : '!' ;
unary_operator : '~' ;
multiplicative_expression : unary_expression ;
multiplicative_expression : multiplicative_expression '*' unary_expression ;
multiplicative_expression : multiplicative_expression '/' unary_expression ;
multiplicative_expression : multiplicative_expression '%' unary_expression ;
additive_expression : multiplicative_expression ;
additive_expression : additive_expression '+' multiplicative_expression ;
additive_expression : additive_expression '-' multiplicative_expression ;
shift_expression : additive_expression ;
shift_expression : shift_expression '<<' additive_expression ;
shift_expression : shift_expression '>>' additive_expression ;
relational_expression : shift_expression ;
relational_expression : relational_expression '<' shift_expression ;
relational_expression : relational_expression '>' shift_expression ;
relational_expression : relational_expression '<=' shift_expression ;
relational_expression : relational_expression '>=' shift_expression ;
equality_expression : relational_expression ;
equality_expression : equality_expression '==' relational_expression ;
equality_expression : equality_expression '!=' relational_expression ;
and_expression : equality_expression ;
and_expression : and_expression '&' equality_expression ;
exclusive_or_expression : and_expression ;
exclusive_or_expression : exclusive_or_expression '^' and_expression ;
inclusive_or_expression : exclusive_or_expression ;
inclusive_or_expression : inclusive_or_expression '|' exclusive_or_expression ;
logical_and_expression : inclusive_or_expression ;
logical_and_expression : logical_and_expression '&&' inclusive_or_expression ;
logical_xor_expression : logical_and_expression ;
logical_xor_expression : logical_xor_expression '^^' logical_and_expression ;
logical_or_expression : logical_xor_expression ;
logical_or_expression : logical_or_expression '||' logical_xor_expression ;
conditional_expression : logical_or_expression ;
conditional_expression : logical_or_expression '?' expression ':' assignment_expression ;
assignment_expression : conditional_expression ;
assignment_expression : unary_expression assignment_operator assignment_expression ;
assignment_operator : '=' ;
assignment_operator : '*=' ;
assignment_operator : '/=' ;
assignment_operator : '%=' ;
assignment_operator : '+=' ;
assignment_operator : '-=' ;
assignment_operator : '<<=' ;
assignment_operator : '>>=' ;
assignment_operator : '&=' ;
assignment_operator : '^=' ;
assignment_operator : '|=' ;
expression : assignment_expression ;
expression : expression ',' assignment_expression ;
constant_expression : conditional_expression ;
declaration : function_prototype ';' ;
declaration : init_declarator_list ';' ;
declaration : 'precision' precision_qualifier type_specifier ';' ;
declaration : type_qualifier 'identifier' '{' struct_declaration_list '}' ';' ;
declaration : type_qualifier 'identifier' '{' struct_declaration_list '}' 'identifier' ';' ;
declaration : type_qualifier 'identifier' '{' struct_declaration_list '}' 'identifier' array_specifier ';' ;
declaration : type_qualifier ';' ;
declaration : type_qualifier 'identifier' ';' ;
declaration : type_qualifier 'identifier' identifier_list ';' ;
identifier_list : ',' 'identifier' ;
identifier_list : identifier_list ',' 'identifier' ;
function_prototype : function_declarator ')' ;
function_declarator : function_header ;
function_declarator : function_header_with_parameters ;
function_header_with_parameters : function_header parameter_declaration ;
function_header_with_parameters : function_header_with_parameters ',' parameter_declaration ;
function_header : fully_specified_type 'identifier' '(' ;
parameter_declarator : type_specifier 'identifier' ;
parameter_declarator : type_specifier 'identifier' array_specifier ;
parameter_declaration : type_qualifier parameter_declarator ;
parameter_declaration : parameter_declarator ;
parameter_declaration : type_qualifier parameter_type_specifier ;
parameter_declaration : parameter_type_specifier ;
parameter_type_specifier : type_specifier ;
init_declarator_list : single_declaration ;
init_declarator_list : init_declarator_list ',' 'identifier' ;
init_declarator_list : init_declarator_list ',' 'identifier' array_specifier ;
init_declarator_list : init_declarator_list ',' 'identifier' array_specifier '=' initializer ;
init_declarator_list : init_declarator_list ',' 'identifier' '=' initializer ;
single_declaration : fully_specified_type ;
single_declaration : fully_specified_type 'identifier' ;
single_declaration : fully_specified_type 'identifier' array_specifier ;
single_declaration : fully_specified_type 'identifier' array_specifier '=' initializer ;
single_declaration : fully_specified_type 'identifier' '=' initializer ;
fully_specified_type : type_specifier ;
fully_specified_type : type_qualifier type_specifier ;
invariant_qualifier : 'invariant' ;
interpolation_qualifier : 'smooth' ;
interpolation_qualifier : 'flat' ;
interpolation_qualifier : 'noperspective' ;
layout_qualifier : 'layout' '(' layout_qualifier_id_list ')' ;
layout_qualifier_id_list : layout_qualifier_id ;
layout_qualifier_id_list : layout_qualifier_id_list ',' layout_qualifier_id ;
layout_qualifier_id : 'identifier' ;
layout_qualifier_id : 'identifier' '=' 'number' ;
precise_qualifier : 'precise' ;
type_qualifier : single_type_qualifier ;
type_qualifier : type_qualifier single_type_qualifier ;
single_type_qualifier : storage_qualifier ;
single_type_qualifier : layout_qualifier ;
single_type_qualifier : precision_qualifier ;
single_type_qualifier : interpolation_qualifier ;
single_type_qualifier : invariant_qualifier ;
single_type_qualifier : precise_qualifier ;
storage_qualifier : 'const' ;
storage_qualifier : 'inout' ;
storage_qualifier : 'in' ;
storage_qualifier : 'out' ;
storage_qualifier : 'centroid' ;
storage_qualifier : 'patch' ;
storage_qualifier : 'sample' ;
storage_qualifier : 'uniform' ;
storage_qualifier : 'buffer' ;
storage_qualifier : 'shared' ;
storage_qualifier : 'coherent' ;
storage_qualifier : 'volatile' ;
storage_qualifier : 'restrict' ;
storage_qualifier : 'readonly' ;
storage_qualifier : 'writeonly' ;
storage_qualifier : 'subroutine' ;
storage_qualifier : 'subroutine' '(' type_name_list ')' ;
type_name_list : 'userDefinedType' ;
type_name_list : type_name_list ',' 'userDefinedType' ;
type_specifier : type_specifier_nonarray ;
type_specifier : type_specifier_nonarray array_specifier ;
array_specifier : '[' ']' ;
array_specifier : '[' constant_expression ']' ;
array_specifier : array_specifier '[' ']' ;
array_specifier : array_specifier '[' constant_expression ']' ;
type_specifier_nonarray : 'void' ;
type_specifier_nonarray : 'float' ;
type_specifier_nonarray : 'double' ;
type_specifier_nonarray : 'int' ;
type_specifier_nonarray : 'uint' ;
type_specifier_nonarray : 'bool' ;
type_specifier_nonarray : 'vec2' ;
type_specifier_nonarray : 'vec3' ;
type_specifier_nonarray : 'vec4' ;
type_specifier_nonarray : 'dvec2' ;
type_specifier_nonarray : 'dvec3' ;
type_specifier_nonarray : 'dvec4' ;
type_specifier_nonarray : 'bvec2' ;
type_specifier_nonarray : 'bvec3' ;
type_specifier_nonarray : 'bvec4' ;
type_specifier_nonarray : 'ivec2' ;
type_specifier_nonarray : 'ivec3' ;
type_specifier_nonarray : 'ivec4' ;
type_specifier_nonarray : 'uvec2' ;
type_specifier_nonarray : 'uvec3' ;
type_specifier_nonarray : 'uvec4' ;
type_specifier_nonarray : 'mat2' ;
type_specifier_nonarray : 'mat3' ;
type_specifier_nonarray : 'mat4' ;
type_specifier_nonarray : 'mat2x2' ;
type_specifier_nonarray : 'mat2x3' ;
type_specifier_nonarray : 'mat2x4' ;
type_specifier_nonarray : 'mat3x2' ;
type_specifier_nonarray : 'mat3x3' ;
type_specifier_nonarray : 'mat3x4' ;
type_specifier_nonarray : 'mat4x2' ;
type_specifier_nonarray : 'mat4x3' ;
type_specifier_nonarray : 'mat4x4' ;
type_specifier_nonarray : 'dmat2' ;
type_specifier_nonarray : 'dmat3' ;
type_specifier_nonarray : 'dmat4' ;
type_specifier_nonarray : 'dmat2x2' ;
type_specifier_nonarray : 'dmat2x3' ;
type_specifier_nonarray : 'dmat2x4' ;
type_specifier_nonarray : 'dmat3x2' ;
type_specifier_nonarray : 'dmat3x3' ;
type_specifier_nonarray : 'dmat3x4' ;
type_specifier_nonarray : 'dmat4x2' ;
type_specifier_nonarray : 'dmat4x3' ;
type_specifier_nonarray : 'dmat4x4' ;
type_specifier_nonarray : 'atomic_uint' ;
type_specifier_nonarray : 'sampler1D' ;
type_specifier_nonarray : 'sampler2D' ;
type_specifier_nonarray : 'sampler3D' ;
type_specifier_nonarray : 'samplerCube' ;
type_specifier_nonarray : 'sampler1DShadow' ;
type_specifier_nonarray : 'sampler2DShadow' ;
type_specifier_nonarray : 'samplerCubeShadow' ;
type_specifier_nonarray : 'sampler1DArray' ;
type_specifier_nonarray : 'sampler2DArray' ;
type_specifier_nonarray : 'sampler1DArrayShadow' ;
type_specifier_nonarray : 'sampler2DArrayShadow' ;
type_specifier_nonarray : 'samplerCubeArray' ;
type_specifier_nonarray : 'samplerCubeArrayShadow' ;
type_specifier_nonarray : 'isampler1D' ;
type_specifier_nonarray : 'isampler2D' ;
type_specifier_nonarray : 'isampler3D' ;
type_specifier_nonarray : 'isamplerCube' ;
type_specifier_nonarray : 'isampler1DArray' ;
type_specifier_nonarray : 'isampler2DArray' ;
type_specifier_nonarray : 'isamplerCubeArray' ;
type_specifier_nonarray : 'usampler1D' ;
type_specifier_nonarray : 'usampler2D' ;
type_specifier_nonarray : 'usampler3D' ;
type_specifier_nonarray : 'usamplerCube' ;
type_specifier_nonarray : 'usampler1DArray' ;
type_specifier_nonarray : 'usampler2DArray' ;
type_specifier_nonarray : 'usamplerCubeArray' ;
type_specifier_nonarray : 'sampler2DRect' ;
type_specifier_nonarray : 'sampler2DRectShadow' ;
type_specifier_nonarray : 'isampler2DRect' ;
type_specifier_nonarray : 'usampler2DRect' ;
type_specifier_nonarray : 'samplerBuffer' ;
type_specifier_nonarray : 'isamplerBuffer' ;
type_specifier_nonarray : 'usamplerBuffer' ;
type_specifier_nonarray : 'sampler2DMS' ;
type_specifier_nonarray : 'isampler2DMS' ;
type_specifier_nonarray : 'usampler2DMS' ;
type_specifier_nonarray : 'sampler2DMSArray' ;
type_specifier_nonarray : 'isampler2DMSArray' ;
type_specifier_nonarray : 'usampler2DMSArray' ;
type_specifier_nonarray : 'image1D' ;
type_specifier_nonarray : 'iimage1D' ;
type_specifier_nonarray : 'uimage1D' ;
type_specifier_nonarray : 'image2D' ;
type_specifier_nonarray : 'iimage2D' ;
type_specifier_nonarray : 'uimage2D' ;
type_specifier_nonarray : 'image3D' ;
type_specifier_nonarray : 'iimage3D' ;
type_specifier_nonarray : 'uimage3D' ;
type_specifier_nonarray : 'image2DRect' ;
type_specifier_nonarray : 'iimage2DRect' ;
type_specifier_nonarray : 'uimage2DRect' ;
type_specifier_nonarray : 'imageCube' ;
type_specifier_nonarray : 'iimageCube' ;
type_specifier_nonarray : 'uimageCube' ;
type_specifier_nonarray : 'imageBuffer' ;
type_specifier_nonarray : 'iimageBuffer' ;
type_specifier_nonarray : 'uimageBuffer' ;
type_specifier_nonarray : 'image1DArray' ;
type_specifier_nonarray : 'iimage1DArray' ;
type_specifier_nonarray : 'uimage1DArray' ;
type_specifier_nonarray : 'image2DArray' ;
type_specifier_nonarray : 'iimage2DArray' ;
type_specifier_nonarray : 'uimage2DArray' ;
type_specifier_nonarray : 'imageCubeArray' ;
type_specifier_nonarray : 'iimageCubeArray' ;
type_specifier_nonarray : 'uimageCubeArray' ;
type_specifier_nonarray : 'image2DMS' ;
type_specifier_nonarray : 'iimage2DMS' ;
type_specifier_nonarray : 'uimage2DMS' ;
type_specifier_nonarray : 'image2DMSArray' ;
type_specifier_nonarray : 'iimage2DMSArray' ;
type_specifier_nonarray : 'uimage2DMSArray' ;
type_specifier_nonarray : struct_specifier ;
type_specifier_nonarray : 'userDefinedType' ;
precision_qualifier : 'high_precision' ;
precision_qualifier : 'medium_precision' ;
precision_qualifier : 'low_precision' ;
// semantic parsing needed
struct_specifier : 'struct' type_name '{' struct_declaration_list '}' ;
type_name : 'identifier' ;
struct_specifier : 'struct' '{' struct_declaration_list '}' ;
struct_declaration_list : struct_declaration ;
struct_declaration_list : struct_declaration_list struct_declaration ;
struct_declaration : type_specifier struct_declarator_list ';' ;
struct_declaration : type_qualifier type_specifier struct_declarator_list ';' ;
struct_declarator_list : struct_declarator ;
struct_declarator_list : struct_declarator_list ',' struct_declarator ;
struct_declarator : 'identifier' ;
struct_declarator : 'identifier' array_specifier ;
initializer : assignment_expression ;
initializer : '{' initializer_list '}' ;
initializer : '{' initializer_list ',' '}' ;
initializer_list : initializer ;
initializer_list : initializer_list ',' initializer ;
declaration_statement : declaration ;
statement : compound_statement ;
statement : simple_statement ;
simple_statement : declaration_statement ;
simple_statement : expression_statement ;
simple_statement : selection_statement ;
simple_statement : switch_statement ;
simple_statement : case_label ;
simple_statement : iteration_statement ;
simple_statement : jump_statement ;
compound_statement : '{' '}' ;
compound_statement : '{' statement_list '}' ;
statement_no_new_scope : compound_statement_no_new_scope ;
statement_no_new_scope : simple_statement ;
compound_statement_no_new_scope : '{' '}' ;
compound_statement_no_new_scope : '{' statement_list '}' ;
statement_list : statement ;
statement_list : statement_list statement ;
expression_statement : ';' ;
expression_statement : expression ';' ;
selection_statement : 'if' '(' expression ')' selection_rest_statement ;
selection_rest_statement : statement 'else' statement ;
selection_rest_statement : statement ;
condition : expression ;
condition : fully_specified_type 'identifier' '=' initializer ;
switch_statement : 'switch' '(' expression ')' '{' switch_statement_list '}' ;
switch_statement_list : statement_list ;
case_label : 'case' expression ':' ;
case_label : 'default' ':' ;
iteration_statement : 'while' '(' condition ')' statement_no_new_scope ;
iteration_statement : 'do' statement 'while' '(' expression ')' ';' ;
iteration_statement : 'for' '(' for_init_statement for_rest_statement ')' statement_no_new_scope ;
for_init_statement : expression_statement ;
for_init_statement : declaration_statement ;
conditionopt : condition ;
for_rest_statement : conditionopt ';' ;
for_rest_statement : conditionopt ';' expression ;
jump_statement : 'continue' ';' ;
jump_statement : 'break' ';' ;
jump_statement : 'return' ';' ;
jump_statement : 'return' expression ';' ;
jump_statement : 'discard' ';' ;
// lexical statements
'identifier' : %%[a-z-A-Z_][a-z-A-Z0-9_]*%% ;
'number' : %%[-+]?[0-9]+([.][0-9]+)?([Ee][-+]?[0-9]+)?%% ;
标签:specifier,文法,statement,expression,练习,nonarray,测试,type,qualifier
From: https://www.cnblogs.com/bitzhuwei/p/some-grammars.html