Parser Generator

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

Parser Generator

Torsten Bonde Christiansen
Hi.

I am currently looking into integrating a custom language parser into my program and have been
searching the web for parser generators that can create Pascal code from a custom language.

So far in my search i have found the following "options":

* GOLD Parser: http://www.goldparser.org/
Was last updated in sept. 2012 and the lastest pascal implementation is not for the lastest version of the program!

* COCO/R: http://www.ssw.uni-linz.ac.at/Research/Projects/Coco/
Same as with the GOLD parser - last updated in 2014 and lastest pascal implementation is for an older version of the program.

* TP Yacc/Lex: (included in Free Pascal)
Is included with Free Pascal, but the generated code is non-OO, and seems to rely on text-files for input.

So if there is anyone out there who knows of such a generator I would be glad to know.

Kind regards,
Torsten Bonde Christiansen.


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Parser Generator

leledumbo
Administrator
> I am currently looking into integrating a custom language parser into my
> program and have been
> searching the web for parser generators that can create Pascal code from
> a custom language.

No parser generator that I know includes a code generator, you must write that part yourself at least. I would write a handwritten transpiler instead, though. Easier maintenance and maximum flexibility, no rules or restrictions as imposed by every parser generator implementations. At the worst, I would pick Coco/R since it generates a recursive descent parser instead of table driven one, still possible for hand editing.
Reply | Threaded
Open this post in threaded view
|

Re: Parser Generator

Marc Santhoff-2
In reply to this post by Torsten Bonde Christiansen
On Do, 2016-05-19 at 13:10 +0200, Torsten Bonde Christiansen wrote:

> * GOLD Parser: http://www.goldparser.org/
> Was last updated in sept. 2012 and the lastest pascal implementation is
> not for the lastest version of the program!
>
> * COCO/R: http://www.ssw.uni-linz.ac.at/Research/Projects/Coco/
> Same as with the GOLD parser - last updated in 2014 and lastest pascal
> implementation is for an older version of the program.
>
> * TP Yacc/Lex: (included in Free Pascal)
> Is included with Free Pascal, but the generated code is non-OO, and
> seems to rely on text-files for input.
>
> So if there is anyone out there who knows of such a generator I would be
> glad to know.

There is a german learning programm named AtoCC. It can generate Object
Pascal Code:

http://www.atocc.de/cgi-bin/atocc/site.cgi?lang=en&site=main

Sorry, I had no time to test it yet.

Marc


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Parser Generator

Mark Morgan Lloyd-5
Marc Santhoff wrote:
> On Do, 2016-05-19 at 13:10 +0200, Torsten Bonde Christiansen wrote:
>
>> * GOLD Parser: http://www.goldparser.org/

>> * COCO/R: http://www.ssw.uni-linz.ac.at/Research/Projects/Coco/

>> * TP Yacc/Lex: (included in Free Pascal)

> http://www.atocc.de/cgi-bin/atocc/site.cgi?lang=en&site=main
>
> Sorry, I had no time to test it yet.

"For target code generation you need to specify code fragments for each
rule in VCC."

I think the important thing for all of these is that they still assume a
lot of hard work from the person defining the custom syntax. They're not
a magic bullet.

For the last 30 years or so I've been using a compiler compiler
originally written in 1964, the implementation has matured as different
pascal compilers have become available. I'm not suggesting that this is
usable in the general case, but looked at objectively it does allow me
to make gross behavioural changes fairly easily, e.g. to define novel
string properties and to embed pragmata in comments.

--
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Parser Generator

Carlo Kok-2
In reply to this post by Torsten Bonde Christiansen


On 2016-05-19 13:10, Torsten Bonde Christiansen wrote:

> Hi.
>
> I am currently looking into integrating a custom language parser into my
> program and have been
> searching the web for parser generators that can create Pascal code from
> a custom language.
>
> So far in my search i have found the following "options":
>
> * GOLD Parser: http://www.goldparser.org/
> Was last updated in sept. 2012 and the lastest pascal implementation is
> not for the lastest version of the program!
>
> * COCO/R: http://www.ssw.uni-linz.ac.at/Research/Projects/Coco/
> Same as with the GOLD parser - last updated in 2014 and lastest pascal
> implementation is for an older version of the program.
>
> * TP Yacc/Lex: (included in Free Pascal)
> Is included with Free Pascal, but the generated code is non-OO, and
> seems to rely on text-files for input.
>
> So if there is anyone out there who knows of such a generator I would be
> glad to know.
>

It's been my experience that all the compiler compilers have one or more
flaws that make it more work in the end to use them than to just write a
parser by hand.


--
Carlo Kok
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Parser Generator

Marc Santhoff-2
In reply to this post by Mark Morgan Lloyd-5
On Fr, 2016-05-20 at 08:38 +0000, Mark Morgan Lloyd wrote:

