Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the wrong look-ahead for the TypeDecl rule #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tomalla5120x
Copy link

Given the following code:

unit Unit1;
interface
type
    TMyClass = class
    private
        type
            TMyRec = record
            end;
    protected
        Foo: Integer;
    end;
implementation
end.

The parser incorrectly interprets the semi-keyword 'protected' as a
type identifier and issues the following error message: "Expected
EqualSign but found Identifier".

The visibility specifiers are indeed semi-keywords, i.e. they can in
certain situations be treated as identifiers (like procedure names
for instance). This however is an exception, where visibility specifiers
strict, private, public, protected and published (among other keywords
like procedure, class or type) explicitly terminate the nested type
declarations section.

The solution was simple: in a look-ahead procedure for the TypeDecl rule,
I added an additional constraint check for visibility semi-keywords. If
they are present, the rule is no longer accepted and the type section is
terminated.

Given the following code:

unit Unit1;
interface
type
    TMyClass = class
    private
        type
            TMyRec = record
            end;
    protected
        Foo: Integer;
    end;
implementation
end.

The parser incorrectly interprets the semi-keyword 'protected' as a
type identifier and issues the following error message: "Expected
EqualSign but found Identifier".

The visibility specifiers are indeed semi-keywords, i.e. they can in
certain situations be treated as identifiers (like procedure names
for instance). This however is an exception, where visibility specifiers
strict, private, public, protected and published (among other keywords
like procedure, class or type) explicitly terminate the nested type
declarations section.

The solution was simple: in a look-ahead procedure for the TypeDecl rule,
I added an additional constraint check for visibility semi-keywords. If
they are present, the rule is no longer accepted and the type section is
terminated.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants