Package com.jugubell.bproccli.compiler
Class VerifySyntax
java.lang.Object
com.jugubell.bproccli.compiler.VerifySyntax
The class handling the syntax verification of the code.
- Author:
- Jugurtha Bellagh
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetCode()Getting the calculated program metadata.Checks if the line is a labelChecks if the line is the label start:booleanMethod to verify the syntax correctness.Returns what type of line of code is.
-
Constructor Details
-
VerifySyntax
Constructor ofVerifySyntax- Parameters:
code- a trimmed code from any comment or extra spaces asListofString
-
-
Method Details
-
getProgramMetadata
Getting the calculated program metadata.- Returns:
- program metadata as
ProgramMetadataobject.
-
getCode
-
getCodeLineType
-
isSyntaxCorrect
public boolean isSyntaxCorrect()Method to verify the syntax correctness. It logs program metadata and Syntax OK, if true It logs error, place of the error, type of the error if not. It generates line type in aTreeMapwith the same size as thecodeand stores it incodeLineType. The code is inspected line by line, and checks each line the corresponding line type with the methodwhatLine(String[]). Checks for allowed data range declaration. Checks for program and data ranges overlapping. Checks for label start syntax requirement Checks for duplicate labels Checks for duplicate data declaration Checks for general syntax guidelines. If there is an error, it will be aborted, and returns false, with error logs.- Returns:
- boolean true if syntax is correct
-
isLabel
Checks if the line is a label- Parameters:
label- the code line asStringarray- Returns:
- a
LineTypeasLABELif true, otherwiseSYNTAX_ERROR
-
isStart
Checks if the line is the label start:- Parameters:
str- the code line as aStringarray- Returns:
- a
LineTypeSTART, otherwiseSYNTAX_ERROR
-
whatLine
Returns what type of line of code is.- Parameters:
str- a code line as aStringarray- Returns:
- a
LineTypeaccording to the line type, otherwiseSYNTAX_ERROR
-