ANTLR grammars for PIM and ISO

15 Aufrufe
Direkt zur ersten ungelesenen Nachricht

strictly noreply

ungelesen,
18.05.2009, 05:28:3218.05.09
an
For comparative studies I recently created ANTLR grammars for both PIM
and ISO M2. Just in case these might be of help to anyone else, I made
them available online ...

PIM3 grammar:
http://www.sunrisetel.net/software/papers/modula2/m2pim3.g

ISO grammar:
http://www.sunrisetel.net/software/papers/modula2/m2iso.g

Both grammars follow the naming conventions and structure of the EBNF
given in PIM3 and ISO/IEC IS 10514 respectively, but those grammars
were written for documentation purposes only. They are not LL(1), nor
even LL(k), ANTLR will not validate them in this form. As time
permits, I intend to refactor them to create LL(1) versions. If and
when I get around to doing that, I will post the LL(1) versions, too.
Meanwhile the grammars can be used to generate syntax diagrams with
ANTLRworks.

strictly noreply

ungelesen,
19.05.2009, 06:38:5619.05.09
an
refactored LL(1) version of the PIM grammar:

http://www.sunrisetel.net/software/papers/modula2/m2pim3_LL1.g

Die Nachricht wurde gelöscht

carlgl...@yahoo.com

ungelesen,
25.05.2009, 12:18:5425.05.09
an

I believe the linked modula2 grammars correspond to the Second Edition
of "Programming in Modula-2" not the 3rd Edition.

For example, SimpleConstantExpr was simpified in the 3rd edition to be
just
expression
(on the RHS of the rule).

Also your rule for definition (module) is missing (on the RHS):
DEFINITION MODULE (and so on).

Lexical note:
Your rule for string is too restrictive in that you disallow these
legal string characters:
1) a single quote within a double-quoted string and
2) a double-quote within a single-quoted string.

The PIM3 report additionally dissallows strings crossing a line-
boundary. Your apparent referencence to ASCII and your restriction to
"printable" characters would certainly be consistent with the report
not allowing end-of-line characters within strings.

I am unable to check the grammar more thoroughly at this time, but
this will be enough for now.
Thank you for your posts.
"martin the modulan"

carlgl...@yahoo.com

ungelesen,
25.05.2009, 13:18:5725.05.09
an
On May 25, 9:18 am, carlglassb...@yahoo.com wrote:
> On May 18, 2:28 am, strictly noreply <beekay.nore...@gmail.com> wrote:
>
>
>
> > For comparative studies I recently created ANTLR grammars for both PIM
> > and ISO M2. Just in case these might be of help to anyone else, I made
> > them available online ...
>
> > PIM3 grammar:http://www.sunrisetel.net/software/papers/modula2/m2pim3.g
>
> > ISO grammar:http://www.sunrisetel.net/software/papers/modula2/m2iso.g
>
> > Both grammars follow the naming conventions and structure of the EBNF
> > given in PIM3 and ISO/IEC IS 10514 respectively, but those grammars
> > were written for documentation purposes only. They are not LL(1), nor
> > even LL(k), ANTLR will not validate them in this form. As time
> > permits, I intend to refactor them to create LL(1) versions. If and
> > when I get around to doing that, I will post the LL(1) versions, too.
> > Meanwhile the grammars can be used to generate syntax diagrams with
> > ANTLRworks.
>
> I believe the linked modula2 grammars correspond to the Second Edition
> of "Programming in Modula-2" not the 3rd Edition.
>
> For example, SimpleConstantExpr was simpified in the 3rd edition to be
> just
> expression
> (on the RHS of the rule).
>
<...snip...>

Correction:
PIM3, Appendix 1, rule nr. 13
ConstExpression = expression .
was the revision I meant.

"Martin the Modulan"

strictly noreply

ungelesen,
22.06.2009, 05:00:0422.06.09
an
Hi, thanks for the feedback.

On May 26, 1:18 am, carlglassb...@yahoo.com wrote:

> I believe the linked modula2 grammars correspond to the Second Edition
> of "Programming in Modula-2" not the 3rd Edition.

The only copy I had access to when I made the ANTLR grammars was a
German copy of PIM3. I checked this copy this week again and it claims
to be a translation of the "third, corrected edition", there are ISBN
numbers: 3-540-13301-1 and 0-387-13301-1.

I have compared the grammar against ISBN 0-387-15078-1 which also
claims to be "third, corrected edition" but is in English and surprise
surprise, the grammars are different.

The grammar in ISBN 3-540-13301-1 would seem to be at a stage in
between PIM2 and ISBN 0-387-15078-1.

Anyway, I have revised the ANTLR LL(1) grammar accordingly (to follow
ISBN 0-387-15078-1 which seems more recent).

The revised grammar file is at the same URL as before:

http://www.sunrisetel.net/software/papers/modula2/m2pim3_LL1.g

However, I haven't had the time to revise the original non-LL(1)
version yet.

> Also your rule for definition (module) is missing (on the RHS):
> DEFINITION MODULE (and so on).

yes, indeed, fixed now, thanks.

> Your rule for string is too restrictive in that you disallow these
> legal string characters:
> 1) a single quote within a double-quoted string and
> 2) a double-quote within a single-quoted string.

The PIM3 EBNF does not actually match its textual description and I
forgot to amend the grammar, fixed now, thanks.


>
> The PIM3 report additionally dissallows strings crossing a line-
> boundary. Your apparent referencence to ASCII and your restriction to
> "printable" characters would certainly be consistent with the report
> not allowing end-of-line characters within strings.

ANTLR3 is Java based and like Java it considers all characters to be
unicode, so there would be an opportunity for an actual ANTLR based
implementation to add unicode support, but when PIM3 was published
there was no such thing, so I left it at ASCII.

> I am unable to check the grammar more thoroughly at this time, but
> this will be enough for now.
> Thank you for your posts.

You're welcome
thanks again for the feedback.

BK [noreply/posting only]

ungelesen,
08.07.2009, 04:19:5808.07.09
an
The ANTLR grammars for Modula-2 have now been moved to http://modula2.net

- PIM grammar: http://modula2.net/resources/m2pim3.g
- PIM LL(1) grammar: http://modula2.net/resources/m2pim3_LL1.g
- ISO Modula-2 grammar: http://modula2.net/resources/m2iso.g

The old URLs at sunrise are being redirect to the new ones, but if you
have linked to these files on your website, please update the links
accordignly, thanks.

BK [noreply/posting only]

ungelesen,
10.07.2009, 04:37:0010.07.09
an
I added two more grammars today ...

- PIM4 grammar:
http://modula2.net/resources/m2pim4.g

- LL(1) version of the PIM4 grammar:
http://modula2.net/resources/m2pim4_LL1.g

NB: the EBNF in the appendix of PIM4 is identical to that of PIM2.

Allen antworten
Dem Autor antworten
Weiterleiten
0 neue Nachrichten