Click here to Skip to main content
16,007,687 members
Please Sign up or sign in to vote.
1.67/5 (3 votes)
See more:
Hello everyone
I need a little help here
i got a simple source language with simple rules
the general look of the program

Program my-prog; // any program start with the keyword program

var // just one time to start stating the variables

x:datatype // this part is for intial variables

X,y:datatype // for two varibles

Begin // now we start the dosy of the program

.
.
.
.
End

the Instructions

1- if(condition) then

statment; // one instruction only

2- if(condition)

Begin
statment1;
statment2;
End

else

Begin
.
.
.
End // in case of more than one instruction

3- while(condition) do
Begin
.
.
.
End

4- for counter=val1 to val2 do
Begin
.
.
.
End

5- var_name := exp;

6- read(x); // for reading x is a variable
7- readln(x);
8- write(exp);
9- writeln(exp);

there is a ready functions in this language such as:

sin, cos, tan, square, sqrt, max, min.

mathimatical things:

+, +=, -, -=, *, *=, /, /=

comparing things:

>, <, <=, >=, =, !=


first step is the lexical analysis which read a stream of characters and returns tokens

then semantic analysis

If anyone can help it would be cool otherwise thanks
Posted

You should read books to perform this task. Compiler construction is a broad (and deep) topic.
You may start writing the lexical analyzer and ask specific questions when you are stuck.
:)
 
Share this answer
 
I hope you can read more about IronPython, ToyScript, and DLR. This might be handy and easy to start. Also, if you can’t make a compiler then don’t take that project and if you have taken it then work on it. Don’t look for easy solutions. What will you do if you will face similar situations in your professional life too?
 
Share this answer
 
I have to agree with CPallini here. A simple command processor can be challenging enough; a full-fledged compiler (based on Pascal? Oy, does that bring back memories) is a non-trivial undertaking by any stretch.

There are year-long college classes that cover this topic. It is not something that you can learn by browsing the net, I'm afraid.
 
Share this answer
 
Hello
thank you all for replying my quastion
i don't have the option to reject the project it's from the colleage admin
and i started it and finish the lexical analysis but it's not workin at all and the supervisoer refused to see it because i wrote it in java and she want it in c# and she said i want the lexical analysis next week workin or she will cut it from my final grade
that is the pb and why i'm searching for easy solution
thanks all tc
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900