Link to home
Create AccountLog in
Avatar of deucalion0
deucalion0

asked on

Can anyone provide advice on how to write programs using an EBNF?

Hey all, I have an assignment to complete for university, I don't want the answers, just some advice and assistance if possible. I have been provided an EBNF from which I need to build a compiler which should include parsing and semantic analysis. The whole thing needs to be encapsulated within a command-line application.

I am confused about how to start this, I have actually struggled a lot with this class and every week I seem to get more and more confused, so any help at all would be great. I have kept this question short, no code etc.. as I wanted to see which kind of assistance was available at EE first.

Many thanks for your time!
ASKER CERTIFIED SOLUTION
Avatar of David L. Hansen
David L. Hansen
Flag of United States of America image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of deucalion0
deucalion0

ASKER

sl8rz, thank you so very much! I promise my aim is to learn here, it is very important I actually start to understand this subject. Having an example to look at and get to grips with will be a tremendous aid in helping me see exactly how all this comes together!

I shall l have a look and get back to you on how I found it!

Thank you again, I appreciate your help!
As I've researched BNF concepts today, I've learned that BNF is similar to regular expressions.  "Regular expressions," is a fast and lean tool that helps you match strings; however, it is a bear to deal with...you feel like you are writing machine code.  BNF just takes the regex concept a bit further by giving you a way to actually define the language you want.  So say you only want to be looking for numerics in a huge string of data.  Perhaps you just want to find where 3.14159 is in the file and how many times it occurs.  You could use regex for this but with a little BNF magic you could build your own parcer/matcher in just a minute.  You could use C# to deal with it in a more traditional approach (looping, etc.) but that would take a lot more code and would be far slower.

Just some thoughts.