3
Contributors
8
Replies
9
Views
10 Years
Discussion Span
Last Post by Lun
0

BNF is a way of describing the grammar for the language.

It it not a means of describing random program snippets such as this.

You might begin with <assignment> ::= <variable> "=" <expression>

0

thanx..

i did it that way but i guess something is wrong with my code... it doesn't want to run when i put something like x=1 or either x=x+1

0

i have this program with me that i programmed but i am just stuck... i don't really know where it went wrong..... and it's my first time to program in c++... would you like to look at the code?

0

>would you like to look at the code?
This just slows down the process. Post your code, tell us what errors you're getting, and someone will get to it. "Will you look at the code?", "Can anyone help?", etc.. will invariably be answered with "Yes! Ask already!", so why not skip that part and just ask your question?

0

I'm confused as to where 'bnf' fits into the discussion.

If you have some C++ code, then just post it already and stop with the 1 or 2 line posts which don't convey any information that anyone else could use to help you.

0

help!! do i need to change to get x=1.....?

//<ass>-><var>=<expr>
void assignment()
{
 if(nextToken == VARIABLE_TOK)
 {
  lex();
  if(nextToken==EQUAL_TOK)
  {
   lex();
   logical_expr();
   if(nextToken==END_STMT_TOK)
   {
    cout << "end statement: ok"<< endl;
    cout << END_STMT_TOK<< endl;
   cout << "assignment function: ok"<< endl;
   }
    else cout <<"put an end stmt ."<<endl;
  }
    else cout << "invalid it should be = operator only!"<< endl;
 }
  else cout << "invalid it should be variable only!"<< endl;
}
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.