Class Parser
java.lang.Object
org.episteme.natural.computing.compiler.Parser
A recursive descent parser for building Abstract Syntax Trees.
Provides infrastructure for parsing token streams into AST nodes. Subclasses implement specific grammar rules.
- Since:
- 1.0
- Author:
- Silvere Martin-Michiellot, Gemini AI (Google DeepMind)
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBase class for AST nodes.static interfaceVisitor pattern for AST traversal.static classstatic classstatic classstatic classstatic classstatic classException thrown during parsing.static classstatic classstatic class -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected Lexer.Tokenadvance()protected booleanprotected booleancheckOperator(String... operators) protected voidprotected booleanisAtEnd()parse(List<Lexer.Token> tokens) Parses a token stream into an AST.protected Parser.ASTNodeprotected Parser.CallNodeparseCall(Lexer.Token nameToken) protected Parser.ASTNodeprotected Parser.ASTNodeprotected Parser.ASTNodeprotected Parser.ProgramNodeprotected Parser.ASTNodeprotected Parser.ASTNodeprotected Lexer.Tokenpeek()
-
Field Details
-
tokens
-
position
protected int position
-
-
Constructor Details
-
Parser
public Parser()
-
-
Method Details
-
parse
Parses a token stream into an AST.- Throws:
Parser.ParseException
-
parseProgram
- Throws:
Parser.ParseException
-
parseStatement
- Throws:
Parser.ParseException
-
parseExpression
- Throws:
Parser.ParseException
-
parseAdditive
- Throws:
Parser.ParseException
-
parseMultiplicative
- Throws:
Parser.ParseException
-
parseUnary
- Throws:
Parser.ParseException
-
parsePrimary
- Throws:
Parser.ParseException
-
parseCall
- Throws:
Parser.ParseException
-
isAtEnd
protected boolean isAtEnd() -
peek
-
advance
-
check
-
checkOperator
-
expect
- Throws:
Parser.ParseException
-