The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,High School,College,University
| Teaching Since: | Apr 2017 |
| Last Sign in: | 360 Weeks Ago, 1 Day Ago |
| Questions Answered: | 6064 |
| Tutorials Posted: | 6070 |
Doctor of Education in Educational Leadership with a Specialization in Educational Technology
Phoniex University
Oct-1999 - Nov-2005
HR Executive
a21, Inc.
Nov-1998 - Dec-2005
Write a set of BNF grammar rules that will parse a programming language that can have variable type declarations such where the variable has name and a type which can be either integer or boolean, and optionally has a constant default value:
E.g.
var i : integer;
var j : integer = 6;
var b : boolean;
var b2 : boolean = true;
var b3 : boolean = false;
Â
2.
Show an example of why the following grammar is Ambiguous.
<program> Â Â Â Â Â -> <stmts>
<stmts> Â Â Â Â Â Â Â -> <stmts> ; <stmts> | <assignment>
<assignment> Â Â Â -> <var> = <expr>
<var> Â Â Â Â Â Â Â Â Â -> a | b | c | d
<expr> Â Â Â Â Â Â Â Â -> <term> + <term> | <term> - <term>
<term> Â Â Â Â Â Â Â Â -> <var> | const
Sol-----------uti-----------ons----------- fi-----------le ----------- He-----------llo----------- Si-----------r/M-----------ada-----------m -----------Tha-----------nk -----------you----------- fo-----------r y-----------our----------- in-----------ter-----------est----------- an-----------d b-----------uyi-----------ng -----------my -----------pos-----------ted----------- so-----------lut-----------ion-----------. P-----------lea-----------se -----------pin-----------g m-----------e o-----------n c-----------hat----------- I -----------am -----------onl-----------ine----------- or----------- in-----------box----------- me----------- a -----------mes-----------sag-----------e I-----------