phpDocumentor PHP_ParserGenerator
[ class tree: PHP_ParserGenerator ] [ index: PHP_ParserGenerator ] [ all elements ]

Class: PHP_ParserGenerator_Symbol

Source Location: /ParserGenerator/Symbol.php

Class PHP_ParserGenerator_Symbol

Class Overview

Symbols (terminals and nonterminals) of the grammar are stored in this class

Located in /ParserGenerator/Symbol.php [line 58]



		
				Author(s):
		
		
		
Information Tags:
Since:  Class available since Release 0.1.0
Version:  @package_version@
License:  New BSD License
Copyright:  2006 Gregory Beaver

Properties

Methods

[ Top ]
Constant Summary
LEFT  
MULTITERMINAL   Multiple terminal symbols.
NONE  
NONTERMINAL   Symbols that start with a lower-case letter like foo.
RIGHT  
TERMINAL   Symbols that start with a capital letter like FOO.
UNK  

[ Top ]
Property Summary
unknown_type   $assoc   Associativity if precedence is defined.
string   $datatype   Unused relic of the C version of Lemon.
string|0   $destructor   Code that executes whenever this symbol is popped from the stack during error processing.
int   $destructorln   Line number of destructor code
string   $dtnum   Unused relic of the C version of Lemon.
PHP_ParserGenerator_Symbol   $fallback   Fallback token in case this token doesn't parse
array   $firstset   First-set for all rules of this symbol
int   $index   Index of this symbol.
boolean   $lambda   True if this symbol is a non-terminal and can generate an empty result.
string   $name   Name of the symbol
int   $nsubsym   Number of terminal symbols in the MULTITERMINAL
int   $prec   Precendence, if defined.
PHP_ParserGenerator_Rule   $rule   Linked list of rules that use this symbol, if it is a non-terminal.
array   $subsym   Array of terminal symbols in the MULTITERMINAL
int   $type   Symbol type

[ Top ]
Method Summary
static void   same_symbol()   Return true if two symbols are the same.
static void   sortSymbols()   Sort function helper for symbols
static void   Symbol_arrayof()  
static int   Symbol_count()   Return the number of unique symbols
static void   Symbol_find()  
static PHP_ParserGenerator_Symbol   Symbol_new()   Return a pointer to the (terminal or nonterminal) symbol "x".

[ Top ]
Properties
unknown_type   $assoc [line 135]

Associativity if precedence is defined.

One of PHP_ParserGenerator_Symbol::LEFT, PHP_ParserGenerator_Symbol::RIGHT, PHP_ParserGenerator_Symbol::NONE or PHP_ParserGenerator_Symbol::UNK

API Tags:
Access:  public


[ Top ]
string   $datatype [line 169]

Unused relic of the C version of Lemon.

The data type of information held by this object. Only used if this is a non-terminal

API Tags:
Access:  public


[ Top ]
string|0   $destructor = 0 [line 156]

Code that executes whenever this symbol is popped from the stack during error processing.

API Tags:
Access:  public


[ Top ]
int   $destructorln [line 161]

Line number of destructor code

API Tags:
Access:  public


[ Top ]
string   $dtnum [line 178]

Unused relic of the C version of Lemon.

The data type number. In the parser, the value stack is a union. The .yy%d element of this union is the correct data type for this object

API Tags:
Access:  public


[ Top ]
PHP_ParserGenerator_Symbol   $fallback [line 119]

Fallback token in case this token doesn't parse

API Tags:
Access:  public


[ Top ]
array   $firstset [line 141]

First-set for all rules of this symbol

API Tags:
Access:  public


[ Top ]
int   $index [line 100]

Index of this symbol.

This will ultimately end up representing the symbol in the generated parser

API Tags:
Access:  public


[ Top ]
boolean   $lambda [line 149]

True if this symbol is a non-terminal and can generate an empty result.

For instance "foo ::= ."

API Tags:
Access:  public


[ Top ]
string   $name [line 92]

Name of the symbol

API Tags:
Access:  public


[ Top ]
int   $nsubsym [line 188]

Number of terminal symbols in the MULTITERMINAL

The following fields are used by MULTITERMINALs only This is of course the same as count($this->subsym)

API Tags:
Access:  public


[ Top ]
int   $prec = -1 [line 126]

Precendence, if defined.

-1 if no unusual precedence

API Tags:
Access:  public


[ Top ]
PHP_ParserGenerator_Rule   $rule [line 114]

Linked list of rules that use this symbol, if it is a non-terminal.

API Tags:
Access:  public


[ Top ]
array   $subsym = array() [line 193]

Array of terminal symbols in the MULTITERMINAL

The following fields are used by MULTITERMINALs only

API Tags:
Access:  public


[ Top ]
int   $type [line 109]

Symbol type

One of PHP_ParserGenerator_Symbol::TERMINAL, PHP_ParserGenerator_Symbol::NONTERMINAL or PHP_ParserGenerator_Symbol::MULTITERMINAL

API Tags:
Access:  public


[ Top ]
Methods
static method same_symbol  [line 273]

  static void same_symbol( PHP_ParserGenerator_Symbol $a, PHP_ParserGenerator_Symbol $b  )

Return true if two symbols are the same.

Parameters:
PHP_ParserGenerator_Symbol   $a: 
PHP_ParserGenerator_Symbol   $b: 

API Tags:
Access:  public


[ Top ]
static method sortSymbols  [line 263]

  static void sortSymbols( PHP_ParserGenerator_Symbol $a, PHP_ParserGenerator_Symbol $b  )

Sort function helper for symbols

Symbols that begin with upper case letters (terminals or tokens) must sort before symbols that begin with lower case letters (non-terminals). Other than that, the order does not matter.

We find experimentally that leaving the symbols in their original order (the order they appeared in the grammar file) gives the smallest parser tables in SQLite.

Parameters:
PHP_ParserGenerator_Symbol   $a: 
PHP_ParserGenerator_Symbol   $b: 

API Tags:
Access:  public


[ Top ]
static method Symbol_arrayof  [line 237]

  static void Symbol_arrayof( )


API Tags:
Access:  public


[ Top ]
static method Symbol_count  [line 232]

  static int Symbol_count( )

Return the number of unique symbols


API Tags:
Access:  public


[ Top ]
static method Symbol_find  [line 242]

  static void Symbol_find( $x  )

Parameters:
   $x: 

API Tags:
Access:  public


[ Top ]
static method Symbol_new  [line 208]

  static PHP_ParserGenerator_Symbol Symbol_new( string $x  )

Return a pointer to the (terminal or nonterminal) symbol "x".

Create a new symbol if this is the first time "x" has been seen. (this is a singleton)

Parameters:
string   $x: 

API Tags:
Access:  public


[ Top ]
Constants
LEFT = 1 [line 83]

[ Top ]
MULTITERMINAL = 3 [line 81]

Multiple terminal symbols.

These are a grammar rule that consists of several terminals like FOO|BAR|BAZ. Note that non-terminals cannot be in a multi-terminal, and a multi-terminal acts like a single terminal.

"FOO|BAR FOO|BAZ" is actually two multi-terminals, FOO|BAR and FOO|BAZ.


[ Top ]
NONE = 3 [line 85]

[ Top ]
NONTERMINAL = 2 [line 71]

Symbols that start with a lower-case letter like foo.

These are grammar rules like "foo ::= BLAH."


[ Top ]
RIGHT = 2 [line 84]

[ Top ]
TERMINAL = 1 [line 65]

Symbols that start with a capital letter like FOO.

These are tokens directly from the lexer


[ Top ]
UNK = 4 [line 86]

[ Top ]

Documentation generated on Sun, 02 Jul 2006 09:11:12 -0400 by phpDocumentor 1.3.0