C# Класс Axiom.RenderSystems.OpenGL.ATI.Compiler2Pass

Compiler2Pass is a generic compiler/assembler.
Provides a tokenizer in pass 1 and relies on the subclass to provide the virtual method for pass 2 PASS 1 - tokenize source: this is a simple brute force lexical scanner/analyzer that also parses the formed token for proper semantics and context in one pass it uses Look Ahead Left-Right (LALR) ruling based on Backus - Naur From notation for semantic checking and also performs context checking allowing for language dialects. PASS 2 - generate application specific instructions ie native instructions

This class must be subclassed with the subclass providing implementation for Pass 2. The subclass is responsible for setting up the token libraries along with defining the language syntax.

Показать файл Открыть проект

Защищенные свойства (Protected)

Свойство Тип Описание
activeContexts uint
charPos int
constants Axiom.Core.FloatList
currentLine int
endOfSource int
rootRulePath Axiom.RenderSystems.OpenGL.ATI.TokenRule[]
rulePathLibCount int
source string
symbolTypeLib Axiom.RenderSystems.OpenGL.ATI.SymbolDef[]
symbolTypeLibCount int
tokenInstructions Axiom.RenderSystems.OpenGL.ATI.TokenInstructionList
valueID Symbol

Открытые методы

Метод Описание
Compile ( string source ) : bool

Compile the source - performs 2 passes: First pass is to tokinize, check semantics and context. Second pass is performed by subclass and converts tokens to application specific instructions.

Compiler2Pass ( ) : System

Default constructor.

Защищенные методы

Метод Описание
DoPass1 ( ) : bool

perform pass 1 of compile process

Scans source for symbols that can be tokenized and then performs general semantic and context verification on each symbol before it is tokenized. A tokenized instruction list is built to be used by Pass 2.

DoPass2 ( ) : bool

Abstract method that must be set up by subclass to perform Pass 2 of compile process

FindEndOfLine ( ) : void
GetTypeDefText ( Symbol symbol ) : string

Get the text symbol for this token.

Mainly used for debugging and in test routines.

InitSymbolTypeLib ( ) : void

Initialize the type library with matching symbol text found in symbol text library. Find a default text for all Symbol Types in library. Scan through all the rules and initialize TypeLib with index to text and index to rules for non-terminal tokens. Must be called by subclass after libraries and rule database setup.

IsFloatValue ( float &val, int &length ) : bool

Check to see if the text at the present position in the source is a numerical constant.

IsSymbol ( string symbol, int &symbolSize ) : bool

Check to see if the text is in the symbol text library.

PositionToNextSymbol ( ) : bool

Position to the next possible valid symbol.

ProcessRulePath ( int rulePathIdx ) : bool

Process input source text using rulepath to determine allowed tokens.

The method is reentrant and recursive. if a non-terminal token is encountered in the current rule path then the method is called using the new rule path referenced by the non-terminal token Tokens can have the following operation states which effects the flow path of the rule Rule: defines a rule path for the non-terminal token. And: the token is required for the rule to pass. Or: if the previous tokens failed then try these ones. Optional: the token is optional and does not cause the rule to fail if the token is not found. Repeat: the token is required but there can be more than one in a sequence. End: end of the rule path - the method returns the success of the rule.

SetActiveContexts ( uint contexts ) : void

Setup ActiveContexts - should be called by subclass to setup initial language contexts.

SkipComments ( ) : void

Skips all comment specifiers.

SkipEndOfLine ( ) : void

Find the end of line marker and move past it.

SkipWhitespace ( ) : void

Skip all the whitespace which includes spaces and tabs.

ValidateToken ( int rulePathIdx, Symbol activeRuleID ) : bool

Check if current position in source has the symbol text equivalent to the TokenID.

Описание методов

Compile() публичный Метод

Compile the source - performs 2 passes: First pass is to tokinize, check semantics and context. Second pass is performed by subclass and converts tokens to application specific instructions.
public Compile ( string source ) : bool
source string Source to be compiled.
Результат bool

Compiler2Pass() публичный Метод

Default constructor.
public Compiler2Pass ( ) : System
Результат System

DoPass1() защищенный Метод

perform pass 1 of compile process
Scans source for symbols that can be tokenized and then performs general semantic and context verification on each symbol before it is tokenized. A tokenized instruction list is built to be used by Pass 2.
protected DoPass1 ( ) : bool
Результат bool

DoPass2() защищенный абстрактный Метод

Abstract method that must be set up by subclass to perform Pass 2 of compile process
protected abstract DoPass2 ( ) : bool
Результат bool

FindEndOfLine() защищенный Метод

