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

Class: PHP_LexerGenerator_Parser

Source Location: /PHP_LexerGenerator-0.3.0/LexerGenerator/Parser.php

Class Overview


Token parser for plex files.


Author(s):

Version:

  • 0.3.0

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: 0.3.0
  • 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::PATTERN,
        6 => self::CODE,
        7 => self::SUBPATTERN,
        8 => self::PI,
    )

[line 187]

  • Access: public

Type:   mixed


[ Top ]

$yyerrcnt =

[line 754]

  • 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(1,2,),/* 5 */array(5,8,),/* 6 */array(1,2,),/* 7 */array(2,),/* 8 */array(4,),/* 9 */array(2,),/* 10 */array(3,5,8,),/* 11 */array(3,5,8,),/* 12 */array(3,5,8,),/* 13 */array(3,5,8,),/* 14 */array(4,7,),/* 15 */array(5,8,),/* 16 */array(5,8,),/* 17 */array(2,),/* 18 */array(5,6,8,),/* 19 */array(5,6,8,),/* 20 */array(5,6,),/* 21 */array(5,8,),/* 22 */array(5,8,),/* 23 */array(5,6,),/* 24 */array(1,),/* 25 */array(2,),/* 26 */array(7,),/* 27 */array(2,),/* 28 */array(3,),/* 29 */array(5,),/* 30 */array(1,),/* 31 */array(2,),/* 32 */array(1,),/* 33 */array(2,),/* 34 */array(5,),/* 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(),)

[line 598]

  • Access: public

Type:   mixed


[ Top ]

$yyFallback = array(
    )

[line 697]

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

  • 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,
    )

[line 1213]

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

[line 1172]

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 ::= SUBPATTERN",
 /*  26 */ "rule_subpattern ::= rule_subpattern QUOTE",
 /*  27 */ "rule_subpattern ::= rule_subpattern SUBPATTERN",
 /*  28 */ "subpattern ::= QUOTE",
 /*  29 */ "subpattern ::= SUBPATTERN",
 /*  30 */ "subpattern ::= subpattern QUOTE",
 /*  31 */ "subpattern ::= subpattern SUBPATTERN",
    )

[line 778]

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

Type:   array


[ Top ]

$yystack = array()

[line 758]

  • 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',          'reset_rules', 
  'rule_subpattern',
    )

[line 765]

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

  • Access: public

Type:   resource|0


[ Top ]

$yyTracePrompt =

[line 746]

String to prepend to debug output
  • Access: public

Type:   string|0


[ Top ]

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

[line 564]

  • Access: public

Type:   mixed


[ Top ]

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

[line 657]

  • Access: public

Type:   mixed


[ Top ]

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

[line 574]

  • Access: public

Type:   mixed


[ Top ]

$yy_reduce_ofst = array(
 /*     0 */    17,   29,   19,   26,   21,   36,   53,   44,   47,    0,
 /*    10 */    51,   51,   51,   51,   54,   58,   61,   64,
)

[line 594]

  • Access: public

Type:   mixed


[ Top ]

$yy_shift_ofst = array(
 /*     0 */    23,   27,   18,   28,   50,   28,   57,   72,   73,   72,
 /*    10 */    13,   12,   -3,   -2,   46,   40,   40,   77,    2,    6,
 /*    20 */    59,   33,   33,   37,    3,    7,   48,    7,   70,   55,
 /*    30 */    68,    7,   67,    7,   25,   66,
)

[line 586]

  • Access: public

Type:   mixed


[ Top ]



Method Detail

__construct (Constructor)   [line 198]

PHP_LexerGenerator_Parser __construct( $outfile, $lex)


Parameters:

   $outfile   — 
   $lex   — 

[ Top ]

__destruct (Destructor)   [line 885]

void __destruct( )

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

[ Top ]

doFirstMatch   [line 313]

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


Parameters:

   $rules   — 
   $statename   — 
   $ruleindex   — 

[ Top ]

doLongestMatch   [line 209]

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


Parameters:

   $rules   — 
   $statename   — 
   $ruleindex   — 

[ Top ]

doParse   [line 1789]

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

void error( $msg)


Parameters:

   $msg   — 

[ Top ]

outputRules   [line 425]

void outputRules( $rules, $statename)


Parameters:

   $rules   — 
   $statename   — 

[ Top ]

PrintTrace   [line 732]

void PrintTrace( )

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

[ Top ]

tokenName   [line 819]

string tokenName( int $tokenType)

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

Parameters:

int   $tokenType   — 

[ Top ]

Trace   [line 718]

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

void yy_accept( )

The following is executed when the parser accepts

%parse_accept code is inserted here


[ Top ]

yy_destructor   [line 837]

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

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

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

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

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

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

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

void yy_r1( )


[ Top ]

yy_r2   [line 1289]

void yy_r2( )


[ Top ]

yy_r3   [line 1328]

void yy_r3( )


[ Top ]

yy_r4   [line 1367]

void yy_r4( )


[ Top ]

yy_r5   [line 1409]

void yy_r5( )


[ Top ]

yy_r6   [line 1416]

void yy_r6( )


[ Top ]

yy_r7   [line 1458]

void yy_r7( )


[ Top ]

yy_r9   [line 1463]

void yy_r9( )


[ Top ]

yy_r11   [line 1469]

void yy_r11( )


[ Top ]

yy_r12   [line 1476]

void yy_r12( )


[ Top ]

yy_r13   [line 1488]

void yy_r13( )


[ Top ]

yy_r14   [line 1493]

void yy_r14( )


[ Top ]

yy_r15   [line 1502]

void yy_r15( )


[ Top ]

yy_r16   [line 1507]

void yy_r16( )


[ Top ]

yy_r17   [line 1517]

void yy_r17( )


[ Top ]

yy_r18   [line 1524]

void yy_r18( )


[ Top ]

yy_r19   [line 1534]

void yy_r19( )


[ Top ]

yy_r20   [line 1540]

void yy_r20( )


[ Top ]

yy_r21   [line 1550]

void yy_r21( )


[ Top ]

yy_r22   [line 1556]

void yy_r22( )


[ Top ]

yy_r23   [line 1568]

void yy_r23( )


[ Top ]

yy_r24   [line 1581]

void yy_r24( )


[ Top ]

yy_r25   [line 1586]

void yy_r25( )


[ Top ]

yy_r26   [line 1595]

void yy_r26( )


[ Top ]

yy_r27   [line 1600]

void yy_r27( )


[ Top ]

yy_r28   [line 1609]

void yy_r28( )


[ Top ]

yy_r29   [line 1614]

void yy_r29( )


[ Top ]

yy_r30   [line 1623]

void yy_r30( )


[ Top ]

yy_r31   [line 1628]

void yy_r31( )


[ Top ]

yy_reduce   [line 1671]

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

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

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