|
ScriptStack 1.0.5
|
The parser builds an ScriptStack.Runtime.Executable out of the Token stream returned from the ScriptStack.Compiler.Lexer while checking for correct syntax. More...
Classes | |
| struct | Variable |
| struct | FunctionDescriptor |
| struct | LoopControl |
| class | AccessSegment |
Public Member Functions | |
| string | ToLiteral (string input) |
| Parser (Script script, List< Token > tokenStream) | |
| Executable | Parse () |
| Parse the token stream into an executable. | |
Private Member Functions | |
| bool | More () |
| Check if there are more tokens available. | |
| Token | ReadToken () |
| Get the next available token. | |
| Token | LookAhead () |
| Get the next available token without actually increasing the tokenstream index. | |
| Token | LookAhead (int i) |
| Get the token 'n' steps forward without actually increasing the tokenstream index. | |
| void | UndoToken () |
| If you read a token wrong, push it back so the stream stays intact. | |
| bool | AssignmentOperator (TokenType tokenType) |
| OpCode | AssignmentOpcode (TokenType tokenType) |
| bool | RelationalOperator (TokenType tokenType) |
| OpCode | RelationalOpcode (TokenType tokenType) |
| Type | Literal (TokenType tokenType) |
| Get the literal type of a token. | |
| Type | Derivate (Token token, Type first, Type second) |
| Get the resulting type of two computed types. | |
| void | AllocateVariable (string identifier) |
| Allocate a local variable. | |
| void | AllocateFunctionFrame () |
| Increase the function frame index. | |
| string | AllocateTemporaryVariable () |
| Add a temporary variable to the current function frames local memory. | |
| void | FreeFunctionFrame () |
| Decrease the function frame index. | |
| void | ReadSemicolon () |
| void | ReadComma () |
| void | ReadLeftParenthesis () |
| void | ReadRightParenthesis () |
| void | ReadLeftBrace () |
| void | ReadRightBrace () |
| void | ReadLeftBracket () |
| void | ReadRightBracket () |
| void | ReadPeriod () |
| void | InsertDebugInfo (Token token) |
| string | ReadIdentifier () |
| Read a new (previously NOT declared) identifier. | |
| string | ReadQualifiedIdentifier () |
Read a dotted (qualified) identifier like: std.print or ns.io.print. | |
| string | ExpectIdentifier () |
| Read an expected (previously declared) identifier. | |
| void | VariableDeclaration () |
| Shared or local variable declaration. | |
| void | LocalVariableDeclaration () |
| void | Run () |
| Variable | RoutineCall () |
| Variable | Pointer () |
| Array access. | |
| Variable | Member () |
| Member access. | |
| Variable | AccessChain () |
| Mixed access chain parser. | |
| Variable | PreIncrement () |
| Variable | PreDecrement () |
| Variable | PostIncrement () |
| Variable | PostDecrement () |
| Variable | ShiftLeft () |
| Variable | ShiftRight () |
| Variable | BinaryAnd () |
| Variable | BinaryOr () |
| Variable | BinaryNotAssign () |
| Variable | BinaryNot () |
| Variable | Xor () |
| Variable | Atom () |
| The smallest unit. | |
| Variable | BraceArray () |
| An array enclosed in braces. | |
| Variable | BracketArray () |
| An array enclosed in brackets. | |
| Variable | Factor () |
| Atom | Array. | |
| Variable | Term () |
| Factor ( [*|/|%] Factor ). | |
| Variable | Arithmetic () |
| Multiplication and division before Addition and substraction. | |
| Variable | Relation () |
| Variable | Not () |
| Proposition. | |
| Variable | BitwiseAnd () |
| Bitwise AND '&'. | |
| Variable | BitwiseXor () |
| Bitwise XOR '^'. | |
| Variable | BitwiseOr () |
| Bitwise OR '|'. | |
| Variable | And () |
| Conjunction. | |
| Variable | Or () |
| Disjunction (not exclusive). | |
| Variable | VariableAssignment () |
| Variable | AccessChainAssignment () |
| Mixed access chain assignment. | |
| Variable | ArrayAssignment () |
| Variable | MemberAssignment () |
| Variable | Assignment () |
| An assignment can be a variable assignment, an array assignment or a member assignment. | |
| bool | IsAccessChainAssignment () |
| Detect whether the upcoming tokens form an assignment expression. | |
| bool | IsPointer () |
| bool | IsMember () |
| Variable | Expression () |
| An expression is an assignment or a disjunction. | |
| void | If () |
| void | While () |
| void | For () |
| void | ForEach () |
| void | Break () |
| void | Continue () |
| void | Switch () |
| void | Return () |
| By default null is returned. | |
| void | FunctionDeclaration () |
| Parameter variables are already set to true but not assigned yet. Pop all of them in reverse order onto the stack. | |
| Variable | FunctionCall (bool background) |
| Call a forward declared function Push all parameter identifier onto the stack and call the function/routine Only functions can run in background because routines are not translated! | |
| Variable | FunctionCall () |
| Can be a call to a forward declared Function or a Routine. To check what it is we look if it is a registered routine, if not it must be a function. | |
| void | Statement () |
| A statement can be a local variable declaration, a statement list, an expression or a keyword. | |
| void | StatementList () |
| A list of statements. If its not a list (not in braces) just return a single statement. | |
| void | LockedStatementList () |
| void | Yield () |
| void | Wait () |
| Wait for a locked secion of code to be freed. | |
| void | Notify () |
| void | ParseScript () |
| After the first function declaration no more variable, struct or enum declarations are allowed anymore. | |
| void | ResolveForwardFunctionDeclarations () |
| Resolve unresolved, forward declared functions. | |
Private Attributes | |
| Script | script |
| bool | debugMode |
| List< Token > | tokenStream |
| int | nextToken |
| Dictionary< string, bool > | variables |
| Dictionary< string, bool > | localVariables |
| int | functionFrameIndex |
| Dictionary< Instruction, FunctionDescriptor > | forwardDeclarations |
| Stack< LoopControl > | loopControl |
| Derivation | derivation |
| Executable | executable |
The parser builds an ScriptStack.Runtime.Executable out of the Token stream returned from the ScriptStack.Compiler.Lexer while checking for correct syntax.
The parser takes the output from the Lexer in the form of a Token stream and matches it against syntax rules to detect any errors. The output is an abstract syntax tree in form of Instruction's which can be executed by the ScriptStack.Runtime.Interpreter. More details are coming soon.
Not all methods are well documented yet but please be patient - i am working on it.
Definition at line 3336 of file Parser.cs.
References debugMode, derivation, executable, forwardDeclarations, functionFrameIndex, localVariables, loopControl, nextToken, script, tokenStream, and variables.
|
private |
Mixed access chain parser.
Supports combinations of member and index access in arbitrary order, e.g.
The implementation lowers each postfix operation into a MOV into a temporary variable, so the runtime only needs to support OperandType.Member and OperandType.Pointer.
Definition at line 841 of file Parser.cs.
References AllocateTemporaryVariable(), ScriptStack.Runtime.Operand.CreatePointer(), executable, Expression(), ScriptStack.Runtime.Operand.Literal(), LookAhead(), ScriptStack.Runtime.Operand.MemberVariable(), ScriptStack.Compiler.Parser.Variable.name, ReadComma(), ReadIdentifier(), ReadLeftBracket(), ReadLeftParenthesis(), ReadPeriod(), ReadRightBracket(), ReadRightParenthesis(), ScriptStack.Runtime.Operand.Variable(), and ScriptStack.Runtime.Variable.
Referenced by Atom().
|
private |
Mixed access chain assignment.
Supports combinations of member and index access in arbitrary order on the LHS, e.g.
The chain is lowered into temporary MOVs for intermediate steps; the last step becomes the actual assignment target (Variable/Member/Pointer).
Definition at line 2022 of file Parser.cs.
References AllocateTemporaryVariable(), AssignmentOpcode(), AssignmentOperator(), ScriptStack.Runtime.Operand.CreatePointer(), ScriptStack.Compiler.Parser.Variable.derivatedType, executable, ExpectIdentifier(), Expression(), ScriptStack.Compiler.Parser.AccessSegment.Index(), LookAhead(), ScriptStack.Compiler.Parser.AccessSegment.Member(), ScriptStack.Runtime.Operand.MemberVariable(), ScriptStack.Compiler.Parser.Variable.name, ReadIdentifier(), ReadLeftBracket(), ReadPeriod(), ReadRightBracket(), ReadToken(), ScriptStack.Compiler.Token.Type, ScriptStack.Runtime.Operand.Variable(), and ScriptStack.Runtime.Variable.
Referenced by Assignment().
|
private |
Increase the function frame index.
Definition at line 321 of file Parser.cs.
References functionFrameIndex.
Referenced by Statement().
|
private |
Add a temporary variable to the current function frames local memory.
Definition at line 333 of file Parser.cs.
References functionFrameIndex, localVariables, and variables.
Referenced by AccessChain(), AccessChainAssignment(), ArrayAssignment(), Atom(), BraceArray(), BracketArray(), Factor(), For(), ForEach(), FunctionCall(), Member(), MemberAssignment(), Pointer(), PostDecrement(), PostIncrement(), RoutineCall(), Switch(), and VariableAssignment().
|
private |
Allocate a local variable.
| identifier |
Definition at line 303 of file Parser.cs.
References executable, localVariables, ScriptStack.Runtime.Operand.Variable(), and variables.
Referenced by FunctionDeclaration(), and LocalVariableDeclaration().
|
private |
Conjunction.
Check for proposition (a signed atom)
Definition at line 1901 of file Parser.cs.
References BitwiseOr(), Derivate(), ScriptStack.Compiler.Parser.Variable.derivatedType, executable, ScriptStack.Compiler.Parser.Variable.name, ReadToken(), ScriptStack.Compiler.Token.Type, UndoToken(), and ScriptStack.Runtime.Operand.Variable().
Referenced by Or().
|
private |
Multiplication and division before Addition and substraction.
Refer to https://en.wikipedia.org/wiki/Order_of_operations
Definition at line 1669 of file Parser.cs.
References Derivate(), ScriptStack.Compiler.Parser.Variable.derivatedType, executable, ScriptStack.Compiler.Parser.Variable.name, ReadToken(), Term(), ScriptStack.Compiler.Token.Type, UndoToken(), ScriptStack.Runtime.Operand.Variable(), and ScriptStack.Runtime.Variable.
Referenced by Relation().
|
private |
Definition at line 2105 of file Parser.cs.
References AllocateTemporaryVariable(), AssignmentOpcode(), AssignmentOperator(), ScriptStack.Runtime.Operand.CreatePointer(), ScriptStack.Compiler.Parser.Variable.derivatedType, executable, ExpectIdentifier(), Expression(), LookAhead(), ScriptStack.Compiler.Parser.Variable.name, ReadLeftBracket(), ReadRightBracket(), ReadToken(), ScriptStack.Compiler.Token.Type, ScriptStack.Runtime.Operand.Variable(), and ScriptStack.Runtime.Variable.
|
private |
An assignment can be a variable assignment, an array assignment or a member assignment.
Definition at line 2218 of file Parser.cs.
References AccessChainAssignment().
Referenced by Expression(), For(), and LocalVariableDeclaration().
| tokenType |
Definition at line 179 of file Parser.cs.
Referenced by AccessChainAssignment(), ArrayAssignment(), MemberAssignment(), and VariableAssignment().
|
private |
| tokenType |
Definition at line 149 of file Parser.cs.
Referenced by AccessChainAssignment(), ArrayAssignment(), IsAccessChainAssignment(), IsMember(), IsPointer(), MemberAssignment(), and VariableAssignment().
|
private |
The smallest unit.
Definition at line 1222 of file Parser.cs.
References AccessChain(), AllocateTemporaryVariable(), Atom(), executable, ExpectIdentifier(), Expression(), FunctionCall(), ScriptStack.Compiler.Token.Lexeme, Literal(), ScriptStack.Runtime.Operand.Literal(), LookAhead(), ScriptStack.Compiler.Parser.Variable.name, nextToken, PostDecrement(), PostIncrement(), PreDecrement(), PreIncrement(), ReadRightParenthesis(), ReadToken(), ShiftLeft(), ShiftRight(), tokenStream, ScriptStack.Compiler.Token.Type, UndoToken(), ScriptStack.Runtime.Operand.Variable(), and ScriptStack.Runtime.Variable.
|
private |
Definition at line 1078 of file Parser.cs.
References executable, ExpectIdentifier(), Factor(), ScriptStack.Compiler.Parser.Variable.name, ReadToken(), ScriptStack.Compiler.Token.Type, and ScriptStack.Runtime.Operand.Variable().
|
private |
Definition at line 1144 of file Parser.cs.
References executable, Factor(), ScriptStack.Compiler.Parser.Variable.name, ReadToken(), ScriptStack.Compiler.Token.Type, and ScriptStack.Runtime.Operand.Variable().
|
private |
Definition at line 1122 of file Parser.cs.
References executable, ExpectIdentifier(), Factor(), ScriptStack.Compiler.Parser.Variable.name, ReadToken(), ScriptStack.Compiler.Token.Type, and ScriptStack.Runtime.Operand.Variable().
|
private |
Definition at line 1100 of file Parser.cs.
References executable, ExpectIdentifier(), Factor(), ScriptStack.Compiler.Parser.Variable.name, ReadToken(), ScriptStack.Compiler.Token.Type, and ScriptStack.Runtime.Operand.Variable().
|
private |
Bitwise AND '&'.
Precedence (high -> low): ! (logical NOT) & ^ | && ||
This mirrors common C-like precedence and keeps bitwise ops above logical ops.
Definition at line 1792 of file Parser.cs.
References executable, ScriptStack.Compiler.Parser.Variable.name, Not(), ReadToken(), ScriptStack.Compiler.Token.Type, UndoToken(), and ScriptStack.Runtime.Operand.Variable().
Referenced by BitwiseXor().
|
private |
Bitwise OR '|'.
Definition at line 1863 of file Parser.cs.
References BitwiseXor(), executable, ScriptStack.Compiler.Parser.Variable.name, ReadToken(), ScriptStack.Compiler.Token.Type, UndoToken(), and ScriptStack.Runtime.Operand.Variable().
Referenced by And().
|
private |
Bitwise XOR '^'.
Definition at line 1828 of file Parser.cs.
References BitwiseAnd(), executable, ScriptStack.Compiler.Parser.Variable.name, ReadToken(), ScriptStack.Compiler.Token.Type, UndoToken(), and ScriptStack.Runtime.Operand.Variable().
Referenced by BitwiseOr().
|
private |
An array enclosed in braces.
Definition at line 1414 of file Parser.cs.
References AllocateTemporaryVariable(), ScriptStack.Runtime.Operand.CreatePointer(), executable, Expression(), LookAhead(), ScriptStack.Runtime.Operand.MemberVariable(), ScriptStack.Compiler.Parser.Variable.name, ReadComma(), ReadLeftBrace(), ReadRightBrace(), ReadSemicolon(), ReadToken(), ScriptStack.Compiler.Token.Type, ScriptStack.Runtime.Operand.Variable(), and ScriptStack.Runtime.Variable.
Referenced by Factor().
|
private |
An array enclosed in brackets.
Definition at line 1494 of file Parser.cs.
References AllocateTemporaryVariable(), ScriptStack.Runtime.Operand.CreatePointer(), executable, Expression(), LookAhead(), ScriptStack.Runtime.Operand.MemberVariable(), ScriptStack.Compiler.Parser.Variable.name, ReadComma(), ReadLeftBracket(), ReadRightBracket(), ReadToken(), ScriptStack.Compiler.Token.Type, ScriptStack.Runtime.Operand.Variable(), and ScriptStack.Runtime.Variable.
Referenced by Factor().
|
private |
Definition at line 2664 of file Parser.cs.
References ScriptStack.Runtime.Operand.AllocateInstructionPointer(), executable, loopControl, ReadSemicolon(), ReadToken(), and ScriptStack.Compiler.Token.Type.
Referenced by Statement().
|
private |
Definition at line 2686 of file Parser.cs.
References ScriptStack.Runtime.Operand.AllocateInstructionPointer(), executable, loopControl, ReadSemicolon(), ReadToken(), and ScriptStack.Compiler.Token.Type.
Referenced by Statement().
|
private |
Get the resulting type of two computed types.
| token | |
| first | |
| second |
Definition at line 292 of file Parser.cs.
References derivation.
Referenced by And(), Arithmetic(), Or(), Relation(), and Term().
|
private |
Read an expected (previously declared) identifier.
Definition at line 555 of file Parser.cs.
References ScriptStack.Compiler.Token.Lexeme, localVariables, ReadToken(), ScriptStack.Compiler.Token.Type, and variables.
Referenced by AccessChainAssignment(), ArrayAssignment(), Atom(), BinaryAnd(), BinaryNotAssign(), BinaryOr(), ForEach(), MemberAssignment(), Notify(), PostDecrement(), PostIncrement(), PreDecrement(), PreIncrement(), ShiftLeft(), ShiftRight(), Switch(), VariableAssignment(), Wait(), and Xor().
|
private |
An expression is an assignment or a disjunction.
Definition at line 2371 of file Parser.cs.
References Assignment(), IsAccessChainAssignment(), and Or().
Referenced by AccessChain(), AccessChainAssignment(), ArrayAssignment(), Atom(), BraceArray(), BracketArray(), For(), ForEach(), FunctionCall(), If(), IsAccessChainAssignment(), IsPointer(), LockedStatementList(), MemberAssignment(), Not(), Pointer(), Return(), RoutineCall(), Statement(), Switch(), VariableAssignment(), and While().
|
private |
Atom | Array.
Definition at line 1564 of file Parser.cs.
References AllocateTemporaryVariable(), Atom(), BraceArray(), BracketArray(), executable, Factor(), LookAhead(), ScriptStack.Compiler.Parser.Variable.name, ReadToken(), ScriptStack.Runtime.Operand.Variable(), and ScriptStack.Runtime.Variable.
Referenced by BinaryAnd(), BinaryNot(), BinaryNotAssign(), BinaryOr(), Factor(), ShiftLeft(), ShiftRight(), Term(), and Xor().
|
private |
Definition at line 2472 of file Parser.cs.
References ScriptStack.Runtime.Operand.AllocateInstructionPointer(), AllocateTemporaryVariable(), Assignment(), ScriptStack.Compiler.Parser.Variable.derivatedType, executable, Expression(), ScriptStack.Runtime.Operand.Literal(), LocalVariableDeclaration(), LookAhead(), loopControl, ScriptStack.Compiler.Parser.Variable.name, ReadLeftParenthesis(), ReadRightParenthesis(), ReadSemicolon(), ReadToken(), StatementList(), ScriptStack.Compiler.Token.Type, ScriptStack.Runtime.Operand.Variable(), and ScriptStack.Runtime.Variable.
Referenced by Statement().
|
private |
Definition at line 2579 of file Parser.cs.
References ScriptStack.Runtime.Operand.AllocateInstructionPointer(), AllocateTemporaryVariable(), ScriptStack.Runtime.Operand.CreatePointer(), ScriptStack.Compiler.Parser.Variable.derivatedType, executable, ExpectIdentifier(), Expression(), ScriptStack.Runtime.Operand.Literal(), loopControl, ScriptStack.Compiler.Parser.Variable.name, ReadLeftParenthesis(), ReadRightParenthesis(), ReadToken(), StatementList(), ScriptStack.Compiler.Token.Type, and ScriptStack.Runtime.Operand.Variable().
Referenced by Statement().
|
private |
Decrease the function frame index.
Definition at line 361 of file Parser.cs.
References functionFrameIndex, and localVariables.
Referenced by Statement().
|
private |
Can be a call to a forward declared Function or a Routine. To check what it is we look if it is a registered routine, if not it must be a function.
Definition at line 3034 of file Parser.cs.
References executable, FunctionCall(), nextToken, ReadQualifiedIdentifier(), and RoutineCall().
Referenced by Atom(), FunctionCall(), and Run().
|
private |
Call a forward declared function Push all parameter identifier onto the stack and call the function/routine Only functions can run in background because routines are not translated!
| background |
Definition at line 2922 of file Parser.cs.
References ScriptStack.Runtime.Operand.AllocateFunctionPointer(), AllocateTemporaryVariable(), executable, Expression(), forwardDeclarations, LookAhead(), ScriptStack.Compiler.Parser.Variable.name, ReadComma(), ReadLeftParenthesis(), ReadQualifiedIdentifier(), ReadRightParenthesis(), ScriptStack.Runtime.Operand.Variable(), and ScriptStack.Runtime.Variable.
|
private |
Parameter variables are already set to true but not assigned yet. Pop all of them in reverse order onto the stack.
Definition at line 2832 of file Parser.cs.
References AllocateVariable(), executable, ScriptStack.Compiler.Function, InsertDebugInfo(), ScriptStack.Compiler.Token.Lexeme, ScriptStack.Runtime.Operand.Literal(), localVariables, LookAhead(), ReadComma(), ReadIdentifier(), ReadLeftParenthesis(), ReadRightParenthesis(), ReadToken(), StatementList(), ScriptStack.Compiler.Token.Type, and ScriptStack.Runtime.Operand.Variable().
Referenced by ParseScript().
|
private |
Definition at line 2385 of file Parser.cs.
References ScriptStack.Runtime.Operand.AllocateInstructionPointer(), executable, Expression(), LookAhead(), ScriptStack.Compiler.Parser.Variable.name, ReadLeftParenthesis(), ReadRightParenthesis(), ReadToken(), StatementList(), ScriptStack.Compiler.Token.Type, and ScriptStack.Runtime.Operand.Variable().
Referenced by Statement().
|
private |
Definition at line 497 of file Parser.cs.
References debugMode, executable, ScriptStack.Compiler.Token.Line, ScriptStack.Runtime.Operand.Literal(), and ScriptStack.Compiler.Token.Text.
Referenced by FunctionDeclaration(), Statement(), Switch(), and VariableDeclaration().
|
private |
Detect whether the upcoming tokens form an assignment expression.
Supports mixed access chains on the LHS ('.' and '[]' in arbitrary order).
Definition at line 2229 of file Parser.cs.
References AssignmentOperator(), executable, Expression(), LookAhead(), ReadIdentifier(), ReadLeftBracket(), ReadPeriod(), ReadRightBracket(), ReadToken(), ScriptStack.Compiler.Token.Type, and UndoToken().
Referenced by Expression().
|
private |
Definition at line 2329 of file Parser.cs.
References AssignmentOperator(), LookAhead(), ReadIdentifier(), ReadPeriod(), ReadToken(), ScriptStack.Compiler.Token.Type, and UndoToken().
|
private |
Definition at line 2293 of file Parser.cs.
References AssignmentOperator(), executable, Expression(), LookAhead(), ReadIdentifier(), ReadLeftBracket(), ReadRightBracket(), ReadToken(), ScriptStack.Compiler.Token.Type, and UndoToken().
|
private |
Get the literal type of a token.
| tokenType |
Definition at line 258 of file Parser.cs.
Referenced by Atom().
|
private |
Definition at line 625 of file Parser.cs.
References AllocateVariable(), Assignment(), ReadIdentifier(), ReadToken(), ScriptStack.Compiler.Token.Type, and UndoToken().
Referenced by For(), and Statement().
|
private |
Definition at line 3172 of file Parser.cs.
References executable, Expression(), ScriptStack.Compiler.Parser.Variable.name, ReadToken(), Statement(), ScriptStack.Compiler.Token.Type, and ScriptStack.Runtime.Operand.Variable().
Referenced by Statement().
|
private |
Get the next available token without actually increasing the tokenstream index.
Definition at line 106 of file Parser.cs.
References More(), nextToken, and tokenStream.
Referenced by AccessChain(), AccessChainAssignment(), ArrayAssignment(), Atom(), BraceArray(), BracketArray(), Factor(), For(), FunctionCall(), FunctionDeclaration(), If(), IsAccessChainAssignment(), IsMember(), IsPointer(), Member(), MemberAssignment(), Not(), ParseScript(), Pointer(), ReadQualifiedIdentifier(), Return(), RoutineCall(), Statement(), StatementList(), and Switch().
|
private |
Get the token 'n' steps forward without actually increasing the tokenstream index.
| i |
Definition at line 121 of file Parser.cs.
References More(), nextToken, and tokenStream.
|
private |
Member access.
Definition at line 800 of file Parser.cs.
References AllocateTemporaryVariable(), executable, LookAhead(), ScriptStack.Runtime.Operand.MemberVariable(), ReadIdentifier(), ReadPeriod(), ScriptStack.Runtime.Operand.Variable(), and ScriptStack.Runtime.Variable.
|
private |
Definition at line 2161 of file Parser.cs.
References AllocateTemporaryVariable(), AssignmentOpcode(), AssignmentOperator(), ScriptStack.Compiler.Parser.Variable.derivatedType, executable, ExpectIdentifier(), Expression(), LookAhead(), ScriptStack.Runtime.Operand.MemberVariable(), ScriptStack.Compiler.Parser.Variable.name, ReadIdentifier(), ReadPeriod(), ReadToken(), ScriptStack.Compiler.Token.Type, ScriptStack.Runtime.Operand.Variable(), and ScriptStack.Runtime.Variable.
|
private |
Check if there are more tokens available.
Definition at line 83 of file Parser.cs.
References nextToken, and tokenStream.
Referenced by LookAhead(), LookAhead(), ParseScript(), ReadQualifiedIdentifier(), and ReadToken().
|
private |
Proposition.
May be a signed atom or a relation
Definition at line 1752 of file Parser.cs.
References executable, Expression(), LookAhead(), ScriptStack.Compiler.Parser.Variable.name, ReadToken(), Relation(), ScriptStack.Runtime.Operand.Variable(), and ScriptStack.Runtime.Variable.
Referenced by BitwiseAnd().
|
private |
Definition at line 3244 of file Parser.cs.
References executable, ExpectIdentifier(), ScriptStack.Runtime.Operand.Literal(), ReadSemicolon(), ReadToken(), ScriptStack.Compiler.Token.Type, and ScriptStack.Runtime.Operand.Variable().
Referenced by Statement().
|
private |
Disjunction (not exclusive).
Check for conjunction
Definition at line 1939 of file Parser.cs.
References And(), Derivate(), ScriptStack.Compiler.Parser.Variable.derivatedType, executable, ScriptStack.Compiler.Parser.Variable.name, ReadToken(), ScriptStack.Compiler.Token.Type, UndoToken(), and ScriptStack.Runtime.Operand.Variable().
Referenced by Expression().
| Executable ScriptStack.Compiler.Parser.Parse | ( | ) |
Parse the token stream into an executable.
Definition at line 3355 of file Parser.cs.
References executable, forwardDeclarations, functionFrameIndex, localVariables, loopControl, nextToken, ParseScript(), ResolveForwardFunctionDeclarations(), script, and variables.
Referenced by ScriptStack.Runtime.Script.Script(), and ScriptStack.Runtime.Script.Script().
|
private |
After the first function declaration no more variable, struct or enum declarations are allowed anymore.
Definition at line 3265 of file Parser.cs.
References FunctionDeclaration(), LookAhead(), More(), ScriptStack.Compiler.Token.Type, and VariableDeclaration().
Referenced by Parse().
|
private |
Array access.
like
Definition at line 768 of file Parser.cs.
References AllocateTemporaryVariable(), ScriptStack.Runtime.Operand.CreatePointer(), executable, Expression(), LookAhead(), ScriptStack.Compiler.Parser.Variable.name, ReadIdentifier(), ReadLeftBracket(), ReadRightBracket(), ScriptStack.Runtime.Operand.Variable(), and ScriptStack.Runtime.Variable.
|
private |
Definition at line 1010 of file Parser.cs.
References AllocateTemporaryVariable(), executable, ExpectIdentifier(), ReadToken(), ScriptStack.Compiler.Token.Type, ScriptStack.Runtime.Operand.Variable(), and ScriptStack.Runtime.Variable.
Referenced by Atom().
|
private |
Definition at line 986 of file Parser.cs.
References AllocateTemporaryVariable(), executable, ExpectIdentifier(), ReadToken(), ScriptStack.Compiler.Token.Type, ScriptStack.Runtime.Operand.Variable(), and ScriptStack.Runtime.Variable.
Referenced by Atom().
|
private |
Definition at line 966 of file Parser.cs.
References executable, ExpectIdentifier(), ReadToken(), ScriptStack.Compiler.Token.Type, ScriptStack.Runtime.Operand.Variable(), and ScriptStack.Runtime.Variable.
Referenced by Atom().
|
private |
Definition at line 946 of file Parser.cs.
References executable, ExpectIdentifier(), ReadToken(), ScriptStack.Compiler.Token.Type, ScriptStack.Runtime.Operand.Variable(), and ScriptStack.Runtime.Variable.
Referenced by Atom().
|
private |
Definition at line 396 of file Parser.cs.
References ReadToken(), and ScriptStack.Compiler.Token.Type.
Referenced by AccessChain(), BraceArray(), BracketArray(), FunctionCall(), FunctionDeclaration(), and RoutineCall().
|
private |
Read a new (previously NOT declared) identifier.
Definition at line 515 of file Parser.cs.
References ScriptStack.Compiler.Token.Lexeme, ReadToken(), and ScriptStack.Compiler.Token.Type.
Referenced by AccessChain(), AccessChainAssignment(), FunctionDeclaration(), IsAccessChainAssignment(), IsMember(), IsPointer(), LocalVariableDeclaration(), Member(), MemberAssignment(), Pointer(), ReadQualifiedIdentifier(), and VariableDeclaration().
|
private |
Definition at line 435 of file Parser.cs.
References ReadToken(), and ScriptStack.Compiler.Token.Type.
Referenced by BraceArray(), and Switch().
|
private |
Definition at line 461 of file Parser.cs.
References ReadToken(), and ScriptStack.Compiler.Token.Type.
Referenced by AccessChain(), AccessChainAssignment(), ArrayAssignment(), BracketArray(), IsAccessChainAssignment(), IsPointer(), and Pointer().
|
private |
Definition at line 409 of file Parser.cs.
References ReadToken(), and ScriptStack.Compiler.Token.Type.
Referenced by AccessChain(), For(), ForEach(), FunctionCall(), FunctionDeclaration(), If(), RoutineCall(), Switch(), and While().
|
private |
Definition at line 487 of file Parser.cs.
References ReadToken(), and ScriptStack.Compiler.Token.Type.
Referenced by AccessChain(), AccessChainAssignment(), IsAccessChainAssignment(), IsMember(), Member(), MemberAssignment(), and ReadQualifiedIdentifier().
|
private |
Read a dotted (qualified) identifier like: std.print or ns.io.print.
This is intentionally ONLY used for function/routine names. Member access on variables is parsed by AccessChain.
Definition at line 533 of file Parser.cs.
References LookAhead(), More(), ReadIdentifier(), and ReadPeriod().
Referenced by FunctionCall(), FunctionCall(), and RoutineCall().
|
private |
Definition at line 448 of file Parser.cs.
References ReadToken(), and ScriptStack.Compiler.Token.Type.
Referenced by BraceArray(), StatementList(), and Switch().
|
private |
Definition at line 474 of file Parser.cs.
References ReadToken(), and ScriptStack.Compiler.Token.Type.
Referenced by AccessChain(), AccessChainAssignment(), ArrayAssignment(), BracketArray(), IsAccessChainAssignment(), IsPointer(), and Pointer().
|
private |
Definition at line 422 of file Parser.cs.
References ReadToken(), and ScriptStack.Compiler.Token.Type.
Referenced by AccessChain(), Atom(), For(), ForEach(), FunctionCall(), FunctionDeclaration(), If(), RoutineCall(), Switch(), and While().
|
private |
Definition at line 383 of file Parser.cs.
References ReadToken(), and ScriptStack.Compiler.Token.Type.
Referenced by BraceArray(), Break(), Continue(), For(), Notify(), Return(), Run(), Statement(), Wait(), and Yield().
|
private |
Get the next available token.
Definition at line 92 of file Parser.cs.
References More(), nextToken, and tokenStream.
Referenced by AccessChainAssignment(), And(), Arithmetic(), ArrayAssignment(), Atom(), BinaryAnd(), BinaryNot(), BinaryNotAssign(), BinaryOr(), BitwiseAnd(), BitwiseOr(), BitwiseXor(), BraceArray(), BracketArray(), Break(), Continue(), ExpectIdentifier(), Factor(), For(), ForEach(), FunctionDeclaration(), If(), IsAccessChainAssignment(), IsMember(), IsPointer(), LocalVariableDeclaration(), LockedStatementList(), MemberAssignment(), Not(), Notify(), Or(), PostDecrement(), PostIncrement(), PreDecrement(), PreIncrement(), ReadComma(), ReadIdentifier(), ReadLeftBrace(), ReadLeftBracket(), ReadLeftParenthesis(), ReadPeriod(), ReadRightBrace(), ReadRightBracket(), ReadRightParenthesis(), ReadSemicolon(), Relation(), Return(), Run(), ShiftLeft(), ShiftRight(), Statement(), StatementList(), Switch(), Term(), VariableAssignment(), VariableDeclaration(), Wait(), While(), Xor(), and Yield().
|
private |
Definition at line 1720 of file Parser.cs.
References Arithmetic(), Derivate(), ScriptStack.Compiler.Parser.Variable.derivatedType, executable, ScriptStack.Compiler.Parser.Variable.name, ReadToken(), RelationalOpcode(), RelationalOperator(), ScriptStack.Compiler.Token.Type, UndoToken(), and ScriptStack.Runtime.Operand.Variable().
Referenced by Not().
| tokenType |
Definition at line 233 of file Parser.cs.
Referenced by Relation().
|
private |
| tokenType |
Definition at line 207 of file Parser.cs.
Referenced by Relation().
|
private |
Resolve unresolved, forward declared functions.
Definition at line 3301 of file Parser.cs.
References executable, forwardDeclarations, and ScriptStack.Compiler.Parser.FunctionDescriptor.name.
Referenced by Parse().
|
private |
By default null is returned.
Definition at line 2807 of file Parser.cs.
References executable, Expression(), ScriptStack.Runtime.Operand.Literal(), LookAhead(), ReadSemicolon(), ReadToken(), ScriptStack.Compiler.Token.Type, and ScriptStack.Runtime.Operand.Variable().
Referenced by Statement().
|
private |
Definition at line 692 of file Parser.cs.
References ScriptStack.Runtime.Operand.AllocateRoutinePointer(), AllocateTemporaryVariable(), ScriptStack.Runtime.Routine.Description(), executable, Expression(), LookAhead(), ScriptStack.Compiler.Parser.Variable.name, ScriptStack.Runtime.Routine.ParameterTypes, ReadComma(), ReadLeftParenthesis(), ReadQualifiedIdentifier(), ReadRightParenthesis(), ScriptStack.Manager.Routines, and ScriptStack.Runtime.Operand.Variable().
Referenced by FunctionCall().
|
private |
Definition at line 673 of file Parser.cs.
References FunctionCall(), ReadSemicolon(), ReadToken(), and ScriptStack.Compiler.Token.Type.
Referenced by Statement().
|
private |
Definition at line 1034 of file Parser.cs.
References executable, ExpectIdentifier(), Factor(), ScriptStack.Compiler.Parser.Variable.name, ReadToken(), ScriptStack.Compiler.Token.Type, and ScriptStack.Runtime.Operand.Variable().
Referenced by Atom().
|
private |
Definition at line 1056 of file Parser.cs.
References executable, ExpectIdentifier(), Factor(), ScriptStack.Compiler.Parser.Variable.name, ReadToken(), ScriptStack.Compiler.Token.Type, and ScriptStack.Runtime.Operand.Variable().
Referenced by Atom().
|
private |
A statement can be a local variable declaration, a statement list, an expression or a keyword.
Definition at line 3055 of file Parser.cs.
References AllocateFunctionFrame(), Break(), Continue(), Expression(), For(), ForEach(), FreeFunctionFrame(), If(), InsertDebugInfo(), ScriptStack.Compiler.Token.Lexeme, LocalVariableDeclaration(), LockedStatementList(), LookAhead(), Notify(), ReadSemicolon(), ReadToken(), Return(), Run(), StatementList(), Switch(), ScriptStack.Compiler.Token.Type, Wait(), While(), and Yield().
Referenced by LockedStatementList(), StatementList(), and Switch().
|
private |
A list of statements. If its not a list (not in braces) just return a single statement.
Definition at line 3147 of file Parser.cs.
References LookAhead(), ReadRightBrace(), ReadToken(), and Statement().
Referenced by For(), ForEach(), FunctionDeclaration(), If(), Statement(), and While().
|
private |
Definition at line 2708 of file Parser.cs.
References ScriptStack.Runtime.Operand.AllocateInstructionPointer(), AllocateTemporaryVariable(), executable, ExpectIdentifier(), Expression(), InsertDebugInfo(), ScriptStack.Runtime.Operand.Literal(), LookAhead(), ScriptStack.Compiler.Parser.Variable.name, ReadLeftBrace(), ReadLeftParenthesis(), ReadRightBrace(), ReadRightParenthesis(), ReadToken(), Statement(), ScriptStack.Compiler.Token.Type, and ScriptStack.Runtime.Operand.Variable().
Referenced by Statement().
|
private |
Factor ( [*|/|%] Factor ).
Definition at line 1608 of file Parser.cs.
References Derivate(), ScriptStack.Compiler.Parser.Variable.derivatedType, executable, Factor(), ScriptStack.Compiler.Parser.Variable.name, ReadToken(), ScriptStack.Compiler.Token.Type, UndoToken(), ScriptStack.Runtime.Operand.Variable(), and ScriptStack.Runtime.Variable.
Referenced by Arithmetic().
| string ScriptStack.Compiler.Parser.ToLiteral | ( | string | input | ) |
Definition at line 1182 of file Parser.cs.
|
private |
If you read a token wrong, push it back so the stream stays intact.
Definition at line 134 of file Parser.cs.
References nextToken.
Referenced by And(), Arithmetic(), Atom(), BitwiseAnd(), BitwiseOr(), BitwiseXor(), IsAccessChainAssignment(), IsMember(), IsPointer(), LocalVariableDeclaration(), Or(), Relation(), and Term().
|
private |
Definition at line 1975 of file Parser.cs.
References AllocateTemporaryVariable(), AssignmentOpcode(), AssignmentOperator(), ScriptStack.Compiler.Parser.Variable.derivatedType, executable, ExpectIdentifier(), Expression(), ScriptStack.Compiler.Parser.Variable.name, ReadToken(), ScriptStack.Compiler.Token.Type, ScriptStack.Runtime.Operand.Variable(), and ScriptStack.Runtime.Variable.
|
private |
Shared or local variable declaration.
Definition at line 575 of file Parser.cs.
References executable, InsertDebugInfo(), ReadIdentifier(), ReadToken(), script, ScriptStack.Compiler.Token.Type, ScriptStack.Runtime.Operand.Variable(), and variables.
Referenced by ParseScript().
|
private |
Wait for a locked secion of code to be freed.
Definition at line 3212 of file Parser.cs.
References ScriptStack.Runtime.Operand.AllocateInstructionPointer(), executable, ExpectIdentifier(), ReadSemicolon(), ReadToken(), ScriptStack.Compiler.Token.Type, and ScriptStack.Runtime.Operand.Variable().
Referenced by Statement().
|
private |
Definition at line 2426 of file Parser.cs.
References ScriptStack.Runtime.Operand.AllocateInstructionPointer(), ScriptStack.Compiler.Parser.Variable.derivatedType, executable, Expression(), loopControl, ScriptStack.Compiler.Parser.Variable.name, ReadLeftParenthesis(), ReadRightParenthesis(), ReadToken(), StatementList(), ScriptStack.Compiler.Token.Type, and ScriptStack.Runtime.Operand.Variable().
Referenced by Statement().
|
private |
Definition at line 1164 of file Parser.cs.
References executable, ExpectIdentifier(), Factor(), ScriptStack.Compiler.Parser.Variable.name, ReadToken(), ScriptStack.Compiler.Token.Type, and ScriptStack.Runtime.Operand.Variable().
|
private |
Definition at line 3193 of file Parser.cs.
References executable, ReadSemicolon(), ReadToken(), and ScriptStack.Compiler.Token.Type.
Referenced by Statement().
|
private |
Definition at line 64 of file Parser.cs.
Referenced by InsertDebugInfo(), and Parser().
|
private |
Definition at line 72 of file Parser.cs.
Referenced by Derivate(), and Parser().
|
private |
Definition at line 73 of file Parser.cs.
Referenced by AccessChain(), AccessChainAssignment(), AllocateVariable(), And(), Arithmetic(), ArrayAssignment(), Atom(), BinaryAnd(), BinaryNot(), BinaryNotAssign(), BinaryOr(), BitwiseAnd(), BitwiseOr(), BitwiseXor(), BraceArray(), BracketArray(), Break(), Continue(), Factor(), For(), ForEach(), FunctionCall(), FunctionCall(), FunctionDeclaration(), If(), InsertDebugInfo(), IsAccessChainAssignment(), IsPointer(), LockedStatementList(), Member(), MemberAssignment(), Not(), Notify(), Or(), Parse(), Parser(), Pointer(), PostDecrement(), PostIncrement(), PreDecrement(), PreIncrement(), Relation(), ResolveForwardFunctionDeclarations(), Return(), RoutineCall(), ShiftLeft(), ShiftRight(), Switch(), Term(), VariableAssignment(), VariableDeclaration(), Wait(), While(), Xor(), and Yield().
|
private |
Definition at line 70 of file Parser.cs.
Referenced by FunctionCall(), Parse(), Parser(), and ResolveForwardFunctionDeclarations().
|
private |
Definition at line 69 of file Parser.cs.
Referenced by AllocateFunctionFrame(), AllocateTemporaryVariable(), FreeFunctionFrame(), Parse(), and Parser().
|
private |
Definition at line 68 of file Parser.cs.
Referenced by AllocateTemporaryVariable(), AllocateVariable(), ExpectIdentifier(), FreeFunctionFrame(), FunctionDeclaration(), Parse(), and Parser().
|
private |
|
private |
Definition at line 66 of file Parser.cs.
Referenced by Atom(), FunctionCall(), LookAhead(), LookAhead(), More(), Parse(), Parser(), ReadToken(), and UndoToken().
|
private |
Definition at line 63 of file Parser.cs.
Referenced by Parse(), Parser(), and VariableDeclaration().
|
private |
Definition at line 65 of file Parser.cs.
Referenced by Atom(), LookAhead(), LookAhead(), More(), Parser(), and ReadToken().
|
private |
Definition at line 67 of file Parser.cs.
Referenced by AllocateTemporaryVariable(), AllocateVariable(), ExpectIdentifier(), Parse(), Parser(), and VariableDeclaration().