Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribedimage text in transcribed

package lexer; /** 
 * 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(); } }
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.)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

DATABASE Administrator Make A Difference

Authors: Mohciine Elmourabit

1st Edition

B0CGM7XG75, 978-1722657802

More Books

Students also viewed these Databases questions

Question

5. What decision-making model would you advocate to this person?

Answered: 1 week ago