> Marc Santhoff wrote:
> > On Do, 2016-05-19 at 13:10 +0200, Torsten Bonde Christiansen wrote:
> >
> >> * GOLD Parser: http://www.goldparser.org/
>
> >> * COCO/R: http://www.ssw.uni-linz.ac.at/Research/Projects/Coco/
>
> >> * TP Yacc/Lex: (included in Free Pascal)
>
> > http://www.atocc.de/cgi-bin/atocc/site.cgi?lang=en&site=main
> >
> > Sorry, I had no time to test it yet.
>
> "For target code generation you need to specify code fragments for each
> rule in VCC."

Örks. Didn't read that.

> I think the important thing for all of these is that they still assume a
> lot of hard work from the person defining the custom syntax. They're not
> a magic bullet.

There are some tools I liked very much when dealing with language
translation in the past, but they don't fit her. None of them generates
Pascal Code out of the box.

ANTLR3 was my favourite, generating tree walkers with little extra work
(iirc). But it generates Java code.

> For the last 30 years or so I've been using a compiler compiler
> originally written in 1964, the implementation has matured as different
> pascal compilers have become available. I'm not suggesting that this is
> usable in the general case, but looked at objectively it does allow me
> to make gross behavioural changes fairly easily, e.g. to define novel
> string properties and to embed pragmata in comments.

Beautiful. Would you mind disclosing the name of that fine tool? ;)

Marc


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Parser Generator

Marc Santhoff-2
On Fr, 2016-05-20 at 10:53 +0200, Marc Santhoff wrote:

> There are some tools I liked very much when dealing with language
> translation in the past, but they don't fit her. None of them generates
                                                 ^e
"they don't fit here."

Fatal typo. I know Torsten is not a girls name.

Marc


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Parser Generator

Mark Morgan Lloyd-5
In reply to this post by Marc Santhoff-2
Marc Santhoff wrote:

>> For the last 30 years or so I've been using a compiler compiler
>> originally written in 1964, the implementation has matured as different
>> pascal compilers have become available. I'm not suggesting that this is
>> usable in the general case, but looked at objectively it does allow me
>> to make gross behavioural changes fairly easily, e.g. to define novel
>> string properties and to embed pragmata in comments.
>
> Beautiful. Would you mind disclosing the name of that fine tool? ;)

Meta-II, by Val Schorre. Wikipedia has an adequate description, I first
implemented it in the days of Pascal MT+ and since then have ported it
to Turbo, Topspeed, Delphi and FPC. I'm not saying I've done a
particularly good job, and will probably redo it for UTF16 (whatever the
correct FPC type is for that) at some point- possibly adding support for
Smalltalk-style keywords.

Obvious changes included saving more state to allow backtracking. Less
obvious was parsing comments as part of the syntax (which allows things
like XML and SNMP descriptions to be parsed), allowing string delimiters
to be specified and keeping the string delimiter as a string property.
Those last allow runtime behaviour of strings to vary depending on
delimiter, so for example a string expression using / as delimiter can
be used as a regex while a string lvalue using / as delimiter can be a
backref into a pattern.

Schorre or his coworkers later defined something called Tree Meta which
accumulates parsed source into a tree, and also has rules for how the
tree can be manipulated and "unparsed". I don't believe that anybody's
reimplemented it, but I'm occasionally tempted...

--
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Parser Generator

Torsten Bonde Christiansen
In reply to this post by Marc Santhoff-2
On 2016-05-20 10:58, Marc Santhoff wrote:

> On Fr, 2016-05-20 at 10:53 +0200, Marc Santhoff wrote:
>
>> There are some tools I liked very much when dealing with language
>> translation in the past, but they don't fit her. None of them generates
>                                                   ^e
> "they don't fit here."
>
> Fatal typo. I know Torsten is not a girls name.
>
> Marc
:) Thanks!

-Torsten
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Parser Generator

Torsten Bonde Christiansen
In reply to this post by Carlo Kok-2
On 2016-05-20 10:40, Carlo Kok wrote:

>
>
> On 2016-05-19 13:10, Torsten Bonde Christiansen wrote:
>> Hi.
>>
>> I am currently looking into integrating a custom language parser into my
>> program and have been
>> searching the web for parser generators that can create Pascal code from
>> a custom language.
>>
>> So far in my search i have found the following "options":
>>
>> * GOLD Parser: http://www.goldparser.org/
>> Was last updated in sept. 2012 and the lastest pascal implementation is
>> not for the lastest version of the program!
>>
>> * COCO/R: http://www.ssw.uni-linz.ac.at/Research/Projects/Coco/
>> Same as with the GOLD parser - last updated in 2014 and lastest pascal
>> implementation is for an older version of the program.
>>
>> * TP Yacc/Lex: (included in Free Pascal)
>> Is included with Free Pascal, but the generated code is non-OO, and
>> seems to rely on text-files for input.
>>
>> So if there is anyone out there who knows of such a generator I would be
>> glad to know.
>>
>
> It's been my experience that all the compiler compilers have one or
> more flaws that make it more work in the end to use them than to just
> write a parser by hand.

Previously I have worked with TP Lex/Yacc and it works fine with
limitations it has. And yes, using a parser generator is not a magic
wand that creates code to run without modification, but on most
occations I find that the post-processing required with this approach is
far less than writing my own parser.

kind regards,
Torsten Bonde Christiansen.



_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal