apidoc
[ class tree: apidoc ] [ index: apidoc ] [ all elements ]

Class: PHP_LexerGenerator_Parser

Source Location: /PHP_ParserGenerator-0.1.7/examples/Parser.php

Class Overview


The state of the parser is completely contained in an instance of


Variables

Methods


Inherited Variables

Inherited Methods


Class Details

[line 142]
The state of the parser is completely contained in an instance of

the following structure



[ Top ]


Class Variables

$transTable = array(
        1 => self::PHPCODE,
        2 => self::COMMENTSTART,
        3 => self::COMMENTEND,
        4 => self::QUOTE,
        5 => self::PATTERN,
        6 => self::CODE,
        7 => self::SUBPATTERN,
        8 => self::PI,
    )

[line 157]

  • Access: public

Type:   mixed


[ Top ]

$yyerrcnt =

[line 578]

  • Access: public

Type:   int


[ Top ]

$yyExpectedTokens = array(
        /* 0 */ array(1, 2, ),/* 1 */array(4,5,8,),/* 2 */array(4,5,8,),/* 3 */array(5,8,),/* 4 */array(5,8,),/* 5 */array(5,8,),/* 6 */array(4,),/* 7 */array(3,5,8,),/* 8 */array(3,5,8,),/* 9 */array(3,5,8,),/* 10 */array(3,5,8,),/* 11 */array(3,5,8,),/* 12 */array(5,8,),/* 13 */array(1,2,),/* 14 */array(4,7,),/* 15 */array(5,8,),/* 16 */array(1,2,),/* 17 */array(2,),/* 18 */array(2,),/* 19 */array(2,),/* 20 */array(5,6,8,),/* 21 */array(5,6,8,),/* 22 */array(2,4,),/* 23 */array(2,4,),/* 24 */array(5,6,),/* 25 */array(2,4,),/* 26 */array(2,4,),/* 27 */array(5,8,),/* 28 */array(5,8,),/* 29 */array(5,6,),/* 30 */array(7,),/* 31 */array(1,),/* 32 */array(3,),/* 33 */array(1,),/* 34 */array(5,),/* 35 */array(5,),/* 36 */array(1,),/* 37 */array(2,),/* 38 */array(5,),/* 39 */array(1,),/* 40 */array(),/* 41 */array(),/* 42 */array(),/* 43 */array(),/* 44 */array(),/* 45 */array(),/* 46 */array(),/* 47 */array(),/* 48 */array(),/* 49 */array(),/* 50 */array(),/* 51 */array(),/* 52 */array(),/* 53 */array(),/* 54 */array(),/* 55 */array(),/* 56 */array(),/* 57 */array(),/* 58 */array(),/* 59 */array(),/* 60 */array(),)

[line 411]

  • Access: public

Type:   mixed


[ Top ]

$yyFallback = array(
    )

[line 531]

The next table maps tokens into fallback tokens. If a construct like the following:

%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.

  • Access: public

Type:   mixed


[ Top ]

$yyidx =

[line 574]

  • Access: public

Type:   int


[ Top ]

$yyReduceMap = array(
        1 => 1,
        2 => 2,
        3 => 3,
        4 => 4,
        5 => 5,
        6 => 6,
        7 => 7,
        8 => 7,
        9 => 9,
        10 => 9,
        11 => 11,
        12 => 12,
        13 => 13,
        14 => 14,
        15 => 15,
        16 => 16,
        17 => 17,
        18 => 18,
        19 => 19,
        20 => 20,
        21 => 21,
        22 => 22,
        23 => 23,
        27 => 23,
        24 => 24,
        25 => 25,
        29 => 25,
        26 => 26,
        28 => 28,
        30 => 30,
    )

[line 1009]

The following table contains a mapping of reduce action to method name that handles the reduction.

If a rule is not set, it has no handler.

  • Access: public

Type:   mixed


[ Top ]

$yyRuleInfo = array(
  array( 'lhs' => 10, 'rhs' => 1 ),array('lhs'=>11,'rhs'=>2),array('lhs'=>11,'rhs'=>3),array('lhs'=>11,'rhs'=>3),array('lhs'=>11,'rhs'=>4),array('lhs'=>12,'rhs'=>3),array('lhs'=>14,'rhs'=>2),array('lhs'=>15,'rhs'=>2),array('lhs'=>15,'rhs'=>2),array('lhs'=>15,'rhs'=>3),array('lhs'=>15,'rhs'=>3),array('lhs'=>16,'rhs'=>2),array('lhs'=>16,'rhs'=>3),array('lhs'=>13,'rhs'=>3),array('lhs'=>13,'rhs'=>5),array('lhs'=>13,'rhs'=>4),array('lhs'=>13,'rhs'=>6),array('lhs'=>13,'rhs'=>4),array('lhs'=>13,'rhs'=>6),array('lhs'=>13,'rhs'=>5),array('lhs'=>13,'rhs'=>7),array('lhs'=>18,'rhs'=>2),array('lhs'=>18,'rhs'=>3),array('lhs'=>19,'rhs'=>1),array('lhs'=>19,'rhs'=>1),array('lhs'=>19,'rhs'=>2),array('lhs'=>19,'rhs'=>2),array('lhs'=>17,'rhs'=>1),array('lhs'=>17,'rhs'=>1),array('lhs'=>17,'rhs'=>2),array('lhs'=>17,'rhs'=>2),)

