Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [cdt-dev] LR parser and LPG version

Well.... the LR C++ parser passes like 99% of the parser test suites, which shows that using a parser generator for C++ isn't necessarily a bad idea. Of course I had to use some clever trickery in a few places to get it to work. The real star of the show in my opinion is CDT's ability to resolve ambiguity nodes in the AST, this is that makes using a parser generator for C++ possible. In my experience trying to resolve ambiguities during the parse is a dead end, but deferring the resolution until after the parse works very well. The DOM parser uses the same approach so this also helps when the parser is hand written.

In the end there's a tradeoff; the DOM parser is more accurate and has a few extra features, but the LR parser is (in theory) easier to extend by third parties. Your milage may vary.


Mike Kucera
Software Developer
Eclipse CDT/PTP
IBM Toronto
mkucera@xxxxxxxxxx

Inactive hide details for Doug Schaefer ---03/03/2010 11:19:52 AM---You presume too much ;). C++ is a horrible language to writDoug Schaefer ---03/03/2010 11:19:52 AM---You presume too much ;). C++ is a horrible language to write a parser for. gcc itself has switch away from using a parser gener


From:

Doug Schaefer <cdtdoug@xxxxxxxxx>

To:

"CDT General developers list." <cdt-dev@xxxxxxxxxxx>

Date:

03/03/2010 11:19 AM

Subject:

Re: [cdt-dev] LR parser and LPG version




You presume too much ;).

C++ is a horrible language to write a parser for. gcc itself has switch away from using a parser generator and have handcoded their parser. Other languages are easier and make more sense for LPG, ANTLR, Xtext, bison, etc. C++, not so much.

On Wed, Mar 3, 2010 at 11:11 AM, Mike Wrighton <mike.wrighton@xxxxxxxxxxxxxx> wrote:
    Thanks. I was also wondering if anyone knew why CDT still uses the hand-written parser (6.0.1, anyway) when the generated parsers are presumably faster and the code more maintainable?


    On 3 March 2010 15:48, Mike Kucera <mkucera@xxxxxxxxxx> wrote:
    Its easiest to get the LPG 1.1 runtime from Orbit. Find the org.eclipse.orbit folder in CVS and check out the net.sourceforge.lpg.lpgjavaruntime project. The project will initially be empty, right click on the project and select Team > Switch to another branch or version, then select the v1_1 branch. That will give you a project with all the source for LPG 1.1 in your workspace, which is very useful.

    Alternatively I think you can download the runtime as a plugin jar from the orbit page on
    eclipse.org and just drop it in your plugins folder. The sourceforge page provides the runtime as a normal jar file, but its the orbit project that provides a plugin wrapper for the jar so that it can be used easily with eclipse.

    I'm getting enough requests for documentation for the LR parser that I think I'm going to have to start writing some :)




    Mike Kucera
    Software Developer
    Eclipse CDT/PTP
    IBM Toronto

    mkucera@xxxxxxxxxx

    Inactive hide details for Mike Wrighton ---03/03/2010 10:35:17 AM---Hi,Mike Wrighton ---03/03/2010 10:35:17 AM---Hi,


    From:

    Mike Wrighton <mike.wrighton@xxxxxxxxxxxxxx>

    To:

    "CDT General developers list." <cdt-dev@xxxxxxxxxxx>

    Date:

    03/03/2010 10:35 AM

    Subject:

    Re: [cdt-dev] LR parser and LPG version




    Hi,

    I was just wondering if there are any instructions for using the LR
    parser, for example where do I get net.sourceforge.lpg.lpgjavaruntime?
    I downloaded the org.eclipse.cdt.core.lrparser plugins from CVS and
    the LPG distribution zip, as well as some code from

    lpg.cvs.sourceforge.net but I'm a bit lost as I can't find a bundle
    called net.sourceforge.lpg.lpgjavaruntime.

    Thanks,
    Mike


    On 2 March 2010 14:43, Mario Pierro <
    Mario.Pierro@xxxxxxx> wrote:
    > Hello,
    >
    > I am experimenting with extending the new LR parser to recognize custom
    > extensions to the CDT language.
    >
    > I can successfully build and run the checked out java files, but I am
    > not able to correctly generate them from the .g grammar files - the
    > files will contain syntax errors.
    >
    > I checked out the following plugins from CVS
    >
    > net.sourceforge.lpg.lpgjavaruntime
    > org.eclipse.cdt.core.lrparser
    > org.eclipse.cdt.core.lrparser.sdk
    > org.eclipse.cdt.core.lrparser.sdk.feature
    > org.eclipse.cdt.core.lrparser.tests
    >
    > I also downloaded the LPG 1.1 distribution from sourceforge
    >
    >
    http://sourceforge.net/projects/lpg/files/lpgdistribution/LPG-V1.1/lpgdi
    > stribution-05-16-06.zip/download
    >
    > in order to obtain the parser generator executable (lpg.exe).
    >
    > I have set up the lpg_exe and lpg_template ant properties to point to
    > the lpg.exe and the org.eclipse.cdt.core.lrparser/grammar/templates
    > folder, respectively.
    >
    > I can run the build.xml script and generate the java sources, but the
    > files created will contain syntax errors (like a "-a" instead of a "-1"
    > in parser tables). I have also tried to use the lpg executables 2.0 but
    > they will generate even more errors.
    >
    > What is the lpg version which has been used to build the parser sources
    > in the lrparser plugin?
    >
    > Thanks for your help,
    >
    > /Mario
    >
    > _______________________________________________
    > cdt-dev mailing list
    >
    cdt-dev@xxxxxxxxxxx
    >
    https://dev.eclipse.org/mailman/listinfo/cdt-dev
    >
    _______________________________________________
    cdt-dev mailing list

    cdt-dev@xxxxxxxxxxx
    https://dev.eclipse.org/mailman/listinfo/cdt-dev



    _______________________________________________
    cdt-dev mailing list

    cdt-dev@xxxxxxxxxxx
    https://dev.eclipse.org/mailman/listinfo/cdt-dev



    _______________________________________________
    cdt-dev mailing list

    cdt-dev@xxxxxxxxxxx
    https://dev.eclipse.org/mailman/listinfo/cdt-dev
_______________________________________________
cdt-dev mailing list
cdt-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/cdt-dev


GIF image

GIF image


Back to the top