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.

파일 보기 프로젝트 열기: WolfgangSt/axiom

보호된 프로퍼티들

프로퍼티 타입 설명
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