Compiler Construction Project

See Project On Git Hub

This project has been upgraded to Sementic Analyzer

Download Complete Project V.1

 

After the Following test source code on Demo.etcl

 

It would produce the following output

LANGUAGE SPECIFICATION

 

  1. LANGUAGE NAME: ETC (Easy To Code)
  2. DATA TYPES:

 

VALUE PART SYNTEX EXAMPLES CLASS PART
var

 

Var a = constant Var a = 2; DT
var var f = constant Var c = 3.3; DT
  var

 

Var c = constant _efg34 = ‘c’; DT
  var

 

Var s = constant _klm098 = “string”; DT

 

  1. LOOPS
VALUE PART SYNTEX EXAMPLES CLASS PART
For For(exp;cond;exp){code} For(var i =0 ; i<25;i++){I+2;} For
while while(cond){} While(i<2){} While
Do do Do{}While do

 

 

  1. CONDITIONAL STATEMENTS:
VALUE PART SYNTEX EXAMPLES CLASS PART
if If(ocnd) If(i < 2){} IF
switch Switch(variable){case:2; break;} Switch(opr){case 1:} SW

 

  1. OPERATORS:
    • AIRTHMATIC:
VALUE PART CLASS PART
+ ADD_SUB
ADD_SUB
\ MUL_DIV_MOD
* MUL_DIV_MOD
% MUL_DIV_MOD

 

 

 

 

  • INCREMENT/DECREMENT:
VALUE PART CLASS PART
INC_DEC
++ INC_DEC
  • ASSINGMENT:
VALUE PART CLASS PART
= ASS_OP
+= ASS_OP
-= ASS_OP
/= ASS_OP
*= ASS_OP
  • LOGICAL:
VALUE PART CLASS PART
&& LOGICAL_OP
|| LOGICAL_OP
  • RELATIONAL:
VALUE PART CLASS PART
< REL_OP
> REL_OP
== REL_OP
!= REL_OP
<= REL_OP
>= REL_OP

 

  1. PANCTUATORS:
VALUE PART CLASS PART
. .
; ;
, ,
( (
) )
{ {
} }
\ \

 

  1. CONSTANTS:
VALUE PART R.E DFA CLASS PART
3 d* Int_cons
4.44 D**dot*d+ Float_cons
‘c’ (INV_COMA)+(l+(BK_SLASH*l))+ (INV_COMA) Char_cons
“string” “+(l+(\*l))*+ “ String_cons

 

  1. IDENTIFIERS/VARIABLES:

7.1. Letters

e.g: aaa

7.2. Letters then digits

e.g: abc1.

7.3. Underscore then letter then digits

e.g:  _a1

 

R.E:

_* l+ d*

D.F.A:

VARIABLE INITILAZTION ONLY:

e.g: int aaa;

R.E:

D.F.A:

VARIABLE INITILAZATION AND DECLARATION:

e.g: int a=10;

 

VARIABLE DECLARATION ONLY:

e.g: aaa=20;

STATEMENT TERMINATOR:

STATEMENT TERMINATOR SYMBOL CLASS PART
; ;

COMMENT:

COMMENT SYMBOL CLASS PART
// Single_line_comment
/* */ Multi_line_comment

MORE:

KEY WORDS CLASS PART
break BREAK
case CASE
main MAIN
void VOID
class CLASS
Function FUNCTION
virtual virtual
rules rules
Import Import_export
export Import_export

 

Access Modifiers CLASS PART
public Acc-Mod
private Acc_Mod

 

Starting Point

Function main (){

 

}

Function

Function ID(){

 

}

Class ID

{

 

}

 

NOTE:

1.       Since data types belong to same class and all data types have same syntax, we don’t need separate ‘class part’ name for it, just give one name to all data types( e.g. int,float,char all will have class part name ”Data_type”)

2.        Operators are defined in categorize for your understanding, if your language have more operators than mentioned above add them in your documentation.

3.       Identifiers/variables examples and their R.E/D.F.A are given for understanding purpose, add your own set of examples as per your compiler requirement (as well as R.E and D.F.A too).In given example compiler can accept three cases; only letters, letters then digits and underscore then letters and then digits. But their R.E and D.F.A is one which implements all 3 cases.(Left this part for now, we will do in next lab)

4.       This template is for basic understanding, feel free to add/modify or change things as per your language requirements (if you want to add any description add it too).

5.       Take class part in capital letters for easiness in future use.

 

 

 

 

    

Advertisements