The ezr² Project 0.1.1
The codebase for the ezr² programming language.
Loading...
Searching...
No Matches
EzrSquared.Syntax.Parser Class Reference

The ezr² Parser. The job of the Parser is to convert the input Token objects from the Lexer into Node objects to be given as the input to the Runtime.Interpreter.Interpreter. More...

Public Member Functions

 Parser (List< Token > tokens)
 Creates a new Parser object.
 
ParseResult Parse ()
 Parses the Token objects in _tokens.
 

Private Member Functions

void Advance (int advanceCount=1)
 Advances to the next Token object in _tokens.
 
void Reverse (int reverseCount=1)
 Reverses back to the Token object at _index - reverseCount in _tokens.
 
Token PeekPrevious ()
 Peeks at the previous Token object from _index in _tokens.
 
Token PeekNext (int advanceCount=1)
 Peeks at the next Token object from _index in _tokens.
 
void BinaryOperation (Action left, Action right, TokenType[] operators,(TokenType Type, Action OnCase)? specialCase=null)
 Tries creating a BinaryOperationNode.
 
void ParseStatements ()
 Tries parsing a 'statements' structure.
 
void ParseStatement ()
 Tries parsing a 'statement' structure.
 
void ParseExpression (bool itemKeywordRequired=false)
 Tries parsing an 'expression' structure.
 
void ParseQuickExpression (bool itemKeywordRequired=false)
 Tries parsing a 'quick-expression' structure.
 
void ParseJunction ()
 Tries parsing a 'junction' structure.
 
void ParseInversion ()
 Tries parsing an 'inversion' structure.
 
void ParseContainsCheck ()
 Tries parsing a 'contains-check' structure.
 
void ParseComparison ()
 Tries parsing a 'comparison' structure.
 
void ParseBitwiseOr ()
 Tries parsing a 'bitwise-or' structure.
 
void ParseBitwiseXOr ()
 Tries parsing a 'bitwise-xor' structure.
 
void ParseBitwiseAnd ()
 Tries parsing a 'bitwise-and' structure.
 
void ParseBitwiseShift ()
 Tries creating a 'bitwise-shift' structure.
 
void ParseArithmeticExpression ()
 Tries parsing an 'arithmetic-expression' structure.
 
void ParseTerm ()
 Tries parsing a 'term' structure.
 
void ParseFactor ()
 Tries parsing a 'factor' structure.
 
void ParsePower ()
 Tries parsing a 'power' structure.
 
void ParseObjectAttributeAccess ()
 Tries parsing an 'object-attribute-access' structure.
 
void ParseCall ()
 Tries parsing a 'call' structure.
 
void ParseAtom ()
 Tries parsing a 'atom' structure.
 
void ParseArrayOrParentheticalExpression ()
 Tries parsing an array, an ArrayLikeNode with ArrayLikeNode.CreateList set to false OR a parenthetical expression. Starts from _currentToken, which should be of TokenType TokenType.LeftParenthesis.
 
void ParseList ()
 Tries parsing a list, an ArrayLikeNode with ArrayLikeNode.CreateList set to true. Starts from _currentToken, which should be of TokenType TokenType.LeftSquareBracket.
 
void ParseDictionary ()
 Tries parsing a dictionary. Starts from _currentToken, which should be of TokenType TokenType.LeftCurlyBracket.
 
void ParseIfExpression ()
 Tries parsing an if expression. Starts from _currentToken, which should be of TokenType TokenType.KeywordIf.
 
void ParseCountExpression ()
 Tries parsing a count expression. Starts from _currentToken, which should be of TokenType TokenType.KeywordCount.
 
void ParseWhileExpression ()
 Tries parsing a while expression. Starts from _currentToken, which should be of TokenType TokenType.KeywordWhile.
 
void ParseTryExpression ()
 Tries parsing a try expression. Starts from _currentToken, which should be of TokenType TokenType.KeywordTry.
 
void ParseFunctionDefinitionExpression ()
 Tries parsing a function definition expression. Starts from _currentToken, which should be of TokenType TokenType.KeywordFunction.
 
void ParseClassDefinitionExpression ()
 Tries parsing an class definition expression. Starts from _currentToken, which should be of TokenType TokenType.KeywordObject.
 
void ParseIncludeExpression ()
 Tries parsing an include expression. Starts from _currentToken, which should be of TokenType TokenType.KeywordInclude.
 
void ParseDefineBlockExpression ()
 Tries parsing a define block expression. Starts from _currentToken, which should be of TokenType TokenType.KeywordDefine.
 

Private Attributes

readonly List< Token_tokens
 The List<T> of Token objects to be parsed.
 
readonly ParseResult _result
 The object that holds the result of the parsing.
 
int _index
 The index of the Token object currently being parsed in the _tokens List<T>.
 
Token _currentToken
 The Token object currently being parsed at _index of _tokens.
 

Detailed Description

The ezr² Parser. The job of the Parser is to convert the input Token objects from the Lexer into Node objects to be given as the input to the Runtime.Interpreter.Interpreter.

Constructor & Destructor Documentation

◆ Parser()

EzrSquared.Syntax.Parser.Parser ( List< Token > tokens)

Creates a new Parser object.

Parameters
tokensThe List<T> of Token objects to be parsed.

Member Function Documentation

◆ BinaryOperation()

void EzrSquared.Syntax.Parser.BinaryOperation ( Action left,
Action right,
TokenType[] operators,
(TokenType Type, Action OnCase)? specialCase = null )
private

Tries creating a BinaryOperationNode.

Parameters
leftThe function to call for the first operand.
rightThe function to call for the second operand.
operatorsThe operator TokenType object(s).
specialCaseAny special case that needs to be uniquely handled by the "OnCase" Action.

"OnCase" is called after the token of type "Type" and any new lines have been parsed, and before right has been called.
Note that "Type" must be included in operators .

◆ ParseExpression()

void EzrSquared.Syntax.Parser.ParseExpression ( bool itemKeywordRequired = false)
private

Tries parsing an 'expression' structure.

Parameters
itemKeywordRequiredIn cases where the variable assignment expression requires the 'item' keyword, set this to true.

◆ PeekNext()

Token EzrSquared.Syntax.Parser.PeekNext ( int advanceCount = 1)
private

Peeks at the next Token object from _index in _tokens.

Parameters
advanceCountThe numbers of places to advance in _tokens.
Returns
The Token object.

◆ PeekPrevious()

Token EzrSquared.Syntax.Parser.PeekPrevious ( )
private

Peeks at the previous Token object from _index in _tokens.

Returns
The Token object.

◆ Reverse()

void EzrSquared.Syntax.Parser.Reverse ( int reverseCount = 1)
private

Reverses back to the Token object at _index - reverseCount in _tokens.

Parameters
reverseCountThe number of positions to reverse _index in _tokens.

The documentation for this class was generated from the following file: