[SOLVED] CSE341 Project1- G++ Language Lexer

40.00 $

Programming resource
Digital learning resource
Category:
Practical programming resource
Suitable for guided study and reference
Tutor guidance available when needed

Description

Rate this product

Given the description of the G++ language (G++Syntax.pdf) you are asked to implement the lexer that does the tokenization of a given G++ program in a file.

You are expected to submit the file “student_id.cl” with a function called “lexer”. This function should take a file name and perform lexical analysis of the program contained within this file. The output of the function should be the tokens in a list. Sample input and output is provided below.

Sample Input: Sample Output: (There may be mistake(s))
(deffun sumup (x)

(if (equal x 0)

1

(+ x (sumup (- x 1)))

)

)

((“operator” “(“) (“keyword” “deffun”)

(“identifier” “sumup”) (“operator” “(“)

(“identifier” “x”) (“operator” “)”) (“operator”

“(“) (“keyword” “if”) (“operator” “(“) (“keyword”

“equal”) (“identifier” “x”) (“integer” “0”)

(“operator” “)”) (“integer” “1”) (“operator” “(“)

(“operator” “+”) (“identifier” “x”) (“operator”

“(“) (“identifier” “sumup”) (“operator” “(“)

(“operator” “-“) (“identifier” “x”) (“integer” “1”)

(“operator” “)”) (“operator” “)”) (“operator” “)”)

(“operator” “)”) (“operator” “)”)

 

 

 

Resource details

Understand the Task Before You Use the Resource

Review the requirements, identify the programming concepts involved, study the implementation and test your understanding with your own examples and modifications.