Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2009-10

BNF grammar for fpc

21 messages · 14 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Marc Santhoff

Hi everyone,

is a complete grammar for fpc written in some variant of BNF available somewhere?

I searched the website and the wiki, to no avail.

TIA,
Marc

Marc Santhoff
leledumbo
to Marc Santhoff
is a complete grammar for fpc written in some variant of BNF available somewhere? I searched the website and the wiki, to no avail.

AFAIK, there's none. The developers adding language features by directly modifying the code. Even there's a bounty for it. See: http://wiki.lazarus.freepascal.org/Bounties#FPC_grammar

View this message in context: http://www.nabble.com/BNF-grammar-for-fpc-tp25914637p25920664.html Sent from the Free Pascal - General mailing list .
Marco van de Voort
to leledumbo

In our previous episode, leledumbo said:

Show quoted text 9 lines
> is a complete grammar for fpc written in some variant of BNF available > somewhere? > > I searched the website and the wiki, to no avail. AFAIK, there's none. The developers adding language features by directly modifying the code. Even there's a bounty for it. See: http://wiki.lazarus.freepascal.org/Bounties#FPC_grammar

There is not even a proper open one for Delphi. At least there wasn't till a while back.

IIRC there was a discussion about this in comp.lang.pascal.delphi.misc somewhere in the summer, and some new sources were mentioned. Have a look.

Jürgen Hestermann
to Marco van de Voort
There is not even a proper open one for Delphi. At least there wasn't till a while back.

That may be because it is no longer possible to write a BNF grammar for these compilers due to the c-style extensions.

Jonas Maebe
to Jürgen Hestermann
Jürgen Hestermann wrote
That may be because it is no longer possible to write a BNF grammar for these compilers due to the c-style extensions.

BNF grammars exist for C (e.g. as part of the ANSI C standard) and even for C++. Please don't start a language war in every single thread.

Jonas

Marco van de Voort
to Jürgen Hestermann: That may be because it is no longer possible to write a BNF grammar for these compilers…

In our previous episode, J�rgen Hestermann said:

Show quoted text 5 lines
> There is not even a proper open one for Delphi. At least there wasn't till a > while back. That may be because it is no longer possible to write a BNF grammar for these compilers due to the c-style extensions.

Odd that there are grammers for C and C++ then, and they have no problem :-) Please don't grab any random other thread to make your point.

The reason is probably more because Wirthian languages traditionally use recursive descent parsers.

Florian Klaempfl
to Marco van de Voort
Show quoted text 11 lines
In our previous episode, J�rgen Hestermann said: >> There is not even a proper open one for Delphi. At least there wasn't till a >> while back. > That may be because it is no longer possible to write a BNF grammar for > these compilers due to the c-style extensions. Odd that there are grammers for C and C++ then, and they have no problem :-) Please don't grab any random other thread to make your point. The reason is probably more because Wirthian languages traditionally use recursive descent parsers.

gcc as well for several years simply because a recursive descent parser is faster than one generated automatically from a BNF grammar.

Guillermo Martínez Jiménez
From: Marco van de Voort (...) The reason is probably more because Wirthian languages traditionally use recursive descent parsers.

This reminds me: there are a compiler generator named COCO/R wich has a Pascal version (Delphi actually). It generates recursive descendent parsers. ( search results ->
www.google.com/search?hl=es&q=%22COCO%2FR%22&btnG=Buscar&lr=).

Greetings.

Marco van de Voort
to Florian Klaempfl: gcc as well for several years simply because a recursive descent parser is faster than…

In our previous episode, Florian Klaempfl said:

Show quoted text 10 lines
>> these compilers due to the c-style extensions. > > Odd that there are grammers for C and C++ then, and they have no problem :-) > Please don't grab any random other thread to make your point. > > The reason is probably more because Wirthian languages traditionally use > recursive descent parsers. gcc as well for several years simply because a recursive descent parser is faster than one generated automatically from a BNF grammar.

Afaik most C/C++ production compilers are nowadays, gcc was about the last. It doesn't preclude BNF grammars from existing though, which was the point.

On Pascal, not even the startup compilers are parser generator (grammar) based.

Frank Peelo
to Florian Klaempfl: gcc as well for several years simply because a recursive descent parser is faster than…
Florian Klaempfl wrote 19 lines
Marco van de Voort schrieb: >In our previous episode, J�rgen Hestermann said: > >>>There is not even a proper open one for Delphi. At least there wasn't till a >>>while back. >> >>That may be because it is no longer possible to write a BNF grammar for >>these compilers due to the c-style extensions. > >Odd that there are grammers for C and C++ then, and they have no problem :-) >Please don't grab any random other thread to make your point. > >The reason is probably more because Wirthian languages traditionally use >recursive descent parsers. gcc as well for several years simply because a recursive descent parser is faster than one generated automatically from a BNF grammar.

A while back, I read "Compiler Construction", by Prof. Wirth, now available for download:
http://www-old.oberon.ethz.ch/WirthPubl/CBEAll.pdf

It looks like recursive descent parsers and EBNF grammars go quite well together, so having a recursive descent parser should not be a bar to having a grammar.

Is the problem that you start off with a grammar, write the parser, then maintain the parser without updating the grammar?

Frank

