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

Class: PHP_LexerGenerator_Parser

Source Location: /PHP_LexerGenerator-0.4.0/PHP/LexerGenerator/Parser.php

Class Overview


Token parser for plex files.


Author(s):

Version:

  • @package_version@

Copyright:

  • 2006 Gregory Beaver

Variables

Methods


Inherited Variables

Inherited Methods


Class Details

[line 168]
Token parser for plex files.

This parser converts tokens pulled from PHP_LexerGenerator_Lexer into abstract patterns and rules, then creates the output file

  • Author: Gregory Beaver <cellog@php.net>
  • Version: @package_version@
  • Copyright: 2006 Gregory Beaver
  • Since: Class available since Release 0.1.0
  • License: PHP License 3.01


[ Top ]


Class Variables

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

[line 191]

  • Access: public

Type:   mixed


[ Top ]

$yyerrcnt =

[line 799]

  • Access: public

Type:   int


[ Top ]

$yyExpectedTokens = array(
        /* 0 */ array(1, 2, ),/* 1 */array(4,5,8,9,),/* 2 */array(4,5,8,9,),/* 3 */array(5,8,9,),/* 4 */array(5,8,9,),/* 5 */array(1,2,),/* 6 */array(1,2,),/* 7 */array(4,),/* 8 */array(2,),/* 9 */array(2,),/* 10 */array(3,5,8,9,),/* 11 */array(3,5,8,9,),/* 12 */array(3,5,8,9,),/* 13 */array(3,5,8,9,),/* 14 */array(5,8,9,),/* 15 */array(5,8,9,),/* 16 */array(4,7,),/* 17 */array(2,),/* 18 */array(5,6,8,9,),/* 19 */array(5,6,8,9,),/* 20 */array(5,8,9,),/* 21 */array(5,8,9,),/* 22 */array(5,6,),/* 23 */array(5,6,),/* 24 */array(3,),/* 25 */array(1,),/* 26 */array(7,),/* 27 */array(2,),/* 28 */array(2,),/* 29 */array(5,),/* 30 */array(1,),/* 31 */array(5,),/* 32 */array(1,),/* 33 */array(2,),/* 34 */array(2,),/* 35 */array(1,),/* 36 */array(),/* 37 */array(),/* 38 */array(),/* 39 */array(),/* 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 638]

  • Access: public

Type:   mixed


[ Top ]

$yyFallback = array(
    )

[line 742]

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 795]

  • 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,
        24 => 24,
        25 => 25,
        26 => 26,
        27 => 27,
        28 => 28,
        29 => 29,
        30 => 30,
        31 => 31,
        32 => 32,
        33 => 33,
        34 => 34,
        35 => 35,
    )

[line 1268]

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' => 11, 'rhs' => 1 ),array('lhs'=>12,'rhs'=>2),array('lhs'=>12,'rhs'=>3),array('lhs'=>12,'rhs'=>3),array('lhs'=>12,'rhs'=>4),array('lhs'=>13,'rhs'=>3),array('lhs'=>15,'rhs'=>2),array('lhs'=>16,'rhs'=>2),array('lhs'=>16,'rhs'=>2),array('lhs'=>16,'rhs'=>3),array('lhs'=>16,'rhs'=>3),array('lhs'=>17,'rhs'=>2),array('lhs'=>17,'rhs'=>3),array('lhs'=>14,'rhs'=>3),array('lhs'=>14,'rhs'=>5),array('lhs'=>14,'rhs'=>4),array('lhs'=>14,'rhs'=>6),array('lhs'=>14,'rhs'=>3),array('lhs'=>14,'rhs'=>5),array('lhs'=>14,'rhs'=>4),array('lhs'=>14,'rhs'=>6),array('lhs'=>20,'rhs'=>2),array('lhs'=>19,'rhs'=>2),array('lhs'=>19,'rhs'=>3),array('lhs'=>21,'rhs'=>1),array('lhs'=>21,'rhs'=>1),array('lhs'=>21,'rhs'=>1),array('lhs'=>21,'rhs'=>2),array('lhs'=>21,'rhs'=>2),array('lhs'=>21,'rhs'=>2),array('lhs'=>18,'rhs'=>1),array('lhs'=>18,'rhs'=>1),array('lhs'=>18,'rhs'=>1),array('lhs'=>18,'rhs'=>2),array('lhs'=>18,'rhs'=>2),array('lhs'=>18,'rhs'=>2),)

[line 1223]

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

 array(
  array(
   int $lhs;         Symbol on the left-hand side of the rule
   int $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 ::= reset_rules rule COMMENTEND",
 /*  18 */ "rules ::= reset_rules PI SUBPATTERN rule COMMENTEND",
 /*  19 */ "rules ::= reset_rules rule COMMENTEND PHPCODE",
 /*  20 */ "rules ::= reset_rules PI SUBPATTERN rule COMMENTEND PHPCODE",
 /*  21 */ "reset_rules ::= rules COMMENTSTART",
 /*  22 */ "rule ::= rule_subpattern CODE",
 /*  23 */ "rule ::= rule rule_subpattern CODE",
 /*  24 */ "rule_subpattern ::= QUOTE",
 /*  25 */ "rule_subpattern ::= SINGLEQUOTE",
 /*  26 */ "rule_subpattern ::= SUBPATTERN",
 /*  27 */ "rule_subpattern ::= rule_subpattern QUOTE",
 /*  28 */ "rule_subpattern ::= rule_subpattern SINGLEQUOTE",
 /*  29 */ "rule_subpattern ::= rule_subpattern SUBPATTERN",
 /*  30 */ "subpattern ::= QUOTE",
 /*  31 */ "subpattern ::= SINGLEQUOTE",
 /*  32 */ "subpattern ::= SUBPATTERN",
 /*  33 */ "subpattern ::= subpattern QUOTE",
 /*  34 */ "subpattern ::= subpattern SINGLEQUOTE",
 /*  35 */ "subpattern ::= subpattern SUBPATTERN",
    )