[line 969]

The following table contains information about every rule that is used during the reduce.

static const struct { YYCODETYPE lhs; Symbol on the left-hand side of the rule unsigned char nrhs; Number of right-hand side symbols in the rule }

  • Access: public

Type:   mixed


[ Top ]

$yyRuleName = array(
 /*   0 */ "start ::= lexfile",
 /*   1 */ "lexfile ::= declare rules",
 /*   2 */ "lexfile ::= declare PHPCODE rules",
 /*   3 */ "lexfile ::= PHPCODE declare rules",
 /*   4 */ "lexfile ::= PHPCODE declare PHPCODE rules",
 /*   5 */ "declare ::= COMMENTSTART declarations COMMENTEND",
 /*   6 */ "declarations ::= processing_instructions pattern_declarations",
 /*   7 */ "processing_instructions ::= PI SUBPATTERN",
 /*   8 */ "processing_instructions ::= PI CODE",
 /*   9 */ "processing_instructions ::= processing_instructions PI SUBPATTERN",
 /*  10 */ "processing_instructions ::= processing_instructions PI CODE",
 /*  11 */ "pattern_declarations ::= PATTERN subpattern",
 /*  12 */ "pattern_declarations ::= pattern_declarations PATTERN subpattern",
 /*  13 */ "rules ::= COMMENTSTART rule COMMENTEND",
 /*  14 */ "rules ::= COMMENTSTART PI SUBPATTERN rule COMMENTEND",
 /*  15 */ "rules ::= COMMENTSTART rule COMMENTEND PHPCODE",
 /*  16 */ "rules ::= COMMENTSTART PI SUBPATTERN rule COMMENTEND PHPCODE",
 /*  17 */ "rules ::= rules COMMENTSTART rule COMMENTEND",
 /*  18 */ "rules ::= rules PI SUBPATTERN COMMENTSTART rule COMMENTEND",
 /*  19 */ "rules ::= rules COMMENTSTART rule COMMENTEND PHPCODE",
 /*  20 */ "rules ::= rules COMMENTSTART PI SUBPATTERN rule COMMENTEND PHPCODE",
 /*  21 */ "rule ::= rule_subpattern CODE",
 /*  22 */ "rule ::= rule rule_subpattern CODE",
 /*  23 */ "rule_subpattern ::= QUOTE",
 /*  24 */ "rule_subpattern ::= SUBPATTERN",
 /*  25 */ "rule_subpattern ::= rule_subpattern QUOTE",
 /*  26 */ "rule_subpattern ::= rule_subpattern SUBPATTERN",
 /*  27 */ "subpattern ::= QUOTE",
 /*  28 */ "subpattern ::= SUBPATTERN",
 /*  29 */ "subpattern ::= subpattern QUOTE",
 /*  30 */ "subpattern ::= subpattern SUBPATTERN",
    )

[line 602]

For tracing reduce actions, the names of all rules are required.
  • Access: public

Type:   array


[ Top ]

$yystack = array()

[line 583]

  • Access: public

Type:   array


[ Top ]

$yyTokenName = array( 
  '$',             'PHPCODE',       'COMMENTSTART',  'COMMENTEND',  
  'PI',            'SUBPATTERN',    'CODE',          'PATTERN',     
  'QUOTE',         'error',         'start',         'lexfile',     
  'declare',       'rules',         'declarations',  'processing_instructions',
  'pattern_declarations',  'subpattern',    'rule',          'rule_subpattern',
    )

[line 590]

For tracing shifts, the names of all terminals and nonterminals

are required. The following table supplies these names

  • Access: public

Type:   array


[ Top ]

$yyTraceFILE =

[line 569]

  • Access: public

Type:   mixed


[ Top ]

$yyTracePrompt =

[line 570]

  • Access: public

Type:   mixed


[ Top ]

