Sign in Join

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

Mailing lists / fpc-pascal / 2023-12

More syntax questions (and more to follow)

4 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

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

Adriaan van Os

More questions about the FreePascal Language Reference (version 3.2.0)

1. Section 17.1 defines a rule <raise-statement> and <exception-address>

raise-statement = "raise" [ exception-instance [ exception-address ] ] . exception-address = "at" exception-address [ "," address-expression ] .

a) Is it correct that <exception-address> defines itself recursively ?

b) I can't find the rule that defines <address-expression>. What is it ?

c) I can't find the rule that defines <exception-instance>. What is it ?

2. Section 12.1 refers to a rule <address-factor>

factor = "(" expression ")" | variable-reference | function-call | unsigned-constant| "NOT" factor | "sign" factor | set-constructor | value-typecast | address-factor .

I can't find the rule <address-factor> but it may be the same as the rule <addressfactor> given in section 12.7 ?

addressfactor = "@" ( variable-reference | procedure-identifier | function-identifier | qualified-method-identifier ) .

3. Section 2.2 refers to a rule <address-constant>

typed-constant = constant | address-constant | array-constant | record-constant | procedural-constant .

I can't find the rule <address-constant>. What is it ?

4. Section 2.2 also refers to a rule <array-constant>

typed-constant = constant | address-constant | array-constant | record-constant | procedural-constant .

I can't find the rule <array-constant>. What is it ?

5. Section 2.2 also refers to a rule <record-constant>

typed-constant = constant | address-constant | array-constant | record-constant | procedural-constant .

I can't find the rule <record-constant>. What is it ?

6. Section 2.2 also refers to a rule <procedural-constant>

typed-constant = constant | address-constant | array-constant | record-constant | procedural-constant .

I can't find the rule <procedural-constant>. What is it ?

7. Section 13.3 refers to a rule <assembler code>

asm-statement = "asm" assembler-code "END" [ registerlist ] .

I can't find a rule for <assembler code> What is it, from the point of view of parsing Pascal ?

8. Section 10.1 refers to a rule <basehelper>

helper-type = ( "CLASS" | "RECORD" | "TYPE" ) "helper" [ "(" basehelper ")" ] "FOR" identifier { helper-component-list } "END" hint-modifiers .

I can't find a rule for <basehelper>. What is it ?

9. Sections 17.2 and 6.1 refer to a rule <class-type-identifier>

exception-handler = "ON" [ identifier ":" ] class-type-identifier "DO" statement . class-heritage = "(" class-type-identifier [ class-implemented-interfaces ] ")" .

I can assume ?

class-type-identifier = identifier .

10. Section 11.2 refers to a rule <objective-Cclass-type-identifier>

objc-class-heritage = "(" [ objective-Cclass-type-identifier ] [ objc-implemented-protocols ] ")" .

I can assume ?

objective-Cclass-type-identifier = identifier .

11. Section 6.1 refers to a rule <classtype>

class-reference-type = "CLASS" "OF" classtype .

I can't find a rule for <classtype>. What is it ?

12. Section 13.2 refers to a rule <conditional-statement>

structured-statement = compound-statement | conditional-statement | repetitive-statement | with-statement | exception-statement .

I can't find a rule for <conditional-statement>. What is it ?

13. Section 6.1 referes to a rule <const-declaration-part>

component-list = [ visibility-specifier ] { field-definition } { const-declaration-part | type-declaration-part | variable-declaration-part | class-variable-declaration-part | method-definition | property-definition } .

I can assume ?

const-declaration-part = constant-declaration-part .

14. Sections 2.2, 3.1.1, 3.3.2, 4.7 and 13.2.2 refer to a rule <constant>

typed-constant = constant | address-constant | array-constant | record-constant | procedural-constant .
subrange-type = constant ".." constant .
variant = constant { "," constant } ":" "(" [ field-list ] ")" . default-specifier = "default" [ constant ] | "nodefault" . stored-specifier = "stored" ( constant | identifier ) . case = constant [ ".." constant ] { "," constant [ ".." constant ] } ":" statement .

I can't find a rule for <constant>. What is it ?

15. Sections 5.1 and 6.6.1 refer to a rule <constant-expression>

