Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Code in Java package lexer; /** * The Token class records the information for a token: * 1. The Symbol that describes the characters in
Code in Java
package lexer; /**Overview The purpose of this assignment is to extend the Lexer component of our x language compiler to be able to handle additional tokens, to supplement our understanding of Compilers and Lexical Analysis. You are provided with the Lexer code (in the compiler codebase), which will be automatically cloned into your github repository when you begin the assignment via this github assignment link. Submission Your assignment will be submitted using github. Only the main branch of your repository will be graded. Late submission is determined by the last commit time on the "main" branch. You are required to submit a documentation PDF named "documentation.pdf" in a "documentation" folder at the root of your project. Please refer to the documentation requirements posted on iLearn. Organization and appearance of this document is critical. Please use spelling and grammar checkers - your ability to communicate about software and technology is almost as important as your ability to write software! Requirements The Token class must be updated to include the line number that a token was found (for subsequent error reporting, etc.)* The Token class records the information for a token: * 1. The Symbol that describes the characters in the token * 2. The starting column in the source file of the token and * 3. The ending column in the source file of the token **/ public class Token { private int leftPosition,rightPosition; private Symbol symbol; /** * Create a new Token based on the given Symbol * @param leftPosition is the source file column where the Token begins * @param rightPosition is the source file column where the Token ends */ public Token( int leftPosition, int rightPosition, Symbol sym ) { this.leftPosition = leftPosition; this.rightPosition = rightPosition; this.symbol = sym; } public Symbol getSymbol() { return symbol; } public void print() { System.out.println( " " + symbol.toString() + " left: " + leftPosition + " right: " + rightPosition ); return; } public String toString() { return symbol.toString(); } public int getLeftPosition() { return leftPosition; } public int getRightPosition() { return rightPosition; } /** * @return the integer that represents the kind of symbol we have which * is actually the type of token associated with the symbol */ public Tokens getKind() { return symbol.getKind(); } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started