[line 823]

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

Type:   array


[ Top ]

$yystack = array()

[line 803]

  • Access: public

Type:   array


[ Top ]

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

[line 810]

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 786]

  • Access: public

Type:   resource|0


[ Top ]

$yyTracePrompt =

[line 791]

String to prepend to debug output
  • Access: public

Type:   string|0


[ Top ]

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

[line 600]

  • Access: public

Type:   mixed


[ Top ]

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

[line 701]

  • Access: public

Type:   mixed


[ Top ]

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

[line 612]

  • Access: public

Type:   mixed


[ Top ]

$yy_reduce_ofst = array(
 /*     0 */    33,   28,   -9,   46,   36,   52,   63,   58,   61,    5,
 /*    10 */    64,   64,   64,   64,   66,   68,   70,   76,
)

[line 634]

  • Access: public

Type:   mixed


[ Top ]

$yy_shift_ofst = array(
 /*     0 */    60,   27,   -1,   45,   45,   62,   67,   84,   80,   80,
 /*    10 */    34,   25,   -3,    6,   51,   51,    9,   88,   12,   18,
 /*    20 */    43,   43,   65,   35,   19,    0,   22,   74,   74,   75,
 /*    30 */    78,   53,   77,   74,   74,   37,
)

[line 626]

  • Access: public

Type:   mixed


[ Top ]



Method Detail

__construct (Constructor)   [line 203]

PHP_LexerGenerator_Parser __construct( $outfile, $lex)


Parameters:

   $outfile   — 
   $lex   — 

[ Top ]

__destruct (Destructor)   [line 934]

void __destruct( )

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

[ Top ]

doFirstMatch   [line 321]

void doFirstMatch( $rules, $statename, $ruleindex)


Parameters:

   $rules   — 
   $statename   — 
   $ruleindex   — 

[ Top ]

doLongestMatch   [line 214]

void doLongestMatch( $rules, $statename, $ruleindex)


Parameters:

   $rules   — 
   $statename   — 
   $ruleindex   — 

[ Top ]

doParse   [line 1872]

void doParse( int $yymajor, mixed $yytokenvalue, mixed 2)

The main parser program.

The first argument is the major token number. The second is the token value string as scanned from the input.


Parameters:

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

[ Top ]

error   [line 504]

void error( $msg)


Parameters:

   $msg   — 

[ Top ]

makeCaseInsensitve   [line 456]

void makeCaseInsensitve( $string)


Parameters:

   $string   — 

[ Top ]

outputRules   [line 461]

