Question
URGENT! I GENUINELY NEED HELP I need help creating the Scanner and Parser class in JAVA. It takes a SCL file and analyzes it. The
URGENT! I GENUINELY NEED HELP
I need help creating the Scanner and Parser class in JAVA. It takes a SCL file and analyzes it.
The tasks consist of the development of an interpreter for a subset of the SCL language. The interpreter can be implemented in Python
Interpreter Project This project consists of developing an interpreter for a subset of the SCL language. The specification of the grammar of a large subset of SCL is given below. You may propose a smaller subset of SCL
The interpreter will process an SCL program. All tokens in this language are separated by white spaces. The parsing algorithm should detect any syntactical or semantic error. The first such error discovered should cause an appropriate error message to be printed, and then the interpreter should terminate. Run-time errors should also be detected with appropriate error messages being printed. Develop a complete scanner for the SCL language. You must submit a short report describing the work performed. You must also include the source scanner program, input and output files. The report must show the execution of this scanner program by using appropriate input files, the program must show a list of the tokens scanned.
LONG STORY SHORT
The task is to implement a scanner that converts SCL into tokens. If something is not a token print an error message. The scanner should be coded in Python. Build a parser that checks the syntax of the code and makes sure it's correct. If there is an error print an error message for the line the error occurs on. please heavily comment code. I wouldn't be asking this question if I didn't need to but I'm confused about this project
Grammar for a (large) subset of SCL language The following grammar specification of the SCL language is in a modified BNF notation. The terminal symbols are all in upper case. func_main ::= FUNCTION IDENTIFIER oper_type | MAIN oper_type ::= RETURN chk_ptr chk_array ret_type chk_ptr ::= | POINTER OF chk_array ::= [empty] | ARRAY array_dim_list array_dim_list ::= LB array_index RB | array_dim_list LB array_index RB array_index ::= IDENTIFIER | ICON ret_type ::= TYPE type_name | STRUCT IDENTIFIER | STRUCTYPE IDENTIFIER type_name ::= MVOID | INTEGER | SHORT | REAL | FLOAT | DOUBLE | TBOOL | CHAR | TSTRING OF LENGTH ICON | TBYTE struct_enum ::= STRUCT | ENUM specifications ::= | SPECIFICATIONS spec_list spec_list ::= spec_def | spec_list spec_def spec_def ::= ENUM | STRUCT | DESCRIPTION globals ::= | GLOBAL DECLARATIONS const_dec var_dec struct_dec const_var_struct ::= const_dec var_dec struct_dec const_dec ::= | CONSTANTS data_declarations var_dec ::= VARIABLES data_declarations struct_dec ::= | STRUCT data_declarations data_declarations ::= comp_declare | data_declarations comp_declare comp_declare ::= DEFINE data_file data_file ::= sel_file | sel_dmode data_declaration data_declaration ::= IDENTIFIER parray_dec OF data_type data_type ::= TUNSIGNED | CHAR | INTEGER | MVOID | DOUBLE | LONG | SHORT | FLOAT | REAL | TSTRING | TBOOL | TBYTE parray_dec ::= | ARRAY plist_const popt_array_val | LB | VALUE | EQUOP plist_const ::= LB iconst_ident RB | plist_const LB iconst_ident RB iconst_ident ::= ICON | IDENTIFIER popt_array_val ::= | value_eq array_val value_eq ::= VALUE | EQUOP array_val ::= simp_arr_val simp_arr_val ::= LB arg_list RB arg_list ::= expr | arg_list COMMA expr implement ::= IMPLEMENTATIONS main_head funct_list main_head ::= | MAIN DESCRIPTION parameters funct_list ::= funct_body | funct_list funct_body funct_body ::= FUNCTION phead_fun pother_oper_def pother_oper_def ::= pother_oper IS const_var_struct precond CS4308 Project 4 BEGIN pactions ENDFUN IDENTIFIER pother_oper ::= acc_mut IDENTIFIER DESCRIPTION oper_type parameters precond ::= | PRECONDITION pcondition pcondition ::= pcond1 OR pcond1 | pcond1 AND pcond1 | pcond1 pcond1 ::= NOT pcond2 | pcond2 pcond2 ::= LP pcondition RP | expr RELOP expr | expr EQOP expr | expr eq_v expr | expr opt_not true_false | element true_false ::= MTRUE | MFALSE eq_v ::= EQUALS | GREATER THAN | LESS THAN | GREATER OR EQUAL | LESS OR EQUAL opt_not ::= | NOT parameters ::= | PARAMETERS param_list param_list ::= param_def | param_list COMMA param_ CS4308 Project 5 | FCON | MTRUE | MFALSE | LP expr RP pactions ::= action_def | pactions action_def action_def ::= SET name_ref EQUOP exp | READ pvar_value_list | INPUT name_ref | DISPLAY pvar_value_list | DISPLAYN pvar_value_list | MCLOSE IDENTIFIER | MOPEN in_out | MFILE read_write | INCREMENT name_ref | DECREMENT name_ref | RETURN expr | CALL name_ref pusing_ref | IF pcondition THEN pactions ptest_elsif opt_else ENDIF | FOR name_ref EQUOP expr downto expr DO pactions ENDFOR | REPEAT pactions UNTIL pcondition ENDREPEAT | WHILE pcondition DO pactions ENDWHILE | CASE name_ref pcase_val pcase_def MENDCASE | MBREAK | MEXIT | ENDFUN name_ref | POTCONDITION pcondition ptest_elsif ::= | proc_elseif proc_elseif ::= ELSEIF pcondition THEN pactions | proc_elseif ELSEIF pcondition THEN pactions downto ::= TO | DOWNTO pusing_ref ::= | USING arg_list | parguments parguments ::= LP arg_list RP pcase_val ::= MWHEN expr COLON pactions | pcase_val MWHEN expr COLON pactions pcase_def ::= | DEFAULT COLON pactions pvar_value_list ::= expr | pvar_value_list COMMA expr opt_else ::= | ELSE pactions in_out ::= INPUT MFILE IDENTIFIER | OUTPUT MFILE IDENTIFIER read_write ::= READ pvar_value_list FROM IDENTIFIER CS4308 Project 6 | WRITE pvar_value_list TO IDENTIFIER name_ref ::= IDENTIFIER opt_ref pmember_opt popt_dot pmember_opt ::= | pmember_of pmember_of ::= OF IDENTIFIER opt_ref | pmember_of OF IDENTIFIER opt_ref opt_ref ::= array_val popt_ref ::= | array_val | parguments popt_dot ::= | proc_dot proc_dot ::= DOT IDENTIFIER opt_ref | proc_dot DOT IDENTIFIER opt_ref Lexical rules (are using a regular expression notation) white_space [ \t] sign [+-]? digit [0-9] alpha [A-Za-z] alpha_num ({alpha}|{digit}|_) hex_digit [0-9A-F] wordiden ((_?{alpha}+({alpha_num}*\.{alpha_num}+)*) |(_?{alpha}+({alpha_num}*"->"{alpha_num}+)*)) unsigned_integer {digit}+ sinteger {sign}{digit}+ hex_integer (0{hex_digit}+h) exponent e[+-]?{digit}+ i {unsigned_integer} real ({i}\.{i}?|{i}?\.{i}){exponent}? sreal {sign}{real} bad_string \"([^" ]|\"\")+ schar \'{alpha_num}\' string \"[^" ]*[" ]
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