November 4th, 2012, 01:21 PM
Help me:Programing languague
Imagine you have a small Robot that you need a way to communicate with, you decide to make a language for such robot, the language would instruct the Robot to move forward and backward by specifing number of steps (units), also you can instruct the Robot to turn left or right by specifing a number that represents the degrees. The following lists are what you need to do ?
1) a winword document that has the BNF language for such language.
2) some text files that represents some programs written in such language.
3) a C source code that analyze the program ( lexical analyzer and syntax analyzer) for such language
November 4th, 2012, 01:38 PM
Cool! Sounds like a fun assignment! Show us what you've done so far!
November 4th, 2012, 02:20 PM
You will presumably have attended some classes/lectures already and been provided appropriate course materials and text? That being the case - carry on! We have not had the benefit of those classes or materials.
The question is not entirely within the domain of this forum. When you get to part three and have a specific problem, let us know and someone might be able to help. However by the time you have done (1) and (2), (3) should be fairly straightforward.
I think the requirement can be met by just two commands, with each command takes a single signed integer value. It is probably far simpler that you are perhaps thinking.
Since the specification states that the arguments to "move" and "turn" (or whatever you choose to call your commands) are numbers rather than expressions the design and implementation are rather simple. An expression evaluator would complicate things somewhat, but it seems not to be required here.
Last edited by clifford; November 4th, 2012 at 02:23 PM.
November 4th, 2012, 02:43 PM
Mmmm, small robot and "move commands".
Sounds like logo
November 4th, 2012, 03:17 PM
Or Karel, a book that taught programming through the programming of a robot. Though I think the original was based on Pascal, but then in Karel++ they switched to C++. I think it was named after Karel Čapek, the playwright of the classic 1921 Czech sci-fi play, Rossum's Universal Robots, which spawned the term "robot" ("robot-" is the Slavic root for "work", as in the Russian verb "robotat' ", "to work" ).
Originally Posted by salem
November 4th, 2012, 03:20 PM
I agree Clifford; this is a classic example of a 'turtle'. In its original form, the turtle was a physical device that rolled along the floor; by the 1970s, a 'virtual' turtle was commonly used in Logo and it's relatives. Even today, some languages (such as Python) include a ''turtle graphics' package.
For both implementation and use techniques, the textbook Turtle Geometry is an under-appreciated classic. There's a good chance you can find a copy in some dusty corner of your university library; if not, a copy of it is only US$45 ($65 if you get Mindstorms as well, another classic on the subject, which covers the use of turtle graphics in teaching for young children).
As for writing a compiler or interpreter, you may want to look at this thread for some advice and useful links (though some of the links are now stale, sadly).
Last edited by Schol-R-LEA; November 4th, 2012 at 03:24 PM.
November 4th, 2012, 03:27 PM
i have exams and i don't have time to do these home work......
help me please...
Comments on this post
November 4th, 2012, 03:52 PM
OK, I'll help you. Here it is: Find a different major.
1. We help people with their homework. Doing it for them would not be helping them.
2. When you take somebody else's work and turn it in as your own, you are committing plagiarism. Committing plagiarism gets you expelled from your school, ending your academic career. Aiding and abetting your commission of plagiarism would not be helping you.
Do your work and get back to us with questions about problems that you encounter in doing your own work.
Comments on this post
November 4th, 2012, 05:46 PM
You might try Flex and Bison (google is your friend) to help you generate the C source for your scanner and parser. If you understand CFGs and the like then you should be able to pick up on how to use Bison fairly quickly.
Originally Posted by waleedsafi
November 5th, 2012, 03:58 PM
All this talk of Logo and Turtle Graphics etc. is all valid but probably over complicating the issue. This is a very simple subset of a turtle like language, and Logo is so much more than just turtle graphics. The language in question is not a Turing complete language and Flex and Bison etc. are probably unnecessary for this task.