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.


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))


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.


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.


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.


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.


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


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.
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to