Giter Site home page Giter Site logo

Comments (13)

eternalphane avatar eternalphane commented on May 18, 2024

To reproduce:

  1. Create new file A.g4 and save:
parser grammar A
;

options
{
    tokenVocab = ALexer;
}

a
    : A
;
  1. Create new file ALexer.g4 and save:
lexer grammar ALexer
;

A
    : 'a'
;

B
    : 'b'
;

Result:

image

from vscode-antlr4.

eternalphane avatar eternalphane commented on May 18, 2024

Currently I have to cut the tokenVocab line - save - paste - save to force the extension to recognize the new tokens.

from vscode-antlr4.

mike-lischke avatar mike-lischke commented on May 18, 2024

Any change in your parser grammar updates the symbol table. You can see that with your reproduction steps. After you created and saved the lexer go back to your parser. Then press the space key and A is suddenly recognized.

from vscode-antlr4.

eternalphane avatar eternalphane commented on May 18, 2024

Well, I made a mistake in the reproduction steps...

  1. Create a new file A.g4 and save:
parser grammar A
;

options
{
    tokenVocab = ALexer;
}

a
    : A
;
  1. Create a new file ALexer.g4 and save:
lexer grammar ALexer
;

A
    : 'a'
;

Now press space and A is recognized.

  1. Add the following to ALexer.g4 and save:
B
    : 'b'
;
  1. Add the following to A.g4 and save:
b
    : B
;

Now the issue is right there: Unknown token reference 'B'.

from vscode-antlr4.

eternalphane avatar eternalphane commented on May 18, 2024

Reopening the parser file can let the new tokens recognized, but I would appreciate it if you could make it work as soon as the lexer file is modified and saved. Maybe add a hook or something?

from vscode-antlr4.

mike-lischke avatar mike-lischke commented on May 18, 2024

Weird. When I add a new lexer symbol in the lexer grammar it is immediately available in the parser grammar. No error marker appears and the symbol info is available. I don't even need to save either file. I tried this also with a fairly complex grammar, which takes a moment to analyze. Still, everything is immediately there. What else could cause your trouble?

from vscode-antlr4.

eternalphane avatar eternalphane commented on May 18, 2024

My configuration:

{
    "antlr4.format.alignColons": "hanging",
    //"antlr4.format.alignLexerCommands": true,
    "antlr4.format.alignSemicolons": "ownLine",
    //"antlr4.format.allowShortBlocksOnASingleLine": false,
    "antlr4.format.allowShortRulesOnASingleLine": false,
    "antlr4.format.breakBeforeBraces": true,
    "antlr4.format.breakBeforeParens": true,
    "antlr4.format.columnLimit": 10000,
    "antlr4.format.minEmptyLines": 1,
    "antlr4.format.reflowComments": false,
    "antlr4.format.useTab": false,
    //"antlr4.referencesCodeLens.enabled": true,
}

VSC information:

版本 1.19.0-insider
提交 d8989c95964ce06c64ffebc2fb400a0327bd447d
日期 2017-12-08T10:45:40.870Z
Shell 1.7.9
渲染器 58.0.3029.110
Node 7.9.0
架构 x64

from vscode-antlr4.

eternalphane avatar eternalphane commented on May 18, 2024

Btw, could you please print some logs (output from antlr4, javac, etc.) in the output window? Of course users can clone the repo and debug the extension in vsc, but it may be better if they can check what's wrong without the need of it.

from vscode-antlr4.

mike-lischke avatar mike-lischke commented on May 18, 2024

Why did you add your formatter settings here? This issue is about unrecognized symbols.

Btw, could you please print some logs (output from antlr4, javac, etc.) in the output window? Of course users can clone the repo and debug the extension in vsc, but it may be better if they can check what's wrong without the need of it.

What do you have in mind that should be printed?

from vscode-antlr4.

eternalphane avatar eternalphane commented on May 18, 2024

Why did you add your formatter settings here? This issue is about unrecognized symbols.

I thought the settings may affect the behavior of the extension, however I've been aware that I was wrong.

What do you have in mind that should be printed?

Emmm... Output from antlr4-graps maybe? I mean I don't quite understand the mechanism of this extension.

from vscode-antlr4.

mike-lischke avatar mike-lischke commented on May 18, 2024

I see, ok. So what about converting this issue into a FR for more debug output? I cannot reproduce the original issue. It seems to work well, as I described above.

from vscode-antlr4.

eternalphane avatar eternalphane commented on May 18, 2024

Fair enough. I'll reinstall vsc and disable other extensions to see if the issue will still persists.

from vscode-antlr4.

mike-lischke avatar mike-lischke commented on May 18, 2024

Thinking about this again, I come to the conclusion that there's nothing here I can do. Adding extra logging calls to the extension code is pretty odd. This is not how problems are handled in vscode extensions. Errors can be seen in the developer tools window and anything else is useless, since nobody is every going to read it.

Better ask specific questions if you need to understand certain processing in the extension.

from vscode-antlr4.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.