Solved

problem with coding BNF

Posted on 2003-10-23
5
176 Views
Last Modified: 2010-05-18
hi all,

i have problem with coding BNF, so can any body help me with that
i want just small subprogram that chech the syntax error

example of BNF rule:
<program> -><stmts>
<stmts> -> <stmt>|<stmt>;<stmt>
<stmt> -> <var>=<expr>
<var> -> a | b | c | d
<expr> -> <term>+<term>|<term>-<term>
<term> -> <var> | const

where the symbol between< > represent non-terminal rule and other like +, -, = , ;, a, b, c, and d represent terminal symbols and | means OR option.......

this BNF could give such statement like a=b+const

the program should check whether the statement correct or not?

thank you
0
Comment
Question by:badr1981
  • 2
  • 2
5 Comments
 
LVL 15

Accepted Solution

by:
jimmack earned 50 total points
ID: 9606637
Post the code you have written so far, then ask for help with the problem area.
0
 

Author Comment

by:badr1981
ID: 9606684
i have not solve this quastion, i am working in large project and this subprogram that i face problem with it..... i don't know how to implement a BNF in java
0
 

Expert Comment

by:PaulFranz
ID: 9608199
I would use JavaCC it will do this for you.
0
 

Author Comment

by:badr1981
ID: 9610847
how can i use JavaCC for this, i don't have any idea about JavaCC....

can you provide me with more informations about that

thank you
0
 
LVL 15

Expert Comment

by:jimmack
ID: 9610868
Just in case PaulFranz isn't available at the moment, search for JavaCC on google.  There's a few links there.
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
The viewer will learn how to implement Singleton Design Pattern in Java.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now