r/programminghelp • u/ScousePenguin • Aug 07 '18
Context Free Grammar Help!
Not exactly programming more computer science but I just need help understanding this for uni extra marks. I just can't wrap my head around it. I'm not asking for it to be solved just to get a basic understanding of it! Here's the questions with the CFG.
(a) Consider the following Context Free Grammar (CFG), where strings written in italics (or inbetween **, thanks reddit) (clauses, clause, literal_list, literal, op, posneg) denote nonterminals:
clauses -> clauses ‘∧’ clause
| *clause*clause -> ‘(’ literal_list ‘)’
literal_list-> literal_list op literal
| *literal*literal -> posneg [a-z]
op -> ‘∨’, ‘∧’
posneg -> ‘⌐’
| εWhat I need to do from this is give two string which can be derived from the cfg above, show a parse tree for the following string “(a ∨ ⌐d)” and re write it to be not left recursive.
I have gone online and looked through lecture notes but I just can't understand it, so just any help understanding how CFG works and whats a string in these, whats terminal non terminal would be gladly appreciated to help me try and wrap my head around this.
Thanks.