Which rules apply and why?
I'm trying to parse this sample PHP program:
class SimpleClass
{
// Deklaration einer Eigenschaft
public $var = 'ein Standardwert';
// Deklaration einer Methode
public function displayVar() {
echo $this->var;
}
}
Wile the generated parser sees public, it fails to continue with
class_variable_declaration in the first alternative of class_statement.
Additionally, I wonder why as of the graphics below, the first
class_statement node is empty.
Could someone help out?
Class declaration:
class_declaration_statement:
( 'class' | 'abstract' 'class' | 'trait' | 'final' 'class' )
SYMBOL_NAME_LITERAL
( 'extends' fully_qualified_class_name ) ?
( 'implements' interface_list ) ?
'{' class_statement* '}'
| 'interface' SYMBOL_NAME_LITERAL
( 'extends' interface_list ) ?
'{' class_statement* '}'
;
Class statement:
class_statement:
variable_modifiers class_variable_declaration ';'
| class_constant_declaration ';'
| trait_use_statement
| method_modifiers function is_reference SYMBOL_NAME_LITERAL
'(' parameter_list ')'
( ';' | ( '{' inner_statement_list '}' )
;
Class variable declaration
class_variable_declaration:
DOLLAR_VARIABLE ( ',' DOLLAR_VARIABLE )* ( '=' static_scalar )?
;
Modifiers
variable_modifiers:
member_modifier *
| VAR
;
member_modifier:
PUBLIC
| PROTECTED
| PRIVATE
| STATIC
| ABSTRACT
| FINAL
;
ANTLR v 4.1 in use
No comments:
Post a Comment