Florian Klaempfl
to Frank Peelo
Is the problem that you start off with a grammar, write the parser, then maintain the parser without updating the grammar?

Every early FPC (FPK Pascal) prototypes in 1993 used yacc as well but it was simply too slow and also memory consuming at these days.

Florian Klaempfl
to Florian Klaempfl
Show quoted text 6 lines
Frank Peelo schrieb: > Is the problem that you start off with a grammar, write the parser, then > maintain the parser without updating the grammar? > Every early FPC (FPK Pascal) prototypes in 1993 used yacc as well but it

Very early ...

Vinzent Höfler
to Marco van de Voort: In our previous episode, J�rgen Hestermann said: Odd that there are grammers for C and…
The reason is probably more because Wirthian languages traditionally use recursive descent parsers.

Yeah, right.

The reason is most definitely that of all those people who know the language well enough to write the grammar, there's no one actually doing it.

Of course, with all those new features and Delphi-compatibility switches, the language probably probably changes too often to be worth the Jetzt kostenlos herunterladen: Internet Explorer 8 und Mozilla Firefox 3.5 - sicherer, schneller und einfacher! http://portal.gmx.net/de/go/chbrowser

Felipe Monteiro de Carvalho
to leledumbo: AFAIK, there's none. The developers adding language features by directly modifying the…
leledumbo wrote
AFAIK, there's none. The developers adding language features by directly modifying the code. Even there's a bounty for it. See: http://wiki.lazarus.freepascal.org/Bounties#FPC_grammar

I contacted the person that posted the bounty but he didn't answer.

If anyone still wants a grammar I'm interrested in writing for a fair price.

thanks,

Felipe Monteiro de Carvalho
Marc Santhoff
to leledumbo: AFAIK, there's none. The developers adding language features by directly modifying the…
leledumbo wrote 8 lines
> is a complete grammar for fpc written in some variant of BNF available > somewhere? > > I searched the website and the wiki, to no avail. AFAIK, there's none. The developers adding language features by directly modifying the code. Even there's a bounty for it. See: http://wiki.lazarus.freepascal.org/Bounties#FPC_grammar

Okay, nothing to play with without huge effort. ;)

Thank you,
Marc

Marc Santhoff
Graeme Geldenhuys
to Marc Santhoff: is a complete grammar for fpc written in some variant of BNF available somewhere? I…

2009/10/15 Marc Santhoff :

is a complete grammar for fpc written in some variant of BNF available somewhere?

About 2 weeks ago, I had no clue what BNF was. Funny that you mention it, because I am working on a LaTeX converter to IPF. I was google'ing for a BNF for LaTeX, as a starting point.

Anyway, I found the following like to a BNF Compiler that supports 5+ languages. http://code.haskell.org/bnfc/

Maybe this can be extended to Object Pascal - time permitting obviously.

Regards, - Graeme - _______________________________________________ fpGUI - a cross-platform Free Pascal GUI toolkit http://opensoft.homeip.net/fpgui/
Marc Santhoff
to Graeme Geldenhuys
Graeme Geldenhuys wrote 13 lines
2009/10/15 Marc Santhoff : > > is a complete grammar for fpc written in some variant of BNF available > somewhere? About 2 weeks ago, I had no clue what BNF was. Funny that you mention it, because I am working on a LaTeX converter to IPF. I was google'ing for a BNF for LaTeX, as a starting point. Anyway, I found the following like to a BNF Compiler that supports 5+ languages. http://code.haskell.org/bnfc/ Maybe this can be extended to Object Pascal - time permitting obviously.

There are too many compiler generation tools to know them all.

we all know:
- lex and yacc
- flex and bison
and the pascal generating mutant

more recent:
- antlr (former pccts)
- eli and DEViL
- JavaCC
- Jaccie and SIC

older things like twig, burg and the like
- Coco/R was named already
- Gold Parsing System was totally new to me

and so on.

If you have fun fiddling with those tools some good starting points are:

http://catalog.compilertools.net/
http://www.compilers.net/
http://www.thefreecountry.com/
http://cui.unige.ch/db-research/Enseignement/analyseinfo/BNFweb.html

Have a nice weekend,
Marc

Marc Santhoff
Mehmet Erol Sanliturk
to Marc Santhoff
Marc Santhoff wrote
Am Freitag, den 16.10.2009, 22:50 +0200 schrieb Graeme Geldenhuys: > 2009/10/15 Marc Santhoff : >> is a complete grammar for fpc written in some variant of BNF available >> somewhere?

...

Show quoted text 10 lines

The following page is about Delphi 5 :

http://www.felix-colibri.com/papers/compilers/delphi_5_grammar/delphi_5_grammar.html

Thank you very much

Mehmet Erol Sanliturk

leledumbo
to Mehmet Erol Sanliturk
That may be because it is no longer possible to write a BNF grammar for these compilers due to the c-style extensions.

AFAIK if a parser can be made for an extension, so is the grammar.

There are some language constructs that is simply not posible with a LL(1) parser, when comparing to the LALR(1).

For example, left recursion. Yes, I know LALR(1) can recognize this. But it can be solved easily by transforming the grammar such that the recursion is eliminated and LL(1) wins again.

View this message in context: http://www.nabble.com/BNF-grammar-for-fpc-tp25914637p25952532.html Sent from the Free Pascal - General mailing list .