Package gcodeCompiler
Class gcodeGrammarHandler
java.lang.Object
gcodeCompiler.gcodeGrammarHandler
public class gcodeGrammarHandler
extends java.lang.Object
This class is responsible for the management of the G-Code language.
-
Field Summary
Fields Modifier and Type Field Description java.util.SortedMap<java.lang.Integer,BlockDescriptor>
blocks
The blocks.static int
ERR_ON_SYNTAX
The Constant ERR_ON_SYNTAX.(package private) java.util.List<GCodeError>
errorList
The error list.private int
last_n
The last n.static int
LAST_SYNTAX_ERROR
The Constant LAST_SYNTAX_ERROR.(package private) org.antlr.runtime.Token
last_token
The last token.(package private) org.antlr.runtime.TokenStream
lexerStream
The lexer stream.static int
SEM_BLOCK_ORDER
The Constant SEM_BLOCK_ORDER.static int
SEM_DUPLICATE_ERR
The Constant SEM_DUPLICATE_ERR.static int
SEM_END_ROT_ERR
The Constant SEM_END_ROT_ERR.static int
SEM_JOB_SPEED_ERR
The Constant SEM_JOB_SPEED_ERR.static int
SEM_MOVE_SPEED_ERR
The Constant SEM_MOVE_SPEED_ERR.static int
SEM_NO_ABS_BEFORE_REL
The Constant SEM_NO_ABS_BEFORE_REL.static int
SEM_NO_COORDINATE_TYPE
The Constant SEM_NO_COORDINATE_TYPE.static int
SEM_NO_END_PROG
The Constant SEM_NO_END_PROG.static int
SEM_NO_SPEED_COORD_TYPE
The Constant SEM_NO_SPEED_COORD_TYPE.static int
SEM_NO_SPINDLE_ROTATION
The Constant SEM_NO_SPINDLE_ROTATION.static int
SEM_NOT_90_DEGREE
The Constant SEM_NOT_90_DEGREE.static int
SEM_TOOL_ERR
The Constant SEM_TOOL_ERR.static int
TOKEN_ERROR
The Constant TOKEN_ERROR.static int
UNDEFINED
The Constant UNDEFINED. -
Constructor Summary
Constructors Constructor Description gcodeGrammarHandler(org.antlr.runtime.TokenStream ls)
Constructor of the gcodeGrammarHandler class. -
Method Summary
Modifier and Type Method Description private BlockDescriptor
BlockInit(org.antlr.runtime.Token n, java.util.List<InfoGeometriche> info_g_list, java.util.List<InfoTecnologiche> info_t_list, java.util.List<InfoTecnologicheM> info_t_M_list)
Block initialization method.void
createNewBlock(org.antlr.runtime.Token n, java.util.List<InfoGeometriche> info_g_list, java.util.List<InfoTecnologiche> info_t_list, java.util.List<InfoTecnologicheM> info_t_M_list)
Method for creating a new G-Code block.java.util.List<GCodeError>
getErrorList()
Method that returns the G-Code error list.org.antlr.runtime.Token
getLast_token()
Method that returns the last token in the list.(package private) void
handleError(java.lang.String[] tokenNames, org.antlr.runtime.RecognitionException e, java.lang.String h, java.lang.String m)
Method that handles lexical and syntactic errors.void
printBlocks()
Print function for the block list.void
semanticErrorHandler(int code, org.antlr.runtime.Token tk, BlockDescriptor bd)
Method that handles all semantic errors for G-Code.
-
Field Details
-
TOKEN_ERROR
public static final int TOKEN_ERRORThe Constant TOKEN_ERROR.- See Also:
- Constant Field Values
-
ERR_ON_SYNTAX
public static final int ERR_ON_SYNTAXThe Constant ERR_ON_SYNTAX.- See Also:
- Constant Field Values
-
SEM_BLOCK_ORDER
public static final int SEM_BLOCK_ORDERThe Constant SEM_BLOCK_ORDER.- See Also:
- Constant Field Values
-
SEM_NO_END_PROG
public static final int SEM_NO_END_PROGThe Constant SEM_NO_END_PROG.- See Also:
- Constant Field Values
-
SEM_TOOL_ERR
public static final int SEM_TOOL_ERRThe Constant SEM_TOOL_ERR.- See Also:
- Constant Field Values
-
SEM_NO_COORDINATE_TYPE
public static final int SEM_NO_COORDINATE_TYPEThe Constant SEM_NO_COORDINATE_TYPE.- See Also:
- Constant Field Values
-
SEM_NO_SPINDLE_ROTATION
public static final int SEM_NO_SPINDLE_ROTATIONThe Constant SEM_NO_SPINDLE_ROTATION.- See Also:
- Constant Field Values
-
SEM_DUPLICATE_ERR
public static final int SEM_DUPLICATE_ERRThe Constant SEM_DUPLICATE_ERR.- See Also:
- Constant Field Values
-
SEM_END_ROT_ERR
public static final int SEM_END_ROT_ERRThe Constant SEM_END_ROT_ERR.- See Also:
- Constant Field Values
-
SEM_MOVE_SPEED_ERR
public static final int SEM_MOVE_SPEED_ERRThe Constant SEM_MOVE_SPEED_ERR.- See Also:
- Constant Field Values
-
SEM_JOB_SPEED_ERR
public static final int SEM_JOB_SPEED_ERRThe Constant SEM_JOB_SPEED_ERR.- See Also:
- Constant Field Values
-
SEM_NO_SPEED_COORD_TYPE
public static final int SEM_NO_SPEED_COORD_TYPEThe Constant SEM_NO_SPEED_COORD_TYPE.- See Also:
- Constant Field Values
-
SEM_NO_ABS_BEFORE_REL
public static final int SEM_NO_ABS_BEFORE_RELThe Constant SEM_NO_ABS_BEFORE_REL.- See Also:
- Constant Field Values
-
SEM_NOT_90_DEGREE
public static final int SEM_NOT_90_DEGREEThe Constant SEM_NOT_90_DEGREE.- See Also:
- Constant Field Values
-
UNDEFINED
public static final int UNDEFINEDThe Constant UNDEFINED.- See Also:
- Constant Field Values
-
LAST_SYNTAX_ERROR
public static final int LAST_SYNTAX_ERRORThe Constant LAST_SYNTAX_ERROR.- See Also:
- Constant Field Values
-
blocks
The blocks. -
last_n
private int last_nThe last n. -
errorList
java.util.List<GCodeError> errorListThe error list. -
lexerStream
org.antlr.runtime.TokenStream lexerStreamThe lexer stream. -
last_token
org.antlr.runtime.Token last_tokenThe last token.
-
-
Constructor Details
-
gcodeGrammarHandler
public gcodeGrammarHandler(org.antlr.runtime.TokenStream ls)Constructor of the gcodeGrammarHandler class.- Parameters:
ls
- the ls
-
-
Method Details
-
createNewBlock
public void createNewBlock(org.antlr.runtime.Token n, java.util.List<InfoGeometriche> info_g_list, java.util.List<InfoTecnologiche> info_t_list, java.util.List<InfoTecnologicheM> info_t_M_list)Method for creating a new G-Code block.- Parameters:
n
- the ninfo_g_list
- the info g listinfo_t_list
- the info t listinfo_t_M_list
- the info t M list
-
BlockInit
private BlockDescriptor BlockInit(org.antlr.runtime.Token n, java.util.List<InfoGeometriche> info_g_list, java.util.List<InfoTecnologiche> info_t_list, java.util.List<InfoTecnologicheM> info_t_M_list)Block initialization method.- Parameters:
n
- the ninfo_g_list
- the info g listinfo_t_list
- the info t listinfo_t_M_list
- the info t M list- Returns:
- the built block
-
printBlocks
public void printBlocks()Print function for the block list. -
getErrorList
Method that returns the G-Code error list.- Returns:
- the G-Code error list
-
handleError
void handleError(java.lang.String[] tokenNames, org.antlr.runtime.RecognitionException e, java.lang.String h, java.lang.String m)Method that handles lexical and syntactic errors.- Parameters:
tokenNames
- the token namese
- the eh
- the hm
- the m
-
semanticErrorHandler
Method that handles all semantic errors for G-Code.- Parameters:
code
- the codetk
- the tkbd
- the bd
-
getLast_token
public org.antlr.runtime.Token getLast_token()Method that returns the last token in the list.- Returns:
- the last token
-