$yy_action = array(
 /*     0 */    33,   31,   58,   58,    3,   50,   50,   57,   44,   39,
 /*    10 */    42,   58,   57,   55,   50,   42,   51,   36,   58,   58,
 /*    20 */    59,   50,   50,   38,   58,   46,   45,   50,   35,   58,
 /*    30 */    17,    2,   50,   93,   52,   16,   18,    6,   24,   19,
 /*    40 */     2,   12,   41,   53,   48,   40,   30,   60,    1,    4,
 /*    50 */    34,   10,   20,   43,   49,   32,   14,   58,    7,   20,
 /*    60 */    50,    8,   20,    9,   20,   37,   47,   11,   20,   56,
 /*    70 */    15,    5,   22,   54,   28,   23,   53,   21,   29,   25,
 /*    80 */     2,   27,    6,   13,   53,   53,   26,
    )

[line 375]

  • Access: public

Type:   mixed


[ Top ]

$yy_default = array(
 /*     0 */    92,   92,   92,   92,   92,   92,   92,   92,   92,   92,
 /*    10 */    92,   92,   92,   92,   92,   92,   92,   92,   92,   92,
 /*    20 */    92,   92,   64,   62,   92,   65,   63,   72,   73,   92,
 /*    30 */    67,   75,   92,   74,   92,   92,   92,   92,   92,   78,
 /*    40 */    88,   89,   86,   70,   83,   69,   68,   80,   91,   71,
 /*    50 */    84,   79,   61,   77,   76,   82,   81,   87,   85,   66,
 /*    60 */    90,
)

[line 474]

  • Access: public

Type:   mixed


[ Top ]

$yy_lookahead = array(
 /*     0 */     3,    3,    5,    5,    5,    8,    8,    5,    6,    3,
 /*    10 */     8,    5,    5,    6,    8,    8,    3,    3,    5,    5,
 /*    20 */     3,    8,    8,    4,    5,    5,    6,    8,    4,    5,
 /*    30 */     1,    2,    8,   10,   11,   12,    1,    2,    4,    1,
 /*    40 */     2,    7,    5,    1,    5,    8,   16,    8,    2,    5,
 /*    50 */     4,   18,   19,    5,    6,   14,   15,    5,   18,   19,
 /*    60 */     8,   18,   19,   18,   19,    5,    1,   18,   19,    1,
 /*    70 */     7,    2,   13,    1,   17,   13,   20,   19,    4,   13,
 /*    80 */     2,   17,    2,   12,   20,   20,   13,
)

[line 386]

  • Access: public

Type:   mixed


[ Top ]

$yy_reduce_ofst = array(
 /*     0 */    23,   49,   45,   33,   43,   40,   41,   58,   58,   58,
 /*    10 */    58,   58,   64,   59,   30,   57,   62,   73,   71,   66,
)

[line 407]

  • Access: public

Type:   mixed


[ Top ]

$yy_shift_ofst = array(
 /*     0 */    35,   24,   19,   52,   52,   52,   74,   13,   -2,   -3,
 /*    10 */    14,    6,   37,   38,   34,   37,   29,   78,   80,   78,
 /*    20 */     7,    2,   46,   46,   48,   46,   46,   39,   39,   20,
 /*    30 */    63,   42,   17,   72,   60,   -1,   68,   69,   44,   65,
)

[line 399]

  • Access: public

Type:   mixed


[ Top ]



Method Detail

doParse   [line 1549]

void doParse( int $yymajor, mixed $yytokenvalue, [mixed $extraargument = null])

The main parser program.

The first argument is a pointer to a structure obtained from "PHP_LexerGenerator_ParserAlloc" which describes the current state of the parser. The second argument is the major token number. The third is the minor token. The fourth optional argument is whatever the user wants (and specified in the grammar) and is available for use by the action routines.

Inputs:

  • A pointer to the parser (an opaque structure.)
  • The major token number.
  • The minor token number (token value).
  • An option argument of a grammar-specified type.
Outputs: None.


Parameters:

int   $yymajor   —  the token number
mixed   $yytokenvalue   —  the token value
mixed   $extraargument   —  any extra arguments that should be passed to handlers

[ Top ]

error   [line 279]

void error( $msg)


Parameters:

   $msg   — 

[ Top ]

outputRules   [line 177]

void outputRules( $rules, $statename)


Parameters:

   $rules   — 
   $statename   — 

[ Top ]

__construct (Constructor)   [line 168]

PHP_LexerGenerator_Parser __construct( $outfile, $lex)


Parameters:

   $outfile   — 
   $lex   — 

[ Top ]

__destruct (Destructor)   [line 704]

void __destruct( )

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

[ Top ]

PrintTrace   [line 563]

void PrintTrace( )


[ Top ]

