Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Description: You are required to implement a Scanner program for Java programming language in any programming language. The program should be GUI based and it

Description: You are required to implement a Scanner program for Java programming language in any programming language. The program should be GUI based and it should be able to accept the input from the file provided by the user. The scanner will then scan the code file and identifies all the tokens and list them as the output for user. In case of an invalid token, Scanner should mention that a given token is invalid. The scanner should consider following token categories;

Pre-Processing: Before scanning the code your program shall pre-process the input code and remove all the single-line and multi-line comments from the code.

Token Categories

  • Keywords
    • All Keywords
  • Special Symbols
    • Assignment Operator
      • =
    • Unary Operators
      • ++ -- !
    • Arithmetic Operators
      • + - * / %
    • Relational Operators
      • < <= > >= == !=
    • Conditional Operators
      • && ||
    • Symbols
      • ( ) { } [ ] . , ; :
  • Identifier
  • Integer
    • Positive & Negative
  • Real Number
    • Positive & Negative
  • Character Literal
  • String Literal

Parser: Now You are required to extend the implementation of Scanner and use the identified tokens in the scanning phase to validate the syntax of the program. You only need to consider the program syntax that can be generated from the grammar given below. The project will be tested only against the code that can be written using the below mentioned grammar.

Context Free Grammar

S class class class_signature { data_declaration constructor method } class_signature public class identifier data_declaration access_modifier static data_type identifier; data_declaration | access_modifier public | private static static | data_type byte | short | int | long identifier alphabet alpha_numeric alpha_numeric alphabet digit alpha_numeric | digit alphabet alpha_numeric | digit 0|1|2||9 integer digit | digit integer | alphabet A|B|C||X|Y|Z|a|b|c||x|y|z constructor constructor_signature { statements } constructor_signature access_modifier identifier ( parameter_list ) method method_signature { statements return_statement } method_signature access_modifier return_type identifier ( parameter_list ) return_type void | data_type parameter_list parameter | paremter, parameter_list | parameter data_type identifier return_statement return identifier | return integer | statements assignment statements | function_call statements | conditions statements | assignment identifier = expression; | this.identifier = expression; | local_declaration = expression;

expression identifier | digit | expression arith_operator expression arith_operator + | - | * | / | % local_declaration data_type identifier function_call identifier ( argument_list ); | this.identifier ( argument_list ); argument_list identifier | identifier, argument_list | conditions if_condistion if_condition if( predicate ) { statements } predicate identifier rel_operator identifier | identifier rel_operator digit rel_operator < | <= | > | >= | != | ==

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_2

Step: 3

blur-text-image_3

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 Security

Authors: Alfred Basta, Melissa Zgola

1st Edition

1435453905, 978-1435453906

More Books

Students also viewed these Databases questions

Question

2. The model is credible to the trainees.

Answered: 1 week ago