Final Report Toa
Final Report Toa
F2021266101 ArhamAhmad
F2021266134 NawwalAftabWaseer
F2021266121 M.AhmadAfzal
F2021266113 Talha Tajammal
Variables:
Variable_Declaration Data_Type Identifier
=”Expression” ;
Data_Type int | double | char | boolean | String
Identifier letter Identifier_Tail
Identifier_Tail Letter_Or_Digit Identifier_Tail |
ε
Letter a | b | c | ... | z | A | B | C | ... | Z | _
Letter_Or_Digit Letter | Digit
Digit 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
Expression Literal | Identifier | Expression
Binary_Operator Expression
Literal Integer_Literal | Double_Literal |
Char_Literal | Boolean_Literal | String_Literal
Integer_Literal Digit Integer_Literal_Tail
Integer_Literal_Tail Digit Integer_Literal_Tail |
ε
Double_Literal Digit Double_Literal_Tail
Double_Literal_Tail Digit Double_Literal_Tail
|ε
Char_Literal
Any_Character_Except_Single_Quote
Boolean_Literal true | false
String_Literal "Any_Sequence_Of_Characters"
Binary_Operator + | - | * | / | % | == | != | < | > |
<= | >= | && | ||
Conditions:
Conditional_Statement If_Statement |
If_Else_Statement | Switch_Statement
Additive_Operator + | -
Multiplicative_Operator * | / | %
Unary_Operator - | !
Statement Expression_Statement |
Declaration_Statement | If_Statement |
If_e]Else_Statement | Switch_Statement |
While_Statement | Do_While_Statement |
For_Statement
Expression_Statement Expression ;
Declaration_Statement Variable_Declaration ;
For_Init Expression_Statement |
Variable_declaration | ε
For_Condition Expression | ε
For_Update Expression_Statement | ε
Nested Condition:
Program Conditional_Statement | Statement
Conditional_Statement If_Statement |
If_Else_Statement
If_Statement If ( “condition” )
Nested_Condition
If_Else_Statement If ( “condition” )
Nested_Condition else Nested_Condition
Nested_Condition Conditional_Statement |
Statement
Condition Expression Relational_Operator
Expression | Expression
Relational_Operator == | != | | | = | =
Expression Term Expression_Tail
Expression_Tail Additive_Operator Term
Expression_Tail | ε
Additive_Operator + | -
Term Factor Term_Tail
Term_Tail Multiplicative_Operator Factor
Term_Tail | ε
Multiplicative_Operator * | / | %
Factor Literal | Identifier | “Expression”|
Unary_Operator Factor
Literal Integer_Literal | Double_Literal |
Char_Literal | Boolean_Literal | String_Literal
Integer_Literal Digit+
Double_Literal Digit+ . Digit+
Char_Literal
'Any_character_except_single_quote'
Boolean_Literal true | false
String_Literal "any_sequence_of_characters"
Identifier letter identifier_tail
Identifier_Tail letter_or_digit Identifier_Tail | ε
Letter a | b | c | ... | z | A | B | C | ... | Z | _
Letter_or_Digit Letter | Digit
Digit 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
Unary_operator - | !
Function:
Program Function_Declaration |
Class_Declaration
Function_Declaration Return_Type
Function_Name “Parameter_List”
Block_Statement
Return_Type Data_Type | void
Parameter_list> Parameter | Parameter_List ,
Parameter
Parameter Data_Type Variable_Declaration
Block_Statement “Statement_List
Statement_List Sstatement | Statement_List
Statement
Statement Expression_Statement |
Declaration_Statement | If_Statement |
While_Statement | Do_While_Statement |
For_Statement | Return_Statement
Expression_Statement Expression;
Declaration_Statement Variable_Declaration ;
If_Statement if ”Expression” Statement else
“Statement”
While_Statement while “expression” Statement
Do_While_Statement do Statement While
“Expression” ;
For_Statement for “For_Init ; For_Condition” ;
“For_Update” Statement
For_Init Expression_Statement |
Variable_Declaration | ε
For_Condition Expression | ε
For_Update Expression_Statement | ε
<return_statement> ::= return <expression> ;
Expression Literal | Identifier | Expression
Binary_Operator Expression | Unary_Operator
Expression | “Expression”
Literal Integer_Literal | Double_Literal |
Char_Literal | Boolean_Literal | String_Literal
Integer_Literal Digit+
Double_Literal Digit . Digit+
Char_Literal
Any_Character_Except_Single_Quote
Boolean_Literal true | false
String_Literal Any_Sequence_Of_Characters
Data_Type int | double | char | boolean | String |
Custom_Class_Type
Identifier Letter Identifier_Tail
Identifier_Tail Letter_Or_Digit Identifier_Tail |
ε
Letter a | b | c | ... | z | A | B | C | ... | Z | _
Letter_Or_Digit Letter | Digit
Digit 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
Array:
Program Array_Declaration | Statement
Array_Declaration Data_Type Identifier
Expression ;
Statement Expression_Statement |
Declaration_Statement
Expression_Statement Expression ;
Declaration_Statement Variable_Declaration
;
Expression Identifier | Array_access |
Array_creation
Array_access Identifier “expression”
Array_Creation new Data_Type expression
Data_Type int | double | char | boolean |
String
Identifier letter Identifier_Tail
Identifier_Tail Letter_or_Digit
Identifier_Tail | ε
Letter a | b | c | ... | z | A | B | C | ... | Z | _
Letter_or_Digit Letter | Digit
Digit 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
LOOP:
<initialization> → <expression_statement> |
<variable_declaration> | ε
<condition> → <expression> | ε
<update> → <expression_statement> | ε
<statement> → <array_delecration>|
<Expression> | <block_statement> | <loop>|
<Condition_Statement>|<Variable_Declaration>
<expression_statement> → <expression> ;
Variable Declaration
<variable_declaration> → <data_type>
<identifier> [= <expression>] ;
<block_statement> → { <statement_list> }
<statement_list> → <statement> |
<statement_list> <statement>
Nested Loop:
Program Loop | Statement
Loop For_Loop | While_Loop |
Do_While_Loop
For_Loop for (“ For_Init ; For_Condition ;
For_Update”) Nested_Loop
While_Loop while (”expression” )
Nested_loop
Do_while_Loop do Nested_Loop while
( expression ) ;
Nested_Loop Loop | Statement
For_Init Expression_Statement |
Variable_Declaration | ε
For_Condition Expression | ε
For_Update Expression_Statement | ε
Expression_Statement Expression ;
Variable_Declaration Data_Type Identifier [=
expression] ;
Statement Expression_Statement |
Declaration_Statement | If_Statement |
While_Statement | Do_While_Statement |
For_Statement
If_Statement If ( expression ) Nested_Loop
[else Nested_Loop]
While_Statement While ( expression )
nested_loop
Do_While_Statement do Nested_Loop while
( expression ) ;
For_Statement for ( For_Init ; For_Condition ;
For_Update ) nested_loop
Expression Literal | Identifier | Expression
Binary_operator Expression | Unary_Operator
Expression | ( Expression )
Literal Integer_Literal | Double_Literal |
Char_Iiteral | Boolean_Literal | String_Literal
Integer_Literal digit+
Double_Literal digit+ . digit+
Char_Literal
'any_character_except_single_quote'
Boolean_Literal true | false
String_Literal "any_sequence_of_characters"
Data_Type int | double | char | boolean | String
Identifier Letter Identifier_Tail
Identifier_Tail Letter_or_Digit Identifier_Tail |
ε
Letter a | b | c | ... | z | A | B | C | ... | Z | _
Letter_or_Digit Letter | Digit
Digit 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
Binary_Operator + | - | * | / | % | == | != | | | = |
= | && | ||
Unary_Operator - | !