Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Assume that an id can only contain letters (only alphabetic characters), digits, and underscores ( ) with the restrictions that it must begin with a
Assume that an id can only contain letters (only alphabetic characters), digits, and underscores ( ) with the restrictions that it must begin with a letter, cannot end with an underscore and cannot have two consecutive underscores. For example, give 2 Joe, tell me and A45Asm3 are valid identifiers, but 6gh, two bad, and no end are not. integer is an unsigned integer.
The test.java files are below on github
https://github.com/kasonchan/Java_TinyJavaParser/tree/e0410209947cbabf8a683178cf39f440b6b6582c/Tests
Consider the following extended BNF grammar for a subset of the Java programming language called Tiny Java. :-import java.util.*; class-definition class-definition program class-definition member-list member-declaration member-declarator function-definition class class-identifier { {member-list)) member-declaration {member-declaration} member-declarator ; | function-definition static] variable-declaration function-declaration ::= = ::= ::-- ::= variable-declaration ;) statement-list return expression; function-declaration :- public [static] type function-identifier argument-declaration-list) main-declaration type object-identifier [ { [ ] } new int [ integer] { [ integer ] } ] variable-declaration main-declaration ::-- := static Scanner in = new Scanner ( System . in := class-identifier l int | boolean :== type object-identifier( public static void main (String args []) type argument-declaration-listargument-declaration {, argument-declaration argument-declaration compound-statement statement-list statement := { statement-list statement(statement) :compound-statement assignment-statement if (expression) statement else statement] while expression) statement System . out . println assignment-statement := variable expression variable new class-identifier ) variable nextInt () expression expression-list term primary-expression object variable function-call := term | expression binary-operator expression ::= expression expression} :primary-expressionunary-operator term := object l integer l true | false | ( expression ) ::= variable l function-call ::- this | [object .] object-identifier { expression 1} :- [object .] function-identifier expression-list] ) Syntactic and Semantic Conventions The keywords and the token symbols in Tiny Java are in bold. Note that TinyJava has symbols i, and ] which are distinguished from grammar metasymbols t, , , and ], respectively, by underlining Consider the following extended BNF grammar for a subset of the Java programming language called Tiny Java. :-import java.util.*; class-definition class-definition program class-definition member-list member-declaration member-declarator function-definition class class-identifier { {member-list)) member-declaration {member-declaration} member-declarator ; | function-definition static] variable-declaration function-declaration ::= = ::= ::-- ::= variable-declaration ;) statement-list return expression; function-declaration :- public [static] type function-identifier argument-declaration-list) main-declaration type object-identifier [ { [ ] } new int [ integer] { [ integer ] } ] variable-declaration main-declaration ::-- := static Scanner in = new Scanner ( System . in := class-identifier l int | boolean :== type object-identifier( public static void main (String args []) type argument-declaration-listargument-declaration {, argument-declaration argument-declaration compound-statement statement-list statement := { statement-list statement(statement) :compound-statement assignment-statement if (expression) statement else statement] while expression) statement System . out . println assignment-statement := variable expression variable new class-identifier ) variable nextInt () expression expression-list term primary-expression object variable function-call := term | expression binary-operator expression ::= expression expression} :primary-expressionunary-operator term := object l integer l true | false | ( expression ) ::= variable l function-call ::- this | [object .] object-identifier { expression 1} :- [object .] function-identifier expression-list] ) Syntactic and Semantic Conventions The keywords and the token symbols in Tiny Java are in bold. Note that TinyJava has symbols i, and ] which are distinguished from grammar metasymbols t, , , and ], respectively, by underliningStep 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