PHP Class Haanga_Compiler_Parser

Afficher le fichier Open project: crodas/haanga Class Usage Examples

Méthodes publiques

Свойство Type Description
$yyExpectedTokens
$yyFallback %fallback ID X Y Z. appears in the grammer, then ID becomes a fallback token for X, Y, and Z. Whenever one of the tokens X, Y, or Z is input to the parser but it does not parse, the type of the token is changed to ID and the parse is retried before an error is thrown.
$yyReduceMap If a rule is not set, it has no handler.
$yyRuleInfo
array(
 array(
  int $lhs;         Symbol on the left-hand side of the rule
  int $nrhs;     Number of right-hand side symbols in the rule
 ),...
);
$yyRuleName array For tracing reduce actions, the names of all rules are required.
$yyTokenName array For tracing shifts, the names of all terminals and nonterminals are required. The following table supplies these names
$yyTraceFILE resource | 0
$yyTracePrompt string | 0 String to prepend to debug output
$yy_action
$yy_default
$yy_lookahead
$yy_reduce_ofst
$yy_shift_ofst
$yyerrcnt integer
$yyidx integer
$yystack array

Protected Properties

Свойство Type Description
$file
$lex #line 40 "lib/Haanga/Compiler/Parser.y"

Méthodes publiques

Méthode Description
Error ( $text )
PrintTrace ( ) Output debug information to output (php://output stream)
Trace ( $TraceFILE, $zTracePrompt ) Turn parser tracing on by giving a stream to which to write the trace and a prompt to preface each trace message. Tracing is turned off by making either argument NULL
__construct ( $lex, $file = '' )
__destruct ( ) Deallocate and destroy a parser. Destructors are all called for all stack elements before shutting the parser down.
doParse ( integer $yymajor, mixed $yytokenvalue ) : void The main parser program.
tokenName ( $tokenType ) : string This function returns the symbolic name associated with a token value.
yy_accept ( ) The following is executed when the parser accepts
yy_destructor ( $yymajor, $yypminor ) The following function deletes the value associated with a symbol. The symbol can be either a terminal or nonterminal.
yy_find_reduce_action ( $stateno, $iLookAhead ) Find the appropriate action for a parser given the non-terminal look-ahead token $iLookAhead.
yy_find_shift_action ( $iLookAhead ) Find the appropriate action for a parser given the terminal look-ahead token iLookAhead.
yy_get_expected_tokens ( $token ) : array Based on the current state and parser stack, get a list of all possible lookahead tokens
yy_is_expected_token ( $token ) : boolean Based on the parser state and current parser stack, determine whether the lookahead token is possible.
yy_parse_failed ( ) The following code executes when the parse fails
yy_pop_parser_stack ( ) : integer Pop the parser's stack once.
yy_r0 ( ) #line 81 "lib/Haanga/Compiler/Parser.y"
yy_r1 ( ) #line 83 "lib/Haanga/Compiler/Parser.y"
yy_r14 ( ) #line 108 "lib/Haanga/Compiler/Parser.y"
yy_r18 ( ) #line 112 "lib/Haanga/Compiler/Parser.y"
yy_r19 ( ) #line 126 "lib/Haanga/Compiler/Parser.y"
yy_r2 ( ) #line 84 "lib/Haanga/Compiler/Parser.y"
yy_r20 ( ) #line 129 "lib/Haanga/Compiler/Parser.y"
yy_r21 ( ) #line 132 "lib/Haanga/Compiler/Parser.y"
yy_r22 ( ) #line 135 "lib/Haanga/Compiler/Parser.y"
yy_r23 ( ) #line 140 "lib/Haanga/Compiler/Parser.y"
yy_r24 ( ) #line 146 "lib/Haanga/Compiler/Parser.y"
yy_r25 ( ) #line 154 "lib/Haanga/Compiler/Parser.y"
yy_r26 ( ) #line 162 "lib/Haanga/Compiler/Parser.y"
yy_r27 ( ) #line 170 "lib/Haanga/Compiler/Parser.y"
yy_r29 ( ) #line 172 "lib/Haanga/Compiler/Parser.y"
yy_r3 ( ) #line 87 "lib/Haanga/Compiler/Parser.y"
yy_r30 ( ) #line 186 "lib/Haanga/Compiler/Parser.y"
yy_r31 ( ) #line 194 "lib/Haanga/Compiler/Parser.y"
yy_r32 ( ) #line 204 "lib/Haanga/Compiler/Parser.y"
yy_r33 ( ) #line 212 "lib/Haanga/Compiler/Parser.y"
yy_r34 ( ) #line 219 "lib/Haanga/Compiler/Parser.y"
yy_r35 ( ) #line 226 "lib/Haanga/Compiler/Parser.y"
yy_r36 ( ) #line 235 "lib/Haanga/Compiler/Parser.y"
yy_r37 ( ) #line 241 "lib/Haanga/Compiler/Parser.y"
yy_r38 ( ) #line 249 "lib/Haanga/Compiler/Parser.y"
yy_r39 ( ) #line 256 "lib/Haanga/Compiler/Parser.y"
yy_r4 ( ) #line 89 "lib/Haanga/Compiler/Parser.y"
yy_r40 ( ) #line 262 "lib/Haanga/Compiler/Parser.y"
yy_r41 ( ) #line 269 "lib/Haanga/Compiler/Parser.y"
yy_r42 ( ) #line 277 "lib/Haanga/Compiler/Parser.y"
yy_r43 ( ) #line 283 "lib/Haanga/Compiler/Parser.y"
yy_r44 ( ) #line 289 "lib/Haanga/Compiler/Parser.y"
yy_r45 ( ) #line 295 "lib/Haanga/Compiler/Parser.y"
yy_r46 ( ) #line 303 "lib/Haanga/Compiler/Parser.y"
yy_r47 ( ) #line 310 "lib/Haanga/Compiler/Parser.y"
yy_r48 ( ) #line 317 "lib/Haanga/Compiler/Parser.y"
yy_r5 ( ) #line 93 "lib/Haanga/Compiler/Parser.y"
yy_r50 ( ) #line 332 "lib/Haanga/Compiler/Parser.y"
yy_r51 ( ) #line 340 "lib/Haanga/Compiler/Parser.y"
yy_r52 ( ) #line 343 "lib/Haanga/Compiler/Parser.y"
yy_r53 ( ) #line 344 "lib/Haanga/Compiler/Parser.y"
yy_r54 ( ) #line 345 "lib/Haanga/Compiler/Parser.y"
yy_r55 ( ) #line 347 "lib/Haanga/Compiler/Parser.y"
yy_r57 ( ) #line 351 "lib/Haanga/Compiler/Parser.y"
yy_r6 ( ) #line 97 "lib/Haanga/Compiler/Parser.y"
yy_r60 ( ) #line 357 "lib/Haanga/Compiler/Parser.y"
yy_r61 ( ) #line 358 "lib/Haanga/Compiler/Parser.y"
yy_r62 ( ) #line 359 "lib/Haanga/Compiler/Parser.y"
yy_r63 ( ) #line 360 "lib/Haanga/Compiler/Parser.y"
yy_r64 ( ) #line 363 "lib/Haanga/Compiler/Parser.y"
yy_r7 ( ) #line 101 "lib/Haanga/Compiler/Parser.y"
yy_r70 ( ) #line 375 "lib/Haanga/Compiler/Parser.y"
yy_r71 ( ) #line 378 "lib/Haanga/Compiler/Parser.y"
yy_r72 ( ) #line 379 "lib/Haanga/Compiler/Parser.y"
yy_r75 ( ) #line 382 "lib/Haanga/Compiler/Parser.y"
yy_r77 ( ) #line 384 "lib/Haanga/Compiler/Parser.y"
yy_r78 ( ) #line 385 "lib/Haanga/Compiler/Parser.y"
yy_r79 ( ) #line 386 "lib/Haanga/Compiler/Parser.y"
yy_r8 ( ) #line 102 "lib/Haanga/Compiler/Parser.y"
yy_r81 ( ) #line 391 "lib/Haanga/Compiler/Parser.y"
yy_r82 ( ) #line 395 "lib/Haanga/Compiler/Parser.y"
yy_r83 ( ) #line 401 "lib/Haanga/Compiler/Parser.y"
yy_r84 ( ) #line 403 "lib/Haanga/Compiler/Parser.y"
yy_r85 ( ) #line 408 "lib/Haanga/Compiler/Parser.y"
yy_r86 ( ) #line 413 "lib/Haanga/Compiler/Parser.y"
yy_r89 ( ) #line 422 "lib/Haanga/Compiler/Parser.y"
yy_r9 ( ) #line 103 "lib/Haanga/Compiler/Parser.y"
yy_r93 ( ) #line 428 "lib/Haanga/Compiler/Parser.y"
yy_reduce ( $yyruleno ) Perform a reduce action and the shift that must immediately follow the reduce.
yy_shift ( $yyNewState, $yyMajor, $yypMinor ) Perform a shift action.
yy_syntax_error ( $yymajor, $TOKEN ) The following code executes when a syntax error first occurs.

Method Details

Error() public méthode

public Error ( $text )

PrintTrace() static public méthode

Output debug information to output (php://output stream)
static public PrintTrace ( )

Trace() static public méthode

Inputs: - A stream resource to which trace output should be written. If NULL, then tracing is turned off. - A prefix string written at the beginning of every line of trace output. If NULL, then tracing is turned off. Outputs: - None.
static public Trace ( $TraceFILE, $zTracePrompt )

__construct() public méthode

public __construct ( $lex, $file = '' )

__destruct() public méthode

Deallocate and destroy a parser. Destructors are all called for all stack elements before shutting the parser down.
public __destruct ( )

doParse() public méthode

The first argument is the major token number. The second is the token value string as scanned from the input.
public doParse ( integer $yymajor, mixed $yytokenvalue ) : void
$yymajor integer the token number
$yytokenvalue mixed the token value
Résultat void

tokenName() public méthode

This function returns the symbolic name associated with a token value.
public tokenName ( $tokenType ) : string
Résultat string

yy_accept() public méthode

%parse_accept code is inserted here
public yy_accept ( )

yy_destructor() static public méthode

The following function deletes the value associated with a symbol. The symbol can be either a terminal or nonterminal.
static public yy_destructor ( $yymajor, $yypminor )

yy_find_reduce_action() public méthode

If the look-ahead token is self::YYNOCODE, then check to see if the action is independent of the look-ahead. If it is, return the action, otherwise return self::YY_NO_ACTION.
public yy_find_reduce_action ( $stateno, $iLookAhead )

yy_find_shift_action() public méthode

If the look-ahead token is YYNOCODE, then check to see if the action is independent of the look-ahead. If it is, return the action, otherwise return YY_NO_ACTION.
public yy_find_shift_action ( $iLookAhead )

yy_get_expected_tokens() public méthode

Based on the current state and parser stack, get a list of all possible lookahead tokens
public yy_get_expected_tokens ( $token ) : array
Résultat array

yy_is_expected_token() public méthode

The parser will convert the token value to an error token if not. This catches some unusual edge cases where the parser would fail.
public yy_is_expected_token ( $token ) : boolean
Résultat boolean

yy_parse_failed() public méthode

Code from %parse_fail is inserted here
public yy_parse_failed ( )

yy_pop_parser_stack() public méthode

If there is a destructor routine associated with the token which is popped from the stack, then call it. Return the major token number for the symbol popped.
public yy_pop_parser_stack ( ) : integer
Résultat integer

yy_r0() public méthode

#line 81 "lib/Haanga/Compiler/Parser.y"
public yy_r0 ( )

yy_r1() public méthode

#line 83 "lib/Haanga/Compiler/Parser.y"
public yy_r1 ( )

yy_r14() public méthode

#line 108 "lib/Haanga/Compiler/Parser.y"
public yy_r14 ( )

yy_r18() public méthode

#line 112 "lib/Haanga/Compiler/Parser.y"
public yy_r18 ( )

yy_r19() public méthode

#line 126 "lib/Haanga/Compiler/Parser.y"
public yy_r19 ( )

yy_r2() public méthode

#line 84 "lib/Haanga/Compiler/Parser.y"
public yy_r2 ( )

yy_r20() public méthode

#line 129 "lib/Haanga/Compiler/Parser.y"
public yy_r20 ( )

yy_r21() public méthode

#line 132 "lib/Haanga/Compiler/Parser.y"
public yy_r21 ( )

yy_r22() public méthode

#line 135 "lib/Haanga/Compiler/Parser.y"
public yy_r22 ( )

yy_r23() public méthode

#line 140 "lib/Haanga/Compiler/Parser.y"
public yy_r23 ( )

yy_r24() public méthode

#line 146 "lib/Haanga/Compiler/Parser.y"
public yy_r24 ( )

yy_r25() public méthode

#line 154 "lib/Haanga/Compiler/Parser.y"
public yy_r25 ( )

yy_r26() public méthode

#line 162 "lib/Haanga/Compiler/Parser.y"
public yy_r26 ( )

yy_r27() public méthode

#line 170 "lib/Haanga/Compiler/Parser.y"
public yy_r27 ( )

yy_r29() public méthode

#line 172 "lib/Haanga/Compiler/Parser.y"
public yy_r29 ( )

yy_r3() public méthode

#line 87 "lib/Haanga/Compiler/Parser.y"
public yy_r3 ( )

yy_r30() public méthode

#line 186 "lib/Haanga/Compiler/Parser.y"
public yy_r30 ( )

yy_r31() public méthode

#line 194 "lib/Haanga/Compiler/Parser.y"
public yy_r31 ( )

yy_r32() public méthode

#line 204 "lib/Haanga/Compiler/Parser.y"
public yy_r32 ( )

yy_r33() public méthode

#line 212 "lib/Haanga/Compiler/Parser.y"
public yy_r33 ( )

yy_r34() public méthode

#line 219 "lib/Haanga/Compiler/Parser.y"
public yy_r34 ( )

yy_r35() public méthode

#line 226 "lib/Haanga/Compiler/Parser.y"
public yy_r35 ( )

yy_r36() public méthode

#line 235 "lib/Haanga/Compiler/Parser.y"
public yy_r36 ( )

yy_r37() public méthode

#line 241 "lib/Haanga/Compiler/Parser.y"
public yy_r37 ( )

yy_r38() public méthode

#line 249 "lib/Haanga/Compiler/Parser.y"
public yy_r38 ( )

yy_r39() public méthode

#line 256 "lib/Haanga/Compiler/Parser.y"
public yy_r39 ( )

yy_r4() public méthode

#line 89 "lib/Haanga/Compiler/Parser.y"
public yy_r4 ( )

yy_r40() public méthode

#line 262 "lib/Haanga/Compiler/Parser.y"
public yy_r40 ( )

yy_r41() public méthode

#line 269 "lib/Haanga/Compiler/Parser.y"
public yy_r41 ( )

yy_r42() public méthode

#line 277 "lib/Haanga/Compiler/Parser.y"
public yy_r42 ( )

yy_r43() public méthode

#line 283 "lib/Haanga/Compiler/Parser.y"
public yy_r43 ( )

yy_r44() public méthode

#line 289 "lib/Haanga/Compiler/Parser.y"
public yy_r44 ( )

yy_r45() public méthode

#line 295 "lib/Haanga/Compiler/Parser.y"
public yy_r45 ( )

yy_r46() public méthode

#line 303 "lib/Haanga/Compiler/Parser.y"
public yy_r46 ( )

yy_r47() public méthode

#line 310 "lib/Haanga/Compiler/Parser.y"
public yy_r47 ( )

yy_r48() public méthode

#line 317 "lib/Haanga/Compiler/Parser.y"
public yy_r48 ( )

yy_r5() public méthode

#line 93 "lib/Haanga/Compiler/Parser.y"
public yy_r5 ( )

yy_r50() public méthode

#line 332 "lib/Haanga/Compiler/Parser.y"
public yy_r50 ( )

yy_r51() public méthode

#line 340 "lib/Haanga/Compiler/Parser.y"
public yy_r51 ( )

yy_r52() public méthode

#line 343 "lib/Haanga/Compiler/Parser.y"
public yy_r52 ( )

yy_r53() public méthode

#line 344 "lib/Haanga/Compiler/Parser.y"
public yy_r53 ( )

yy_r54() public méthode

#line 345 "lib/Haanga/Compiler/Parser.y"
public yy_r54 ( )

yy_r55() public méthode

#line 347 "lib/Haanga/Compiler/Parser.y"
public yy_r55 ( )

yy_r57() public méthode

#line 351 "lib/Haanga/Compiler/Parser.y"
public yy_r57 ( )

yy_r6() public méthode

#line 97 "lib/Haanga/Compiler/Parser.y"
public yy_r6 ( )

yy_r60() public méthode

#line 357 "lib/Haanga/Compiler/Parser.y"
public yy_r60 ( )

yy_r61() public méthode

#line 358 "lib/Haanga/Compiler/Parser.y"
public yy_r61 ( )

yy_r62() public méthode

#line 359 "lib/Haanga/Compiler/Parser.y"
public yy_r62 ( )

yy_r63() public méthode

#line 360 "lib/Haanga/Compiler/Parser.y"
public yy_r63 ( )

yy_r64() public méthode

#line 363 "lib/Haanga/Compiler/Parser.y"
public yy_r64 ( )

yy_r7() public méthode

#line 101 "lib/Haanga/Compiler/Parser.y"
public yy_r7 ( )

yy_r70() public méthode

#line 375 "lib/Haanga/Compiler/Parser.y"
public yy_r70 ( )

yy_r71() public méthode

#line 378 "lib/Haanga/Compiler/Parser.y"
public yy_r71 ( )

yy_r72() public méthode

#line 379 "lib/Haanga/Compiler/Parser.y"
public yy_r72 ( )

yy_r75() public méthode

#line 382 "lib/Haanga/Compiler/Parser.y"
public yy_r75 ( )

yy_r77() public méthode

#line 384 "lib/Haanga/Compiler/Parser.y"
public yy_r77 ( )

yy_r78() public méthode

#line 385 "lib/Haanga/Compiler/Parser.y"
public yy_r78 ( )

yy_r79() public méthode

#line 386 "lib/Haanga/Compiler/Parser.y"
public yy_r79 ( )

yy_r8() public méthode

#line 102 "lib/Haanga/Compiler/Parser.y"
public yy_r8 ( )

yy_r81() public méthode

#line 391 "lib/Haanga/Compiler/Parser.y"
public yy_r81 ( )

yy_r82() public méthode

#line 395 "lib/Haanga/Compiler/Parser.y"
public yy_r82 ( )

yy_r83() public méthode

#line 401 "lib/Haanga/Compiler/Parser.y"
public yy_r83 ( )

yy_r84() public méthode

#line 403 "lib/Haanga/Compiler/Parser.y"
public yy_r84 ( )

yy_r85() public méthode

#line 408 "lib/Haanga/Compiler/Parser.y"
public yy_r85 ( )

yy_r86() public méthode

#line 413 "lib/Haanga/Compiler/Parser.y"
public yy_r86 ( )

yy_r89() public méthode

#line 422 "lib/Haanga/Compiler/Parser.y"
public yy_r89 ( )

yy_r9() public méthode

#line 103 "lib/Haanga/Compiler/Parser.y"
public yy_r9 ( )

yy_r93() public méthode

#line 428 "lib/Haanga/Compiler/Parser.y"
public yy_r93 ( )

yy_reduce() public méthode

For a rule such as:
A ::= B blah C. { dosomething(); }
This function will first call the action, if any, ("dosomething();" in our example), and then it will pop three states from the stack, one for each entry on the right-hand side of the expression (B, blah, and C in our example rule), and then push the result of the action back on to the stack with the resulting state reduced to (as described in the .out file)
public yy_reduce ( $yyruleno )

yy_shift() public méthode

Perform a shift action.
public yy_shift ( $yyNewState, $yyMajor, $yypMinor )

yy_syntax_error() public méthode

%syntax_error code is inserted here
public yy_syntax_error ( $yymajor, $TOKEN )

Property Details

$file protected_oe property

protected $file

$lex protected_oe property

#line 40 "lib/Haanga/Compiler/Parser.y"
protected $lex

$yyExpectedTokens public_oe static_oe property

public static $yyExpectedTokens

$yyFallback public_oe static_oe property

%fallback ID X Y Z. appears in the grammer, then ID becomes a fallback token for X, Y, and Z. Whenever one of the tokens X, Y, or Z is input to the parser but it does not parse, the type of the token is changed to ID and the parse is retried before an error is thrown.
public static $yyFallback

$yyReduceMap public_oe static_oe property

If a rule is not set, it has no handler.
public static $yyReduceMap

$yyRuleInfo public_oe static_oe property

array(
 array(
  int $lhs;         Symbol on the left-hand side of the rule
  int $nrhs;     Number of right-hand side symbols in the rule
 ),...
);
public static $yyRuleInfo

$yyRuleName public_oe static_oe property

For tracing reduce actions, the names of all rules are required.
public static array $yyRuleName
Résultat array

$yyTokenName public_oe static_oe property

For tracing shifts, the names of all terminals and nonterminals are required. The following table supplies these names
public static array $yyTokenName
Résultat array

$yyTraceFILE public_oe static_oe property

public static resource|0 $yyTraceFILE
Résultat resource | 0

$yyTracePrompt public_oe static_oe property

String to prepend to debug output
public static string|0 $yyTracePrompt
Résultat string | 0

$yy_action public_oe static_oe property

public static $yy_action

$yy_default public_oe static_oe property

public static $yy_default

$yy_lookahead public_oe static_oe property

public static $yy_lookahead

$yy_reduce_ofst public_oe static_oe property

public static $yy_reduce_ofst

$yy_shift_ofst public_oe static_oe property

public static $yy_shift_ofst

$yyerrcnt public_oe property

public int $yyerrcnt
Résultat integer

$yyidx public_oe property

public int $yyidx
Résultat integer

$yystack public_oe property

public array $yystack
Résultat array