PHP Class Haanga_Compiler_Parser

ファイルを表示 Open project: crodas/haanga Class Usage Examples

Public Properties

Property 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

Property Type Description
$file
$lex #line 40 "lib/Haanga/Compiler/Parser.y"

Public Methods

Method 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 method

public Error ( $text )

PrintTrace() static public method

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

Trace() static public method

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 method

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

__destruct() public method

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

doParse() public method

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
return void

tokenName() public method

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

yy_accept() public method

%parse_accept code is inserted here
public yy_accept ( )

yy_destructor() static public method

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 method

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 method

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 method

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

yy_is_expected_token() public method

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
return boolean

yy_parse_failed() public method

Code from %parse_fail is inserted here
public yy_parse_failed ( )

yy_pop_parser_stack() public method

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
return integer

yy_r0() public method

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

yy_r1() public method

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

yy_r14() public method

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

yy_r18() public method

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

yy_r19() public method

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

yy_r2() public method

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

yy_r20() public method

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

yy_r21() public method

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

yy_r22() public method

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

yy_r23() public method

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

yy_r24() public method

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

yy_r25() public method

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

yy_r26() public method

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

yy_r27() public method

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

yy_r29() public method

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

yy_r3() public method

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

yy_r30() public method

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

yy_r31() public method

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

yy_r32() public method

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

yy_r33() public method

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

yy_r34() public method

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

yy_r35() public method

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

yy_r36() public method

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

yy_r37() public method

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

yy_r38() public method

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

yy_r39() public method

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

yy_r4() public method

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

yy_r40() public method

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

yy_r41() public method

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

yy_r42() public method

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

yy_r43() public method

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

yy_r44() public method

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

yy_r45() public method

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

yy_r46() public method

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

yy_r47() public method

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

yy_r48() public method

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

yy_r5() public method

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

yy_r50() public method

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

yy_r51() public method

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

yy_r52() public method

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

yy_r53() public method

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

yy_r54() public method

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

yy_r55() public method

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

yy_r57() public method

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

yy_r6() public method

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

yy_r60() public method

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

yy_r61() public method

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

yy_r62() public method

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

yy_r63() public method

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

yy_r64() public method

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

yy_r7() public method

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

yy_r70() public method

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

yy_r71() public method

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

yy_r72() public method

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

yy_r75() public method

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

yy_r77() public method

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

yy_r78() public method

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

yy_r79() public method

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

yy_r8() public method

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

yy_r81() public method

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

yy_r82() public method

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

yy_r83() public method

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

yy_r84() public method

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

yy_r85() public method

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

yy_r86() public method

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

yy_r89() public method

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

yy_r9() public method

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

yy_r93() public method

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

yy_reduce() public method

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 method

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

yy_syntax_error() public method

%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
return 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
return array

$yyTraceFILE public_oe static_oe property

public static resource|0 $yyTraceFILE
return resource | 0

$yyTracePrompt public_oe static_oe property

String to prepend to debug output
public static string|0 $yyTracePrompt
return 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
return integer

$yyidx public_oe property

public int $yyidx
return integer

$yystack public_oe property

public array $yystack
return array