protected FindEndOfLine ( ) : void
Результат void

GetTypeDefText() защищенный Метод

Get the text symbol for this token.
Mainly used for debugging and in test routines.
protected GetTypeDefText ( Symbol symbol ) : string
symbol Symbol Token ID.
Результат string

InitSymbolTypeLib() защищенный Метод

Initialize the type library with matching symbol text found in symbol text library. Find a default text for all Symbol Types in library. Scan through all the rules and initialize TypeLib with index to text and index to rules for non-terminal tokens. Must be called by subclass after libraries and rule database setup.
protected InitSymbolTypeLib ( ) : void
Результат void

IsFloatValue() защищенный Метод

Check to see if the text at the present position in the source is a numerical constant.
protected IsFloatValue ( float &val, int &length ) : bool
val float Receives the float value that is in the source.
length int Receives number of characters that make of the value in the source.
Результат bool

IsSymbol() защищенный Метод

Check to see if the text is in the symbol text library.
protected IsSymbol ( string symbol, int &symbolSize ) : bool
symbol string
symbolSize int
Результат bool

PositionToNextSymbol() защищенный Метод

Position to the next possible valid symbol.
protected PositionToNextSymbol ( ) : bool
Результат bool

ProcessRulePath() защищенный Метод

Process input source text using rulepath to determine allowed tokens.
The method is reentrant and recursive. if a non-terminal token is encountered in the current rule path then the method is called using the new rule path referenced by the non-terminal token Tokens can have the following operation states which effects the flow path of the rule Rule: defines a rule path for the non-terminal token. And: the token is required for the rule to pass. Or: if the previous tokens failed then try these ones. Optional: the token is optional and does not cause the rule to fail if the token is not found. Repeat: the token is required but there can be more than one in a sequence. End: end of the rule path - the method returns the success of the rule.
protected ProcessRulePath ( int rulePathIdx ) : bool
rulePathIdx int Index into to array of Token Rules that define a rule path to be processed.
Результат bool

SetActiveContexts() защищенный Метод

Setup ActiveContexts - should be called by subclass to setup initial language contexts.
protected SetActiveContexts ( uint contexts ) : void
contexts uint
Результат void

SkipComments() защищенный Метод

Skips all comment specifiers.
protected SkipComments ( ) : void
Результат void

SkipEndOfLine() защищенный Метод

Find the end of line marker and move past it.
protected SkipEndOfLine ( ) : void
Результат void

SkipWhitespace() защищенный Метод

Skip all the whitespace which includes spaces and tabs.
protected SkipWhitespace ( ) : void
Результат void

ValidateToken() защищенный Метод

Check if current position in source has the symbol text equivalent to the TokenID.
protected ValidateToken ( int rulePathIdx, Symbol activeRuleID ) : bool
rulePathIdx int Index into rule path database of token to validate.
activeRuleID Symbol Index of non-terminal rule that generated the token.
Результат bool

Описание свойств

activeContexts защищенное свойство

Active Contexts pattern used in pass 1 to determine which tokens are valid for a certain context.
protected uint activeContexts
Результат uint

charPos защищенное свойство

Current position in the source string.
protected int charPos
Результат int

constants защищенное свойство

Storage container for constants defined in source.
protected FloatList,Axiom.Core constants
Результат Axiom.Core.FloatList

currentLine защищенное свойство

Current line in the source string.
protected int currentLine
Результат int

endOfSource защищенное свойство

protected int endOfSource
Результат int

rootRulePath защищенное свойство

Reference to the root rule path - has to be set by subclass constructor.
protected TokenRule[],Axiom.RenderSystems.OpenGL.ATI rootRulePath
Результат Axiom.RenderSystems.OpenGL.ATI.TokenRule[]

rulePathLibCount защищенное свойство

protected int rulePathLibCount
Результат int

source защищенное свойство

Source to be compiled.
protected string source
Результат string

symbolTypeLib защищенное свойство

Reference to the Text and Token type libraries set up by subclass.
protected SymbolDef[],Axiom.RenderSystems.OpenGL.ATI symbolTypeLib
Результат Axiom.RenderSystems.OpenGL.ATI.SymbolDef[]

symbolTypeLibCount защищенное свойство

protected int symbolTypeLibCount
Результат int

tokenInstructions защищенное свойство

Container for tokens extracted from source.
protected TokenInstructionList,Axiom.RenderSystems.OpenGL.ATI tokenInstructions
Результат Axiom.RenderSystems.OpenGL.ATI.TokenInstructionList

valueID защищенное свойство

Needs to be initialized by the subclass before compiling occurs it defines the token ID used in the symbol type library.
protected Symbol valueID
Результат Symbol