GetPoplog / Grammar

Managing the Pop-11 Grammar
Creative Commons Zero v1.0 Universal
2 stars 1 forks source link

Some fixes to EBNF #2

Closed edgardozoppi closed 3 years ago

edgardozoppi commented 3 years ago

Hi @sfkleach,

I have some doubts that I would like to discuss with you regarding the issues you found on the EBNF grammar.I understand that maybe the differences found are due to the fact that the book's diagrams are old or even wrong, but since I don't know the Pop-11 language I tried to make the EBNF grammar as faithful as possible to the provided charts from the book.

  1. Varslist

The rail-road diagram from the book for Varslist allows the following input string: , word word , , word macro word , , word word syntax word

So the production you suggest is not correct as far as I can tell, because it allows the input string: word but it shouldn't according to the book's chart. Among other things, all inputs should end with the following pattern: (macro | syntax | number) word.

Book_Varslist         ::= ( ','* ( 'macro' | 'syntax' | Number )? Word )+

So according to the book my original production is correct:

Varslist ::= ( ( ','* Word? )+ ( 'macro' | 'syntax' | Number ) Word )+  

  1. Repeater Iteration

The from_repeater is a terminal? I don't see it in the chart you show in the Google Doc with the feedback. So I'm not sure if it is a terminal or a non terminal.

  1. ListSegment

I don't know how to Fix all occurrences of Literal appropriately because I don't know where the newly added ConstantExpression nonterminal should be used instead of the original Literal nonterminal. Should I add ConstantExpression as an alternative in Expression?

  1. Declaration

I can see in the examples you mentioned that declarations can be initialized, but the book's charts don't allow this. Only lconstants can be initialized? Where the procedure qualified can be used? I think I need more examples to come up with the right grammar. So far I modified the production like this but not sure if its ok.

Declaration ::=
    ('global'? ('vars' 'procedure'? | 'constant') Varslist | ('lvars' | 'lconstant' | 'dlocal') (',' | Word)+) ';'

Thanks, Edgar.

sfkleach commented 3 years ago

Thanks for this pull-request. We will need to modify the Varslist in addition, simply because the book definition is so wrong. Here's what I think it has to be.

Varslist ::= ( ','* ( 'macro' | 'syntax' | Number )? Word )+

Once we have made this immediate fix for Varslist, we can then pay attention to the fact that the Varslist is used in two contexts: inside Declarations (where this definition is mostly OK) and inside Definition, where the book is simply wrong (again).

edgardozoppi commented 3 years ago

Hi Steve, I have made some changes according to your feedback. Please let me know how to improve the grammar to be up to date with the latest version of the language. Maybe I can take a look to a few code fragments written in Poplog so I can get a better understanding and be more familiar with its syntax. Do you have same examples to point me out so I can review them? A tutorial will also help a lot. Thanks!