machine readable grammar of object pascal?

classic Classic list List threaded Threaded
19 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

machine readable grammar of object pascal?

Marc Santhoff-2
Hi,

for playing around I would need a grammar of Object Pascal. I do not
care for which tool it is written or at best if it is plain EBNF.

Does such grammar exist?

TIA,
Marc


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

Re: machine readable grammar of object pascal?

Marco van de Voort
In our previous episode, Marc Santhoff said:
> for playing around I would need a grammar of Object Pascal. I do not
> care for which tool it is written or at best if it is plain EBNF.
>
> Does such grammar exist?

Not within FPC/Lazarus project, since those use handcrafted recursive
descent parsers. So that means websearch, and then your search is as good as
mine.

The manual of older Delphi versions had a grammar for documentation (not
use!) purposes, and many only Object Pascal grammars will be based on that,
so check licensing of what you find thoroughly if you need it for a
commercial setting.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: machine readable grammar of object pascal?

Graeme Geldenhuys-6
In reply to this post by Marc Santhoff-2
On 2017-05-03 00:53, Marc Santhoff wrote:
> Does such grammar exist?

Not as part of the Free Pascal project. At one stage I have been
maintaining my own Pascal Grammar in EBNF format as part of the
documentation for fpGUI, but I haven’t kept up with all the recent FPC
syntax changes though - no generic, advanced records (aka new style TP
Objects) etc. I based the grammar on FPC’s “objfpc” compiler mode only.

The latest version can be found in the FPC Language Reference document
(INF help format) here:

   https://github.com/graemeg/fpGUI/blob/develop/docs/fpc_lang_ref.ipf

ps:
  I can generate a INF binary help file viewable with fpGUI’s DocView
  help viewer if you want to see how it looks like in its final
  state. Otherwise, you can compile your own binary INF file.
  Everything needed is in the fpGUI code repository and pre-built
  binaries of DocView are available for download from SourceForge.


Regards,
  Graeme

--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

My public PGP key:  http://tinyurl.com/graeme-pgp
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: machine readable grammar of object pascal?

denisgolovan
> On 2017-05-03 00:53, Marc Santhoff wrote:
>>  Does such grammar exist?

Well, it depends on what you are trying to solve.
If you want to parse Pascal using FPC - that's one way.
If you want to get some king of AST using any available [command-line] tools - that's another one.

Talking about latter - I would take LPEG (Lua+PEG) and create a parser myself.
It comes quite simple and intuitive (contrary to LL,LR,LALR,...).
Most of Object Pascal is done right (minus sets/open arrays), so it can be parsed statically pretty easily.
See http://lua-users.org/wiki/LpegRecipes for inspiration.

--
Regards,
Denis Golovan
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: machine readable grammar of object pascal?

Michael Van Canneyt


On Wed, 3 May 2017, denisgolovan wrote:

>> On 2017-05-03 00:53, Marc Santhoff wrote:
>>>  Does such grammar exist?
>
> Well, it depends on what you are trying to solve.
> If you want to parse Pascal using FPC - that's one way.
> If you want to get some king of AST using any available [command-line] tools - that's another one.
>
> Talking about latter - I would take LPEG (Lua+PEG) and create a parser myself.
> It comes quite simple and intuitive (contrary to LL,LR,LALR,...).
> Most of Object Pascal is done right (minus sets/open arrays),
Add generics to the 'minus' list.

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

Re: machine readable grammar of object pascal?

Peter
In reply to this post by Marc Santhoff-2
On 03/05/17 00:53, Marc Santhoff wrote:

> Hi,
>
> for playing around I would need a grammar of Object Pascal. I do not
> care for which tool it is written or at best if it is plain EBNF.
>
> Does such grammar exist?
>
> TIA,
> Marc
>
>
> _______________________________________________
> fpc-pascal maillist  -  [hidden email]
> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
>
I found grammar for Delphi once.
Trying to attach it.

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

delphi.atg (23K) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: machine readable grammar of object pascal?

Marco van de Voort
In reply to this post by Marco van de Voort
In our previous episode, Marco van de Voort said:

> > Does such grammar exist?
>
> Not within FPC/Lazarus project, since those use handcrafted recursive
> descent parsers. So that means websearch, and then your search is as good as
> mine.
>
> The manual of older Delphi versions had a grammar for documentation (not
> use!) purposes, and many only Object Pascal grammars will be based on that,
> so check licensing of what you find thoroughly if you need it for a
> commercial setting.

