I recently had an idea for a language called Calcularity. Suppose I tell you tha
ID: 3793212 • Letter: I
Question
I recently had an idea for a language called Calcularity. Suppose I tell you that my new language just has five token types: Integer literals (INT_LIT), which are sequences of number Identifiers (CHAR_UT), which are sequences of alphabetic characters Addition (ADD_OP), which is the character Multiplication (MULT_OP), which is the character Assignment (ASSIGN), which is the "=" character Now look at the statement below and fill out the table that follows with the corresponding lexemes and tokens: myVar = yourVar * 75 + herVar * hisVar;Explanation / Answer
The Statement is :
myVar = yourVar * 75 + herVar * hisVar
A lexeme is a sequence of characters in the source program that matches the pattern for a token and is identified by the lexical analyzer as an instance of that token.
A token is a pair consisting of a token name and an optional attribute value. The token name is an abstract symbol representing a kind of lexical unit, e.g., a particular keyword, or sequence of input characters denoting an identifier. The token names are the input symbols that the parser processes
Pair: <Token Name, attribute>
So Lexeme, Token table as follows.
Lexeme Token
INT_LIT
myVar <CHAR_LIT,0>
= <=>
yourVar <CHAR_LIT,1>
* <*>
75 <INT_LIT,0>
+ <+>
herVar <CHAR_LIT,2>
* <*>
hisVar <CHAR_LIT,3>