Question: 1 Star Programming Language For this phase, you will use Lex tool for writing the scanner and Yace tool for writing the parser for a


1 Star Programming Language For this phase, you will use Lex tool for writing the scanner and Yace tool for writing the parser for a programming language called Star. 1. The Scanner and the Lexemes: - Keywords: int, float,boolean, if,else,end,true,false, read, print, while,START,END. - Operators: - Arithmetic: +,,,/ - Logic: \&\&, , ! - Relational: ==,,,==, - Assignment: =: - Punctuation elements: (),{} - Precedence and associativity The table below shows all Star language operators from highest to lowest precedence, along with their associativity. Thhle 1. nraradanea and asonciativity tahla - Identifiers: should start with capital letter and can include small, capital letters, underscores, or digits. - Comment: is sequence of any characters between double hash \#\# . . . .\#\#and any thing inside commentst should be ignored. - Literals: INT_NUMBERe.g. 12345, STRING_LITERAL e.g. "Hello" and FLOAT_LITERAL e.g. 3.14. 2. The Parser and the Grammar: When YACC finds input that doesn't match the grammar, it automatically terminates with the message 'Syntax error'. You will need to implement an error routine (yyerror) that also prints out the line number before this termination, and a main method that read Star code from a file. Print an appropriate message in case of no syntax error. Build your parser using the grammar below: - Program START Statements END - Statements Statements Statement| Statement - Statement Dec_stmt Assignment_stmt | Print_stmt | Read_stmt | Condition_stmt | While_stmt - Dec_stmt Type ID - Type int float boolean - Assignment_stmt ID = Expression - Expression exp==expexpexpexp
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
