[this should move to emc-developers, which is why I'm cc'ing there]

it just occured to me that a decent parser would give us the opportunity for a 
significant language simplification while retaining backwards compatibility.

An example for the current RS274NGC language with variable references, 
expressions and control structures:

----------------------
#<var1> = [#<foo> + 1]
#<var2> = 10

o#<label1> if [#<var1> lt #<var2>]
    .... 
o#<label1> else
    ....
o#<label1> endif
----------------------

Note the pathetic amount of syntactic noise - wouldnt it be more readable to 
write:

----------------------
$var1 = $foo + 1
$var2 = 10

if $var1 < $var 2
        ...
else
        ...
endif
----------------------

We have several noise chars per variable (#<>), useless labels including noise 
(o#<label1>) which do not help in disambiguating, and useless brackets around 
expressions, plus, well, fortranesque operators

now the major reason why this is so is that the current scanner only does 
lookahead 1 character, and the parser is inadeaquate; if even Perl can do it, 
so should RS274NGC

A combination of a say flex scanner, bison parser should be able to parse both 
examples unambiguously. Moreover, it should tell during the bison run wether 
there are any ambiguities or conflicts when such a language simplification is 
introduced - it would give a reduce/reduce message. For instance, one could 
experiment wether the '$' as variable introducer is actually necessary (it 
probably is due to ambiguities with words in a block).

I understand this is quite different from you pretty printer/lint goal

If we were to go about this, I think the way to do this is:

- have both parsers as alternatives
- add a flag to sai/rs274 to parse a file with old and new parser
- compare outputs for regression tests
- when it is clear that no ambiguities are left, move it to mainline as the 
default parser

- Michael


------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
_______________________________________________
Emc-developers mailing list
Emc-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-developers

Reply via email to