Package org.kigalisim.lang.parse
Class ParseResult
java.lang.Object
org.kigalisim.lang.parse.ParseResult
Result of parsing a QubecTalk source code file.
Structure representing the result of parsing a QubecTalk source code file, which may contain either a successfully parsed program or a list of errors encountered during parsing.
-
Constructor Summary
ConstructorsConstructorDescriptionParseResult(List<ParseError> errors) Constructs a ParseResult with the specified errors and no program.ParseResult(org.kigalisim.lang.QubecTalkParser.ProgramContext program) Constructs a ParseResult with the specified program and no errors. -
Method Summary
Modifier and TypeMethodDescriptionGet the list of parsing errors.Optional<org.kigalisim.lang.QubecTalkParser.ProgramContext> Get the parsed program.booleanDetermine if there were errors during parsing.
-
Constructor Details
-
ParseResult
public ParseResult(org.kigalisim.lang.QubecTalkParser.ProgramContext program) Constructs a ParseResult with the specified program and no errors.- Parameters:
program- the parsed program.
-
ParseResult
Constructs a ParseResult with the specified errors and no program.- Parameters:
errors- the errors encountered which must not be empty.- Throws:
IllegalArgumentException- if errors is empty.
-
-
Method Details
-
getProgram
Get the parsed program.- Returns:
- An Optional containing the parsed program if available.
-
getErrors
Get the list of parsing errors.- Returns:
- A list of ParseError encountered during parsing.
-
hasErrors
public boolean hasErrors()Determine if there were errors during parsing.- Returns:
- true if there are errors, false otherwise.
-