When I searched I saw a new entry, reportedly for XE7:

https://github.com/fabriciocolombo/sonar-delphi/blob/master/src/main/antlr3/org/sonar/plugins/delphi/antlr/Delphi.g

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

Re: machine readable grammar of object pascal?

noreply
In reply to this post by Marc Santhoff-2
On 2017-05-02 18:53, Marc Santhoff wrote:
> Hi,
>
> for playing around I would need a grammar of Object Pascal. I do not
> care for which tool it is written or at best if it is plain EBNF.
>
> Does such grammar exist?
>

The issue is that there is no object pascal, or in other words, there's
about 5 million different versions of it.
Delphi 5 is different than delphi 6, 7, 8, as things keep changing...

It's not like Plain C which stays mostly the same.

So in order to get a grammar, you'd need to only include a subset of
object pascal in a certain version.

Delphi 5 compatibility would be a good candidate (subset)... as it is a
fairly small language or subset (well, no, actually it's Big like Ada..)
but would not include generics and all the other features of object
pascal.

This is one of the biggest issues object pascal faces is that it is not
very standard and keeps changing, but C++ is very similar to this,
despite supposed standards existing
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: machine readable grammar of object pascal?

noreply
In reply to this post by Michael Van Canneyt
On 2017-05-03 04:37, Michael Van Canneyt wrote:

> On Wed, 3 May 2017, denisgolovan wrote:
>
>>> On 2017-05-03 00:53, Marc Santhoff wrote:
>>>>  Does such grammar exist?
>>
>> Well, it depends on what you are trying to solve.
>> If you want to parse Pascal using FPC - that's one way. If you want to
>> get some king of AST using any available [command-line] tools - that's
>> another one.
>>
>> Talking about latter - I would take LPEG (Lua+PEG) and create a parser
>> myself. It comes quite simple and intuitive (contrary to
>> LL,LR,LALR,...).
>> Most of Object Pascal is done right (minus sets/open arrays),
>
> Add generics to the 'minus' list.

Does it take into account little bizarre things like writable consts
(assignable consts)

like

const
   i: integer = 0;

which is like a variable, but called a const ;-)
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: machine readable grammar of object pascal?

noreply
In reply to this post by Peter
On 2017-05-03 06:49, Peter wrote:

> On 03/05/17 00:53, Marc Santhoff wrote:
>> Hi,
>>
>> for playing around I would need a grammar of Object Pascal. I do not
>> care for which tool it is written or at best if it is plain EBNF.
>>
>> Does such grammar exist?
>>
>> TIA,
>> Marc
>>

> I found grammar for Delphi once.
> Trying to attach it.
>


Which version? Delphi 5? 4? 7?

There is really no such thing as "delphi" language since there are more
than 10 versions of it ;-)

But to find even a subset, would be handy.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: machine readable grammar of object pascal?

Graeme Geldenhuys-6
In reply to this post by noreply
On 2017-05-08 04:26, [hidden email] wrote:
> which is like a variable, but called a const ;-)

I'm slowly but surely loosing all hope for Object Pascal. The language
is becoming more and more mangled with every new release of
Delphi and FPC.

Regards,
  Graeme

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

Re: machine readable grammar of object pascal?

Mattias Gaertner
On Mon, 8 May 2017 09:22:48 +0100
Graeme Geldenhuys <[hidden email]> wrote:

> On 2017-05-08 04:26, [hidden email] wrote:
> > which is like a variable, but called a const ;-)  
>
> I'm slowly but surely loosing all hope for Object Pascal. The language
> is becoming more and more mangled with every new release of
> Delphi and FPC.

Was a typed const ever read only?

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

Re: machine readable grammar of object pascal?

Michael Van Canneyt


On Mon, 8 May 2017, Mattias Gaertner wrote:

> On Mon, 8 May 2017 09:22:48 +0100
> Graeme Geldenhuys <[hidden email]> wrote:
>
>> On 2017-05-08 04:26, [hidden email] wrote:
>> > which is like a variable, but called a const ;-)
>>
>> I'm slowly but surely loosing all hope for Object Pascal. The language
>> is becoming more and more mangled with every new release of
>> Delphi and FPC.
>
> Was a typed const ever read only?

