On 16 Feb 2017, at 02:49, Paul Isaacs <paul@redpineinstruments.org> wrote:

I can’t say I follow you exactly...

Hello Bastiaan,

Is the sentence a(x).field1.field2 a syntactically valid outcome of the function-access production?

1) function-access                       = component- function access
2) component-function-access   = record-function-access

substituting 2) in 1)
3) function-access                       = record-function-access

4) record-function-access          = record-function '.' field-specifier
substituting 4) in 3)

5) function-access                       = record-function '.' field-specifier

6) record-function                        = function-access
substituting 6) in 5)

7) function-access                       = function-access '.' field-specifier

which makes function-access left recursive.

Is 7) lexically valid but semantically invalid because function-access '.' field-specifier can not be a function-access?

For what it’s worth, my parser fails to parse the following:

program isaacs;

begin
    a(x).field1.field2;
end.


EP (failure)
 +-EP.BNVCompileUnit (failure)
    +-EP.Program (failure)
       +-EP.ProgramBlock (failure)
          +-EP.ProgramComponent (failure)
             +-EP.MainProgramDeclaration (failure)
                +-EP.ProgramHeading [0, 14]["program", "isaacs"]
                |  +-EP.PROGRAM [0, 7]["program"]
                |  +-EP.BNVProgramName [8, 14]["isaacs"]
                |     +-EP.Identifier [8, 14]["isaacs"]
                |        +-EP.BNVAnyIdentifier [8, 14]["isaacs"]
                +-EP.MainProgramBlock (failure)
                   +-EP.Block (failure)
                      +-EP.StatementPart (failure)
                         +-EP.CompoundStatement (failure)
                            +-EP._ [22, 27]["\n    "]
                            |  +-EP.Spacing [22, 27]["\n    "]
                            +-EP.StatementSequence [27, 31]["a", "(", "x", ")"]
                            |  +-EP.Statement [27, 31]["a", "(", "x", ")"]
                            |     +-EP.SimpleStatement [27, 31]["a", "(", "x", ")"]
                            |        +-EP.ProcedureStatement [27, 31]["a", "(", "x", ")"]
                            |           +-EP.ProcedureName [27, 28]["a"]
                            |           |  +-EP.ProcedureIdentifier [27, 28]["a"]
                            |           |     +-EP.Identifier [27, 28]["a"]
                            |           |        +-EP.BNVAnyIdentifier [27, 28]["a"]
                            |           +-EP.ActualParameterList [28, 31]["(", "x", ")"]
                            |              +-EP.ActualParameter [29, 30]["x"]
                            |                 +-EP.Expression [29, 30]["x"]
                            |                    +-EP.SimpleExpression [29, 30]["x"]
                            |                       +-EP.Term [29, 30]["x"]
                            |                          +-EP.Factor [29, 30]["x"]
                            |                             +-EP.Primary [29, 30]["x"]
                            |                                +-EP.FunctionAccess [29, 30]["x"]
                            |                                   +-EP.EntireFunctionAccess [29, 30]["x"]
                            |                                      +-EP.FunctionDesignator [29, 30]["x"]
                            |                                         +-EP.FunctionName [29, 30]["x"]
                            |                                            +-EP.FunctionIdentifier [29, 30]["x"]
                            |                                               +-EP.Identifier [29, 30]["x"]
                            |                                                  +-EP.BNVAnyIdentifier [29, 30]["x"]
                            +-discard!(EP.END) failure at line 3, col 8, after "n\n    a(x)" expected "\"end\"", but got ".field1.fi"