tokenName   [line 642]

string tokenName( int $tokenType)

This function returns the symbolic name associated with a token value.

Parameters:

int   $tokenType   — 

[ Top ]

Trace   [line 552]

void Trace( resource $TraceFILE, string $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

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.


Parameters:

resource   $TraceFILE   — 
string   $zTracePrompt   — 

[ Top ]

yy_accept   [line 1515]

void yy_accept( )


[ Top ]

yy_destructor   [line 656]

void yy_destructor( $yymajor, $yypminor)


Parameters:

   $yymajor   — 
   $yypminor   — 

[ Top ]

yy_find_reduce_action   [line 899]

void yy_find_reduce_action( int $stateno, int $iLookAhead)

Find the appropriate action for a parser given the non-terminal look-ahead token iLookAhead.

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.


Parameters:

int   $stateno   —  Current state number
int   $iLookAhead   —  The look-ahead token

[ Top ]

yy_find_shift_action   [line 855]

void yy_find_shift_action( int $iLookAhead)

Find the appropriate action for a parser given the terminal look-ahead token iLookAhead.

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.


Parameters:

int   $iLookAhead   —  The look-ahead token

[ Top ]

yy_get_expected_tokens   [line 714]

void yy_get_expected_tokens( $token)


Parameters:

   $token   — 

[ Top ]

yy_is_expected_token   [line 780]

void yy_is_expected_token( $token)


Parameters:

   $token   — 

[ Top ]

yy_parse_failed   [line 1478]

void yy_parse_failed( )

The following code executes when the parse fails

[ Top ]

yy_pop_parser_stack   [line 683]

int yy_pop_parser_stack( PHP_LexerGenerator_ParseryyParser 0)

Pop the parser's stack once.

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.


Parameters:

PHP_LexerGenerator_ParseryyParser   0   — 

[ Top ]

yy_r1   [line 1048]

void yy_r1( )


[ Top ]

yy_r2   [line 1084]

void yy_r2( )


[ Top ]

yy_r3   [line 1123]

void yy_r3( )


[ Top ]

yy_r4   [line 1162]

void yy_r4( )


[ Top ]

yy_r5   [line 1204]

void yy_r5( )


[ Top ]

yy_r6   [line 1210]

void yy_r6( )


[ Top ]

yy_r7   [line 1247]

void yy_r7( )


[ Top ]

yy_r9   [line 1252]

void yy_r9( )


[ Top ]

yy_r11   [line 1258]

void yy_r11( )


[ Top ]

yy_r12   [line 1263]

void yy_r12( )


[ Top ]

yy_r13   [line 1273]

void yy_r13( )


[ Top ]

yy_r14   [line 1278]

void yy_r14( )


[ Top ]

yy_r15   [line 1287]

void yy_r15( )


[ Top ]

yy_r16   [line 1292]

void yy_r16( )


[ Top ]

yy_r17   [line 1301]

void yy_r17( )


[ Top ]

yy_r18   [line 1307]

void yy_r18( )


[ Top ]

yy_r19   [line 1317]

void yy_r19( )


[ Top ]

yy_r20   [line 1323]

void yy_r20( )


[ Top ]

yy_r21   [line 1333]

void yy_r21( )


[ Top ]

yy_r22   [line 1338]

void yy_r22( )


[ Top ]

yy_r23   [line 1344]

void yy_r23( )


[ Top ]

yy_r24   [line 1349]

void yy_r24( )


[ Top ]

yy_r25   [line 1358]

void yy_r25( )


[ Top ]

yy_r26   [line 1363]

void yy_r26( )


[ Top ]

yy_r28   [line 1372]

void yy_r28( )


[ Top ]

yy_r30   [line 1381]

void yy_r30( )


[ Top ]

yy_reduce   [line 1425]

void yy_reduce( int $yyruleno)

Perform a reduce action and the shift that must immediately follow the reduce.

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)


Parameters:

int   $yyruleno   —  Number of the rule by which to reduce

[ Top ]

yy_shift   [line 928]

void yy_shift( int $yyNewState, int $yyMajor, mixed $yypMinor)

Perform a shift action.

Parameters:

int   $yyNewState   —  The new state to shift in
int   $yyMajor   —  The major token to shift in
mixed   $yypMinor   —  the minor token to shift in

[ Top ]

yy_syntax_error   [line 1495]

void yy_syntax_error( int $yymajor, mixed $TOKEN)

The following code executes when a syntax error first occurs.

Parameters:

int   $yymajor   —  The major type of the error token
mixed   $TOKEN   —  The minor type of the error token

[ Top ]


Documentation generated on Mon, 11 Mar 2019 15:41:02 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.