Writeable consts date from the Turbo Pascal days.

In Delphi (and FPC) there is a compiler directive that controls this.

{$WRITEABLECONST ON|OFF}
{$J+/-}

Best is of course to use {$J-}

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

Re: machine readable grammar of object pascal?

Graeme Geldenhuys-6
In reply to this post by Mattias Gaertner
On 2017-05-08 09:49, Mattias Gaertner wrote:
> Was a typed const ever read only?

And does CONSTANT in any other language mean writable? I think
they have VAR for that. Maybe it's just the terminology used
in FPC.

Regards,
  Graeme

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

Re: machine readable grammar of object pascal?

Mark Morgan Lloyd-5
In reply to this post by Graeme Geldenhuys-6
On 08/05/17 08:30, Graeme Geldenhuys wrote:
> On 2017-05-08 04:26, [hidden email] wrote:> which is like a variable, but called a const ;-)
> I'm slowly but surely loosing all hope for Object Pascal. The languageis becoming more and more mangled with every new release ofDelphi and FPC.

I'm not sure that it's worse than the alternatives, which either get
bogged down in an attempt to be all things to all men (Perl 6 as a
particular example) or are showcases for some community's idea of the
one true way of programming.

Please excuse a quote, edited for conciseness:

"Back around September 2007, I was doing some minor but central work on
an enormous Google C++ program, one you've all interacted with, and my
compilations were taking about 45 minutes on our huge distributed
compile cluster. An announcement came around that there was going to be
a talk

"In the span of an hour at that talk we heard about something like 35
new features that were being planned.

"At this point I asked myself a question: Did the C++ committee really
believe that was wrong with C++ was that it didn't have enough features?"

-- Ken Thompson
https://commandcenter.blogspot.co.uk/2012/06/less-is-exponentially-more.html

The problem is that those 35+ new features were things that somebody
actually wanted or needed, either because it improved functionality or
because it improved the rigour with which behaviour could be documented.

--
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
|  
Report Content as Inappropriate

Re: machine readable grammar of object pascal?

Michael Van Canneyt
In reply to this post by Graeme Geldenhuys-6


On Mon, 8 May 2017, Graeme Geldenhuys wrote:

> On 2017-05-08 09:49, Mattias Gaertner wrote:
>> Was a typed const ever read only?
>
> And does CONSTANT in any other language mean writable? I think
> they have VAR for that. Maybe it's just the terminology used
> in FPC.

This is not something invented by FPC.
It is something inherited from Turbo Pascal.

See my other reply to Mattias.

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

Re: machine readable grammar of object pascal?

Marco van de Voort
In our previous episode, Michael Van Canneyt said:
>
> This is not something invented by FPC.
> It is something inherited from Turbo Pascal.

And Delphi up to D4 iirc.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: machine readable grammar of object pascal?

Jürgen Hestermann
Am 2017-05-08 um 12:31 schrieb Marco van de Voort:
> In our previous episode, Michael Van Canneyt said:
>> This is not something invented by FPC.
>> It is something inherited from Turbo Pascal.
> And Delphi up to D4 iirc.
Delphi inherited it from Turbo Pascal.
Actually, it was a hack.
Const defines end up in the global data segment
so writable local constants work like global variables
but are only accessable from the declaring function.

There should have been a different syntax for this
but Borland did not add one.
Now we have this syntax anomaly 'till the end of time...

This shows that before adding new "features" one should
think twice (or three times).

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

Re: machine readable grammar of object pascal?

wkitty42
In reply to this post by Mattias Gaertner
On 05/08/2017 04:49 AM, Mattias Gaertner wrote:

> On Mon, 8 May 2017 09:22:48 +0100
> Graeme Geldenhuys <[hidden email]> wrote:
>
>> On 2017-05-08 04:26, [hidden email] wrote:
>>> which is like a variable, but called a const ;-)
>>
>> I'm slowly but surely loosing all hope for Object Pascal. The language
>> is becoming more and more mangled with every new release of
>> Delphi and FPC.
>
> Was a typed const ever read only?

i used them all the time in my TP days... some i used at the end of the exe
binary to store configuration data that changed based on registration or user
settings...

--
  NOTE: No off-list assistance is given without prior approval.
        *Please keep mailing list traffic on the list* unless
        private contact is specifically requested and granted.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Loading...