Sign in Join

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

Mailing lists / fpc-pascal / 2023-12

More syntax questions (part 2)

3 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) part 2

17. For the following rules, I couldn't find a definition in the Language Reference. Can I assume they can all be defined as <identifier> ?

object-type-identifier = identifier . field-identifier = identifier . interface-identifier = identifier . interface-type-identifier = identifier . method-identifier = identifier . procedure-identifier = identifier . protocol-identifier = identifier . protocol-type-identifier = identifier . qualified-method-identifier = identifier . result-identifier = identifier . type-identifier = identifier . function-identifier = identifier . unit-identifier = identifier . variable-identifier = identifier .

18. Section 14.4.1 defines a rule <value-parameter>

value-parameter = identifier-list ":" [ "ARRAY" "OF" ] parameter-type | identifier ":" type-identifier "=" default-parameter-value .

I couldn't find a rule for <parameter-type>. If <parameter-type> equals <type-identifier> then it may be easier to name it <type-identifier> ?

19. Sections 3.6, 14.2 and 15.2 refer to a rule <result-type>.

function-header = "FUNCTION" formal-parameter-list ":" result-type . function-header = "FUNCTION" ( identifier | qualified-method-identifier ) formal-parameter-list ":" result-type [ modifiers ] [ hintdirectives ] . operator-definition = "operator" ( assignment-operator-definition | arithmetic-operator-definition | comparision-operator-definition ) result-identifier ":" result-type ";" subroutine-block .

I couldn't find a rule for <result-type>. Can I assume ?

result-type = type-identifier .

20. For the following rules, I couldn't find a definition in the Language Reference. Can I assume they can all be defined as <single-quoted-string> ?

guid = single-quoted-string .
string-constant-declaration = single-quoted-string . string-literal = single-quoted-string .
stringconstant = single-quoted-string .

where <single-quoted-string> is a parser built-in rule that parses two consecutive single-quote chars as a literal single-quote char ? and that may not contain CR and LF characters ? or any other control characters ?

21. Can I assume ?

statement-list = statement { ";" statement } .
statementlist = statement-list .

22. Various rules refer to a rule <variable-reference> for which I can't find the rule. What is it ?

23. Section 12.2 defines a rule <function-call> that references rules <qualified-method-designator> and <method-designator>.

function-call = ( function-identifier | method-designator | qualified-method-designator | variable-reference ) [ actual-parameter-list ] .

I can't find the rules for <qualified-method-designator> and <method-designator>. What are they ?

24. Sections 14.4.1 and 14.4.4 define rules that refer to a rule <default-parameter-value>.

value-parameter = identifier-list ":" [ "ARRAY" "OF" ] parameter-type | identifier ":" type-identifier "=" default-parameter-value .
constant-parameter = "CONST" ( identifier-list [ ":" [ "ARRAY" "OF" ] type-identifier ] | identifier ":" type-identifier "=" default-parameter-value ) .

I can't find the rule for <default-parameter-value>. What is it ?

25. Section 16.2 defines a rule <interface-part> that refers to a rule <property-declaration-part>

interface-part = "INTERFACE" [ uses-clause ] { constant-declaration-part | type-declaration-part | variable-declaration-part | property-declaration-part | procedure-headers-part } .

I can't find the rule <property-declaration-part>. What is it ?

(more to follow)

Reply by email

Michael Van Canneyt
to Adriaan van Os
Adriaan van Os wrote 21 lines
More questions about the FreePascal Language Reference (version 3.2.0) part 2 17. For the following rules, I couldn't find a definition in the Language Reference. Can I assume they can all be defined as <identifier> ? object-type-identifier = identifier . field-identifier = identifier . interface-identifier = identifier . interface-type-identifier = identifier . method-identifier = identifier . procedure-identifier = identifier . protocol-identifier = identifier . protocol-type-identifier = identifier . qualified-method-identifier = identifier . result-identifier = identifier . type-identifier = identifier . function-identifier = identifier . unit-identifier = identifier . variable-identifier = identifier .

Yes.

The idea was to use these "dedicated names" to convey that the identifier must be of a certain type.

You cannot express this concept in a formal syntax, but for a formal syntax the above is correct.

Show quoted text 8 lines
18. Section 14.4.1 defines a rule <value-parameter> value-parameter = identifier-list ":" [ "ARRAY" "OF" ] parameter-type | identifier ":" type-identifier "=" default-parameter-value . I couldn't find a rule for <parameter-type>. If <parameter-type> equals <type-identifier> then it may be easier to name it <type-identifier> ?

Not quite. it can also be 'const' (the 'array of const' construct).

This diagram needs to be enhanced, I suppose the following is more correct:

(identifier [ "=" constant-expression ] | "array" "of" ("const" | identifier))