const-definition = "CONST" identifier "=" constant-expression ";" . class-method-directives = ( ( "virtual" | "dynamic" ) [ ";" "abstract" ] | "reintroduce" ";" | "override" ";" | "message" constant-expression ) [ call-modifiers ";" ] .

I can assume ?

constant-expression = expression .

16. Section 12.1 refers to a rule <constant-identifier>

unsigned-constant = unsigned-number | character-string | constant-identifier | "NIL" .

I can assume ?

constant-identifier = identifier .

(more to follow)

Regards,

Adriaan van Os

Michael Van Canneyt
to Adriaan van Os
Adriaan van Os wrote 11 lines
More questions about the FreePascal Language Reference (version 3.2.0) 1. Section 17.1 defines a rule <raise-statement> and <exception-address> raise-statement = "raise" [ exception-instance [ exception-address ] ] . exception-address = "at" exception-address [ "," address-expression ] . a) Is it correct that <exception-address> defines itself recursively ?

No.

That should be exception-address = "at" address-factor

Corrected.

b) I can't find the rule that defines <address-expression>. What is it ?

Typo, should be address-factor.

Corrected.

c) I can't find the rule that defines <exception-instance>. What is it ?

An expression of type exception.

Added.

Show quoted text 9 lines
2. Section 12.1 refers to a rule <address-factor> factor = "(" expression ")" | variable-reference | function-call | unsigned-constant| "NOT" factor | "sign" factor | set-constructor | value-typecast | address-factor . I can't find the rule <address-factor> but it may be the same as the rule <addressfactor> given in section 12.7 ?

Yes. Corrected.

Show quoted text 10 lines
addressfactor = "@" ( variable-reference | procedure-identifier | function-identifier | qualified-method-identifier ) . 3. Section 2.2 refers to a rule <address-constant> typed-constant = constant | address-constant | array-constant | record-constant | procedural-constant . I can't find the rule <address-constant>. What is it ?

A constant of type address. So either Nil or @identifier.

Show quoted text 7 lines
4. Section 2.2 also refers to a rule <array-constant> typed-constant = constant | address-constant | array-constant | record-constant | procedural-constant . I can't find the rule <array-constant>. What is it ?

A constant of type array, obviously.

Needs to be added.

Show quoted text 7 lines
5. Section 2.2 also refers to a rule <record-constant> typed-constant = constant | address-constant | array-constant | record-constant | procedural-constant . I can't find the rule <record-constant>. What is it ?

A constant of type record.

Needs to be added.

Show quoted text 7 lines
6. Section 2.2 also refers to a rule <procedural-constant> typed-constant = constant | address-constant | array-constant | record-constant | procedural-constant . I can't find the rule <procedural-constant>. What is it ?

Address-factor of procedural type.

Needs to be added.

Show quoted text 7 lines
7. Section 13.3 refers to a rule <assembler code> asm-statement = "asm" assembler-code "END" [ registerlist ] . I can't find a rule for <assembler code> What is it, from the point of view of parsing Pascal ?

Undefined. Skip all tokens till you meet END.

Show quoted text 8 lines
8. Section 10.1 refers to a rule <basehelper> helper-type = ( "CLASS" | "RECORD" | "TYPE" ) "helper" [ "(" basehelper ")" ] "FOR" identifier { helper-component-list } "END" hint-modifiers . I can't find a rule for <basehelper>. What is it ?

An identifier.

Corrected.

Show quoted text 11 lines
9. Sections 17.2 and 6.1 refer to a rule <class-type-identifier> exception-handler = "ON" [ identifier ":" ] class-type-identifier "DO" statement . class-heritage = "(" class-type-identifier [ class-implemented-interfaces ] ")" . I can assume ? class-type-identifier = identifier .

Yes.

Added.

Show quoted text 9 lines
10. Section 11.2 refers to a rule <objective-Cclass-type-identifier> objc-class-heritage = "(" [ objective-Cclass-type-identifier ] [ objc-implemented-protocols ] ")" . I can assume ? objective-Cclass-type-identifier = identifier .

Yes.

Added.