void outputRules( $rules, $statename)


Parameters:

   $rules   — 
   $statename   — 

[ Top ]

PrintTrace   [line 777]

void PrintTrace( )

Output debug information to output (php://output stream)

[ Top ]

tokenName   [line 868]

string tokenName( int $tokenType)

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

Parameters:

int   $tokenType   — 

[ Top ]

Trace   [line 763]

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 1850]

void yy_accept( )

The following is executed when the parser accepts

%parse_accept code is inserted here


[ Top ]

yy_destructor   [line 886]

void yy_destructor( int $yymajor, mixed $yypminor)

The following function deletes the value associated with a symbol. The symbol can be either a terminal or nonterminal.

Parameters:

int   $yymajor   —  the symbol code
mixed   $yypminor   —  the symbol's value

[ Top ]

yy_find_reduce_action   [line 1149]

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


Parameters:

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

[ Top ]

yy_find_shift_action   [line 1105]

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 950]

array yy_get_expected_tokens( int $token)

Based on the current state and parser stack, get a list of all

possible lookahead tokens


Parameters:

int   $token   — 

[ Top ]

yy_is_expected_token   [line 1025]

bool yy_is_expected_token( int $token)

Based on the parser state and current parser stack, determine whether the lookahead token is possible.

The parser will convert the token value to an error token if not. This catches some unusual edge cases where the parser would fail.


Parameters:

int   $token   — 

[ Top ]

yy_parse_failed   [line 1809]

void yy_parse_failed( )

The following code executes when the parse fails

Code from %parse_fail is inserted here


[ Top ]

yy_pop_parser_stack   [line 913]

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 1312]

void yy_r1( )


[ Top ]

yy_r2   [line 1348]

void yy_r2( )


[ Top ]

yy_r3   [line 1387]

void yy_r3( )


[ Top ]

yy_r4   [line 1426]

void yy_r4( )


[ Top ]

yy_r5   [line 1468]

void yy_r5( )


[ Top ]

yy_r6   [line 1475]

void yy_r6( )


[ Top ]

yy_r7   [line 1521]

void yy_r7( )


[ Top ]

yy_r9   [line 1526]

void yy_r9( )


[ Top ]

yy_r11   [line 1532]

void yy_r11( )


[ Top ]

yy_r12   [line 1539]

void yy_r12( )


[ Top ]

yy_r13   [line 1551]

void yy_r13( )


[ Top ]

yy_r14   [line 1556]

void yy_r14( )


[ Top ]

yy_r15   [line 1565]

void yy_r15( )


[ Top ]

yy_r16   [line 1570]

void yy_r16( )


[ Top ]

yy_r17   [line 1580]

void yy_r17( )


[ Top ]

yy_r18   [line 1587]

void yy_r18( )


[ Top ]

yy_r19   [line 1597]

void yy_r19( )


[ Top ]

yy_r20   [line 1603]

void yy_r20( )


[ Top ]

yy_r21   [line 1613]

void yy_r21( )


[ Top ]

yy_r22   [line 1619]

void yy_r22( )


[ Top ]

yy_r23   [line 1631]

void yy_r23( )


[ Top ]

yy_r24   [line 1644]

void yy_r24( )


[ Top ]

yy_r25   [line 1649]

void yy_r25( )


[ Top ]

yy_r26   [line 1654]

void yy_r26( )


[ Top ]

yy_r27   [line 1663]

void yy_r27( )


[ Top ]

yy_r28   [line 1668]

void yy_r28( )


[ Top ]

yy_r29   [line 1673]

void yy_r29( )


[ Top ]

yy_r30   [line 1682]

void yy_r30( )


[ Top ]

yy_r31   [line 1687]

void yy_r31( )


[ Top ]

yy_r32   [line 1692]

void yy_r32( )


[ Top ]

yy_r33   [line 1701]

void yy_r33( )


[ Top ]

yy_r34   [line 1706]

void yy_r34( )


[ Top ]

yy_r35   [line 1711]

void yy_r35( )


[ Top ]

yy_reduce   [line 1754]

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 1178]

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 1828]

void yy_syntax_error( int $yymajor, mixed $TOKEN)

The following code executes when a syntax error first occurs.

%syntax_error code is inserted here


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:40:44 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.