Show quoted text 14 lines
19. Sections 3.6, 14.2 and 15.2 refer to a rule <result-type>. function-header = "FUNCTION" formal-parameter-list ":" result-type . function-header = "FUNCTION" ( identifier | qualified-method-identifier ) formal-parameter-list ":" result-type [ modifiers ] [ hintdirectives ] . operator-definition = "operator" ( assignment-operator-definition | arithmetic-operator-definition | comparision-operator-definition ) result-identifier ":" result-type ";" subroutine-block . I couldn't find a rule for <result-type>. Can I assume ? result-type = type-identifier .

Yes.

Show quoted text 8 lines
20. For the following rules, I couldn't find a definition in the Language Reference. Can I assume they can all be defined as <single-quoted-string> ? guid = single-quoted-string . string-constant-declaration = single-quoted-string . string-literal = single-quoted-string . stringconstant = single-quoted-string .

Yes.

where <single-quoted-string> is a parser built-in rule that parses two consecutive single-quote chars as a literal single-quote char ? and that may not contain CR and LF characters ? or any other control characters ?

Yes.
Following your remarks, I was planning to introduce a list of "parser built-in" rules, as I need them to define the constants.

Show quoted text 5 lines
21. Can I assume ? statement-list = statement { ";" statement } . statementlist = statement-list .

Yes.

22. Various rules refer to a rule <variable-reference> for which I can't find the rule. What is it ?

identifier.

Show quoted text 10 lines
23. Section 12.2 defines a rule <function-call> that references rules <qualified-method-designator> and <method-designator>. function-call = ( function-identifier | method-designator | qualified-method-designator | variable-reference ) [ actual-parameter-list ] . I can't find the rules for <qualified-method-designator> and <method-designator>. What are they ?

With the appearance of nested classes and type definitions, they are actually the same.

method-designator = qualified-method-designator = identifier ({ "." identifier })

So the function-call can be simplified to
function-call = ( method-designator | variable-reference ) [ actual-parameter-list ]

maybe introducing a

fully-qualified-identifier = identifier ({ "." identifier })

and using that everywhere instead is a better approach.

Show quoted text 11 lines
24. Sections 14.4.1 and 14.4.4 define rules that refer to a rule <default-parameter-value>. value-parameter = identifier-list ":" [ "ARRAY" "OF" ] parameter-type | identifier ":" type-identifier "=" default-parameter-value . constant-parameter = "CONST" ( identifier-list [ ":" [ "ARRAY" "OF" ] type-identifier ] | identifier ":" type-identifier "=" default-parameter-value ) . I can't find the rule for <default-parameter-value>. What is it ?

default-parameter-value = constant-expression

Show quoted text 10 lines
25. Section 16.2 defines a rule <interface-part> that refers to a rule <property-declaration-part> interface-part = "INTERFACE" [ uses-clause ] { constant-declaration-part | type-declaration-part | variable-declaration-part | property-declaration-part | procedure-headers-part } . I can't find the rule <property-declaration-part>. What is it ?

That should be
property-declaration-part = property definition { ";" property definition }

("property definition" is defined in the class declaration diagram)

Michael.

Reply by email

Adriaan van Os
to Michael Van Canneyt
Michael Van Canneyt wrote 34 lines
On Sat, 16 Dec 2023, Adriaan van Os via fpc-pascal wrote: > > More questions about the FreePascal Language Reference (version > 3.2.0) part 2 > > 17. For the following rules, I couldn't find a definition in the > Language Reference. Can I assume they can all be defined as > <identifier> ? > > object-type-identifier = identifier . > field-identifier = identifier . > interface-identifier = identifier . > interface-type-identifier = identifier . > method-identifier = identifier . > procedure-identifier = identifier . > protocol-identifier = identifier . > protocol-type-identifier = identifier . > qualified-method-identifier = identifier . > result-identifier = identifier . > type-identifier = identifier . > function-identifier = identifier . > unit-identifier = identifier . > variable-identifier = identifier . Yes. The idea was to use these "dedicated names" to convey that the identifier must be of a certain type. You cannot express this concept in a formal syntax, but for a formal syntax the above is correct.

Of course, a rule like

proc-identifier = procedure-identifier | function-identifier .

makes no sense without the semantics of a symbol table (to decide between the two), but rules like

procedure-heading = "PROCEDURE" procedure-identifier .... function-heading = "FUNCTION" function-identifier .... procedure-identifier = identifier .
function-identifier = identifier .

do make sense, even without semantics, because in the parsing(-only) tree, a procedure-identifier (etc.) node is now marked as such, and not just as identifier. In certain applications of a parsing(-only) tree this is quite useful.

Regards,

Adriaan van Os

Reply by email