Zbyszek schrieb am Mittwoch, 27. Januar 2010 um 20:54:55 UTC+1:
Is there any? I cannot find it with Google.
Z.
First of all: M is a language based on indentation, like python. Indentation-languages are very difficult to handle
in compiler-science because they are Chomsky-Type 0 or 1, i don't now exactly.
If you want to write a parser you'll have to do a little trick based on the compiler-phases introduced by Aho Sehti Ullman, see
https://www.tutorialspoint.com/compiler_design/compiler_design_phases_of_compiler.htm
- The scanner maintains the indentation, he delivers indentation-changed-tokens to the parser instead of indentation-tokens
Now (from parser's point of view) the token-stream is in fact Chomsky-Type-2 (context-free). The rest will do the symbol-table.
But now this type-2-grammer is no more the original type-0-grammar. (Annotation: Same problem is markdown, you'll find nowhere a markdown-grammer, an if: let me know!)
Next problem: In M each statement is a pair of
- statement
- argument (can be empty)
and there may be name-conflicts which have to be maintained by the scanner too. Code like
if if do:do do go:go go
(do 1 is a statement, do 2 is a variable, do 3 is a label, analog the three go) is possible, this is never possible in python or i think in any other language.
As a consequence: In my opinion a "normal" BNF / EBNF will not be possible.
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)