Show quoted text 6 lines
11. Section 6.1 refers to a rule <classtype> class-reference-type = "CLASS" "OF" classtype . I can't find a rule for <classtype>. What is it ?

class-type-identifier (or identifier)

Added.

Show quoted text 7 lines
12. Section 13.2 refers to a rule <conditional-statement> structured-statement = compound-statement | conditional-statement | repetitive-statement | with-statement | exception-statement . I can't find a rule for <conditional-statement>. What is it ?

You missed it. It is defined under 'Structured statements'.

Show quoted text 10 lines
13. Section 6.1 referes to a rule <const-declaration-part> component-list = [ visibility-specifier ] { field-definition } { const-declaration-part | type-declaration-part | variable-declaration-part | class-variable-declaration-part | method-definition | property-definition } . I can assume ? const-declaration-part = constant-declaration-part .

Yes. Corrected.

Show quoted text 13 lines
14. Sections 2.2, 3.1.1, 3.3.2, 4.7 and 13.2.2 refer to a rule <constant> typed-constant = constant | address-constant | array-constant | record-constant | procedural-constant . subrange-type = constant ".." constant . variant = constant { "," constant } ":" "(" [ field-list ] ")" . default-specifier = "default" [ constant ] | "nodefault" . stored-specifier = "stored" ( constant | identifier ) . case = constant [ ".." constant ] { "," constant [ ".." constant ] } ":" statement . I can't find a rule for <constant>. What is it ?

A simple constant. ordinal, string or float.

Needs to be added.

Show quoted text 11 lines
15. Sections 5.1 and 6.6.1 refer to a rule <constant-expression> const-definition = "CONST" identifier "=" constant-expression ";" . class-method-directives = ( ( "virtual" | "dynamic" ) [ ";" "abstract" ] | "reintroduce" ";" | "override" ";" | "message" constant-expression ) [ call-modifiers ";" ] . I can assume ? constant-expression = expression .

As far as parsing is concerned, yes.

Show quoted text 9 lines
16. Section 12.1 refers to a rule <constant-identifier> unsigned-constant = unsigned-number | character-string | constant-identifier | "NIL" . I can assume ? constant-identifier = identifier .

Yes. Added.

Thanks for the questions. They showed me deficiencies of the text. I have corrected what could be done quickly.

For the typed constants I need some time to correct/add them, since I need to provide some explanatory text.

Please note that the syntax diagrams are NOT meant to be exhaustive. They are an aid to explain the syntax. I strive to make them as correct as possible, but they make no pretense to being complete.

Furthermore, recent changes in Delphi syntax unfortunately require that the parser is aware of the types of some of the elements, something which cannot be expressed in a formal syntax :/

As far as I know, Delphi no longer provides an up-to-date grammar. The last one I saw came with Delphi 7.

Michael.

Adriaan van Os
to Michael Van Canneyt

Michael Van Canneyt via fpc-pascal wrote:

Thanks for the replies.

Please note that the syntax diagrams are NOT meant to be exhaustive. They are an aid to explain the syntax. I strive to make them as correct as possible, but they make no pretense to being complete.

Anyway, I strive to make the syntax complete and correct. When it is ready, I can send it in to be added as an Appendix to the Language Reference manual. I have an ebfn-driven general (back-parsing) parser, that already works for Oberon-0 end UCSD-Pascal. So, the ebnf can be tested.

Regards,

Adriaan van Os

Michael Van Canneyt
to Adriaan van Os
Adriaan van Os wrote 12 lines
Michael Van Canneyt via fpc-pascal wrote: Thanks for the replies. > Please note that the syntax diagrams are NOT meant to be exhaustive. > They are an aid to explain the syntax. I strive to make them as correct as > possible, but they make no pretense to being complete. Anyway, I strive to make the syntax complete and correct. When it is ready, I can send it in to be added as an Appendix to the Language Reference manual. I have an ebfn-driven general (back-parsing) parser, that already works for Oberon-0 end UCSD-Pascal. So, the ebnf can be tested.

There are several typesetting systems that can convert EBNF to a nice diagram, so it can be nicely typeset too.

I have long been looking for an EBNF, and only found several syntaxes for other systems, so that would be really good if you could make one. I would include it at once :-)

Michael.