If it is of any interest I could send you an experimental parser I 
wrote a decade ago that uses Sprit++ (a C++ template tool, part of 
Boost.org now, which replaces bison and flex, and reads like EBNF).  At 
that time I was experimenting with runtime polymorphic parsers (which 
would allow you to overload the language description and support 
different interpretations of the rs274*...

   EBo --

On Wed, 1 Feb 2012 00:10:04 +0100, Michael Haberler wrote:
> [I guess this better belongs here]
>
> ok, while this wonderful discussion was raging on, I built a working
> parser for the current linuxcnc dialect, as an experiment in
> feasability (this is NOT an end-user tool!)
>
> 
> http://git.mah.priv.at/gitweb/emc2-dev.git/shortlog/refs/heads/parser-v2-dev
>
> - Michael
>
> ps: I'd appreciate feedback from language geeks wrt to removing
> shift/reduce conflicts.
>
> -------------- src/emc/parser-v2/README: --------
>
> RS274NGC parser based on Bison/Flex
> ===================================
>
> usage:
>
> parser [options] ngcfile ...
>
> example:
> $ parser emc2-dev/nc_files/*.ngc
>
> no output means good news (parse ok)
> other that that, no actions - this is an experiment to find out
> wether this is feasible
>
> options are:
> -v: create listing with interspersed error messages
> -s: trace scanning
> -p: trace parsing
>
> I'd be grateful for hints how to remove the remaining shift/reduce
> conflicts in the grammar. I guess there's something wrong/missing 
> with
> operator precedence and/or associativity.
>
> Error messages
> --------------
> There are no custom error messages yet. All error messages are
> autogenerated from the parser, and derived from the grammar, 
> including
> the set of permitted tokens, which is already quite reasonable:
>
> $ parser -v emc2-dev/src/emc/parser-v2/ngc/foo.txt
>
> ...
> #<bar> = [EXISTS[23
> -----------------^^
> ngc/foo.txt:8:unexpected integer, expecting #
> ...
> m73.1
> ---^^
> ngc/foo.txt:18:unexpected real, expecting one of: <<EOF>> EOL ^ @ %
> if while break do repeat sub endsub return call # G-code M-code A B C
> D E F H I J K L P Q R S T U V W X Y Z
> ...
> N3242 G10 x[1
>
> ^
> ngc/foo.txt:24:unexpected EOL, expecting one of: ] EQ NE GT GE LT LE
> and or xor + - * / mod pow
> ...
> N3242 G10 x[1]]
> --------------^
> ngc/foo.txt:25:unexpected ], expecting one of: <<EOF>> EOL ^ @ % if
> while break do repeat sub endsub return call # G-code M-code A B C D 
> E
> F H I J K L P Q R S T U V W X Y Z
> ..
> 4 error(s)
>
> Error recovery:
> ---------------
>
> currently, on syntax error the parser skips to the next of line, and
> continues, which seems to work ok.
>
> Build notes
> -----------
> All files needed to compile are in this branch
> If you change the grammar: bison 2.5 is needed (Ubuntu 10.04 has
> 2.4.1 which is too old)
> I compiled from source - found no backport.
> Flex: the stock flex coming with 10.04 is fine (flex 2.5.35)
>
> Speed is quite good - without spending a thought on optimization and
> all debug options on, this parser does about 300.000 lines/second on 
> my MBP.
>
> added Submakefile
>
> base taken from https://idlebox.net/2007/flex-bison-cpp-example/
> much of that example code is still to be deleted but then this is
> a proof of concept
>
> -mah
> 
> ------------------------------------------------------------------------------
> 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-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/emc-users
>
>
> 
> ------------------------------------------------------------------------------
> 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
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/emc-developers


------------------------------------------------------------------------------
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/emc-developers

Reply via email to