Re: [fpc-pascal] More syntax questions (part 2)
Michael Van Canneyt via fpc-pascal wrote: 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 ? 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 ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] More syntax questions (part 2)
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 ? 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 = identifier-list ":" [ "ARRAY" "OF" ] parameter-type | identifier ":" type-identifier "=" default-parameter-value . I couldn't find a rule for . If equals then it may be easier to name it ? 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 . 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 . 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 ? guid = single-quoted-string . string-constant-declaration = single-quoted-string . string-literal = single-quoted-string . stringconstant = single-quoted-string . Yes. where 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 for which I can't find the rule. What is it ? identifier. 23. Section 12.2 defines a rule that references rules and . function-call = ( function-identifier | method-designator | qualified-method-designator | variable-reference ) [ actual-parameter-list ] . I can't find the rules for and . 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 . 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 . What is it ? default-parameter-value = constant-expression 25. Section 16.2 defines a rule that refers to a rule 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 . 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
[fpc-pascal] More syntax questions (part 2)
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 ? 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 = identifier-list ":" [ "ARRAY" "OF" ] parameter-type | identifier ":" type-identifier "=" default-parameter-value . I couldn't find a rule for . If equals then it may be easier to name it ? 19. Sections 3.6, 14.2 and 15.2 refer to a rule . 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 . 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 ? guid = single-quoted-string . string-constant-declaration = single-quoted-string . string-literal = single-quoted-string . stringconstant = single-quoted-string . where 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 for which I can't find the rule. What is it ? 23. Section 12.2 defines a rule that references rules and . function-call = ( function-identifier | method-designator | qualified-method-designator | variable-reference ) [ actual-parameter-list ] . I can't find the rules for and . What are they ? 24. Sections 14.4.1 and 14.4.4 define rules that refer to a rule . 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 . What is it ? 25. Section 16.2 defines a rule that refers to a rule 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 . What is it ? (more to follow) ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal