fri.patterns.interpreter.parsergenerator.syntax.builder
Class SyntaxBuilderSemantic

java.lang.Object
  |
  +--fri.patterns.interpreter.parsergenerator.syntax.builder.SyntaxBuilderSemantic
All Implemented Interfaces:
Semantic

public class SyntaxBuilderSemantic
extends java.lang.Object
implements Semantic

A syntax specification similar to EBNF. This semantic is used to build a Parser with Lexer from a textual EBNF syntax specification.

The semantics of ".." is the description of the set between leading and trailing character. The leading must be the one with the lower UNICODE value.

The semantics of "-" is intersection. When specifiying chars - comment - stringdef this means all chars but not comments or stringdef, i.e. stringdef is not subtracted from comment but from chars!

TODO: think over repeat number symbol: parser AND lexer would need this. Better define this by written symbols like "a ::= b b b b;"? But what to do on hundred "b"?

Author:
(c) 2002 Fritz Ritzberger

Field Summary
static java.lang.String[][] syntax
           
 
Constructor Summary
SyntaxBuilderSemantic()
          Creates a syntax builder semantic that resolves parenthesis and quantifiers.
SyntaxBuilderSemantic(java.util.List initialNonterminals)
          Creates a syntax builder semantic that resolves parenthesis and quantifiers.
 
Method Summary
 java.lang.Object doSemantic(Rule rule, java.util.List inputTokens, java.util.List ranges)
          Called by every REDUCE step.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

syntax

public static java.lang.String[][] syntax
Constructor Detail

SyntaxBuilderSemantic

public SyntaxBuilderSemantic()
Creates a syntax builder semantic that resolves parenthesis and quantifiers.


SyntaxBuilderSemantic

public SyntaxBuilderSemantic(java.util.List initialNonterminals)
Creates a syntax builder semantic that resolves parenthesis and quantifiers. All nonterminals read from the processed syntax will be collected into the passed List.

Method Detail

doSemantic

public java.lang.Object doSemantic(Rule rule,
                                   java.util.List inputTokens,
                                   java.util.List ranges)
Description copied from interface: Semantic
Called by every REDUCE step. Passes the evaluated Rule and the corresponding parsing results.

Specified by:
doSemantic in interface Semantic
Parameters:
rule - Rule that was "reduced" (recognized).
inputTokens - all semantic call returns from underlying rules, collected according to current rule, that means you get a List of Objects as long as the count of symbols on the right side of the rule, every Object is a return of an underlying doSemantic() call.
ranges - all line ranges for parseResults elements. Cast elements to Token.Range to get the start and end position of every Object in parseResult List.
Returns:
some result to be pushed on value stack by the Parser, or null.