3 ms·
In BASIC the equal symbol "=" can mean assignment or equality depending on "context". Is this an example of a non context free? On the other hand, I've seen EB
by signaru 6y ago
In BASIC the equal symbol "=" can mean assignment or equality depending on "context". Is this an example of a non context free?
On the other hand, I've seen EBNF definition of BASIC (VB, actually). Is this a contradiction?
(just someone still learning)
- foldr 6y agoA context free grammar can handle this fine - as you can see from the EBNF - so no, it's not an example.
- kyllo 6y agoIt's still context-free, the reason is because by the time you hit the '=' symbol you already know whether you're in a <Statement> or a <Compare Exp> production rule, based on the preceding symbols (namely the LET keyword), based on these excerpts from the BASIC EBNF: <Statement> ::= CLOSE '#' Integer | DATA <Constant List> [...] | LET Id '=' <Expression> [...] | Remark <Compare Exp> ::= <Add Exp> '=' <Compare Exp> | <Add Exp> '<>' <Compare Exp> | <Add Exp> '><' <Compare Exp> | <Add Exp> '>' <Compare Exp> | <Add Exp> '>=' <Compare Exp> | <Add Exp> '<' <Compare Exp> | <Add Exp> '<=' <Compare Exp> | <Add Exp>