eidalina20
March 2nd, 2008, 12:08 AM
hey guys.. i am reading about grammar here and came across this statement.. can someone please help me answer a couple of questions based on this??
A regular expression over {0, 1} can be the empty string EMPTY, or the symbols 0, or 1. Additionally, if A and B are regular expressions, then so are A|B, A.B, (A) and A* with * having the highest precedence, followed by left-associative . followed by left-associative |. Parentheses can be used to override the default precedence.
1. can someone please give a grammar for the above regular expressions which enforces the associativity and precedecence of the above operators.
2. Based on the grammar from 1st part, give the parse tree for (0|1)*.0.
3. and this one: give a AST for (0|1)**.0.
thanks
A regular expression over {0, 1} can be the empty string EMPTY, or the symbols 0, or 1. Additionally, if A and B are regular expressions, then so are A|B, A.B, (A) and A* with * having the highest precedence, followed by left-associative . followed by left-associative |. Parentheses can be used to override the default precedence.
1. can someone please give a grammar for the above regular expressions which enforces the associativity and precedecence of the above operators.
2. Based on the grammar from 1st part, give the parse tree for (0|1)*.0.
3. and this one: give a AST for (0|1)**.0.
thanks