Code Monkey home page Code Monkey logo

Comments (21)

mike-lischke avatar mike-lischke commented on May 23, 2024 2

There was an error in the interpreter file name construction, which is fixed now. Until the next release you can split your combined grammar into individual lexer and parser grammars. This should work.

from vscode-antlr4.

mike-lischke avatar mike-lischke commented on May 23, 2024 1

Try all that again. I had some changes not yet published in my antlr4-c3 node module.

from vscode-antlr4.

smwikipedia avatar smwikipedia commented on May 23, 2024 1

Now the npm commands finished without error. I manually copied all the js files from the output folder to the extension folder. I can debug and see ATN graphs now. Many thanks!

debug and atn

from vscode-antlr4.

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

What happens when you change something and save the grammar. Does it show the little busy animation in the status bar? Does the ATN graph show something useful afterwards?

from vscode-antlr4.

smwikipedia avatar smwikipedia commented on May 23, 2024

Yes, it shows a little busy animation in the status bar after I modify and save the grammar. And I can see new parser files generated. But still cannot see ATN graph. The error is as the screenshot. But I can see rail road diagram.

from vscode-antlr4.

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

Are there any error messages in the Developer Tools console (see help menu)?

from vscode-antlr4.

smwikipedia avatar smwikipedia commented on May 23, 2024

I tried below:
Open Help -> Developer Tools -> Console (Choose verbose mode in filter)
Open a .g4 file and modify and save.

What I see:
Busy animation shows.
New parser files generated.
Nothing shows in Developer Tools Console.

Now I am trying to reinstall the VS Code and the ANTLR plugin.

from vscode-antlr4.

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

Does the call graph show up? Does debugging work? The message you see about no ATN data found means the *.interp files couldn't be loaded. The question is: why? Are they generated and reachable?

from vscode-antlr4.

smwikipedia avatar smwikipedia commented on May 23, 2024

I tried the C# target and Java target with C.g4. In both scenarios, a CLexer.interp file got generated. But I don't know why they cannot be loaded.

I haven't tried the debugging. But I will try it.

Below are my user settings:


{
    "window.zoomLevel": 0,
    "workbench.colorTheme": "Visual Studio Dark",
    "editor.renderWhitespace": "all",
    "python.linting.enabled": false,
    "antlr4.generation": {
        "mode": "external",
        "language": "Java",
        "listeners": true,
        "visitors": false,
        "outputDir": "Java"
    },
    "antlr4.rrd.saveDir": "antlr4.rrd",
    "antlr4.atn.saveDir": "antlr4.atn",
    "antlr4.call-graph.saveDir": "antlr4.callgraph"
}

from vscode-antlr4.

smwikipedia avatar smwikipedia commented on May 23, 2024

I just tried the debug feature. There seems to be some issue.

My 1st debug settings:

{
    "version": "2.0.0",
    "configurations": [
        {
            "name": "antlr4-c",
            "type": "antlr-debug",
            "request": "launch",
            "input": "${workspaceFolder}/${command:AskForTestInput}",
            //"input": "../TestSuite/full.c",
            "grammar": "C.g4",
            "startRule": "compilationUnit",
            "printParseTree": true,
            "visualParseTree": true
        }
    ]
}

I got this error:

debug1failure

My 2nd debug settings:


{
    "version": "2.0.0",
    "configurations": [
        {
            "name": "antlr4-c",
            "type": "antlr-debug",
            "request": "launch",
            //"input": "${workspaceFolder}/${command:AskForTestInput}",
            "input": "../TestSuite/full.c",    // <===============HERE changes.
            "grammar": "C.g4",
            "startRule": "compilationUnit",
            "printParseTree": true,
            "visualParseTree": true
        }
    ]
}

debug2failure

I guess the *.interp is the interpreter data in above screenshot. So I guess same issue as ATN graph here.

But the *.interp file did get generated. See below.

debug3failure

from vscode-antlr4.

smwikipedia avatar smwikipedia commented on May 23, 2024

I just tried reinstall Visual Studio Code and the ANTLR extension. Still the same error.

from vscode-antlr4.

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

That's not a vscode issue. There are several problems at work here.

For debugging:

  • The action to ask for that file wasn't recognized, which is totally strange. As a consequence that action was taken as file name.
  • In the second case it seems as if the grammar wasn't read from the config, even though it's there. There's a mode where the debugger uses the currently active editor, if that is a grammar, if no grammar is given in the config. If the current editor is not debuggable by the antlr4 extension it shows that other error.

Also for the debugger you need the ATN data. You found the *.interp files in the target folder, right? But for ATN + debugging they must be in the internal .antlr folder (in the same folder where your grammar is). Try with internal generation mode. Does this work? Could be something with the interp data move is wrong. These files should be automatically moved from the external output folder to the internal one. You shouldn't even see them.

from vscode-antlr4.

smwikipedia avatar smwikipedia commented on May 23, 2024

I tried below 2 things:

  1. I changed to use "mode": "internal". And I saw below files generated in the .antlr folder.
    internal mode

Then I tried debug by pressing F5. It gave me this:
But the start rule is just there.
start rule error

And the ATN graph failed as before.

  1. Then I tried "mode": "external". And I manually copy the *.interp files to the .antlr folder. And then I tried Debug and ATN graph. Still failed as 1. And below are the logs from the Debug Console:
10:14:03 AM, 3/24/2018
From client: initialize({"clientID":"vscode","adapterID":"antlr-debug","pathFormat":"path","linesStartAt1":true,"columnsStartAt1":true,"supportsVariableType":true,"supportsVariablePaging":true,"supportsRunInTerminalRequest":true,"locale":"en-us"})
To client: {"seq":0,"type":"event","event":"initialized"}
To client: {"seq":0,"type":"response","request_seq":1,"command":"initialize","success":true,"body":{"supportsConfigurationDoneRequest":true,"supportsStepInTargetsRequest":true}}
From client: threads(undefined)
To client: {"seq":0,"type":"response","request_seq":2,"command":"threads","success":true,"body":{"threads":[{"id":1,"name":"Interpreter"}]}}
From client: launch({"name":"antlr4-c","type":"antlr-debug","request":"launch","input":"c:\\Test\\TestSuite\\full.c","grammar":"c:\\Test\\grammar\\C.g4","startRule":"compilationUnit","trace":true,"printParseTree":true,"visualParseTree":true,"debugServer":17865,"__sessionId":"42bc26d0-999c-426d-985f-810661544990"})
To client: {"seq":0,"type":"response","request_seq":3,"command":"launch","success":false,"message":"Error while launching debug session: start rule \"compilationUnit\" not found","body":{"error":{"id":1,"format":"Error while launching debug session: start rule \"compilationUnit\" not found"}}}
From client: disconnect({"restart":false})
To client: {"seq":0,"type":"response","request_seq":4,"command":"disconnect","success":true}

And this is the g4 file I used.

C.g4.zip

from vscode-antlr4.

smwikipedia avatar smwikipedia commented on May 23, 2024

Thanks for the quick fix. Looking forward to the new release.

from vscode-antlr4.

smwikipedia avatar smwikipedia commented on May 23, 2024

BTW, I just tried splitting my grammar into individual parser and lexer grammars. Unfortunately, still the same error.

It seems the split parser grammar CParserRules.g4 still generate its own CParserRulesLexer.interp file. So now, I got 3 *.interp files. Hope this won't be an issue. See below:

split grammar

My split grammars:
CParser&LexerRules.zip

And the 3 interp files:
3 interp files.zip

from vscode-antlr4.

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

Now, that's a situation I hadn't on the radar. You get 3 files because you still have lexer rules in your parser grammar (all the text literals) which cause ANTLR4 to generate that CParserRuleLexer.

However, that shouldn't affect the load of the interpreter data. Though, I just found another bug and fixed it. The previous change went a little too far. Can you clone the repo, transpile the TS code and manually copy the SourceContext.js file the extension folder (the one in your home dir, as given in the error screenshot above)? This way you should finally get what you want without waiting for the next release of the extension.

from vscode-antlr4.

smwikipedia avatar smwikipedia commented on May 23, 2024

I am not familiar with TS project. Here is what I tried:

  1. cloned the repo.
  2. run tsc --out SourceContext.js SourceContext.ts

Then I got many errors. Such as:

C:\D\Sources.2\github\vscode-antlr4\src\backend\SourceContext.ts(13,1): error TS1008: Unexpected token; 'module, class, interface, enum, import or statement' expected.
C:\D\Sources.2\github\vscode-antlr4\src\backend\SourceContext.ts(13,8): error TS1008: Unexpected token; 'module, class, interface, enum, import or statement' expected.
C:\D\Sources.2\github\vscode-antlr4\src\backend\SourceContext.ts(13,13): error TS1005: ';' expected.
C:\D\Sources.2\github\vscode-antlr4\src\backend\SourceContext.ts(13,27): error TS1005: ';' expected.
C:\D\Sources.2\github\vscode-antlr4\src\backend\SourceContext.ts(13,32): error TS1005: ';' expected.
C:\D\Sources.2\github\vscode-antlr4\src\backend\SourceContext.ts(14,1): error TS1008: Unexpected toke
...


Then I tried to open it in VS code as workspace. Then run Ctrl+Shift+B. VS Code complains that :

The following workspace folders are ingored since they use task version 0.1.0: vscode-antlr4.

I installed tsc and node, maybe I missed something.

  • tsc v1.0.3.0
  • node v9.9.0

I am learning the TS related knowledge now.

from vscode-antlr4.

mike-lischke avatar mike-lischke commented on May 23, 2024
Mikes-iMac:vscode-antlr4 mike$ npm update
+ [email protected]
+ @types/[email protected]
updated 11 packages in 7.924s
Mikes-iMac:vscode-antlr4 mike$ npm install

> [email protected] postinstall /Volumes/Extern/Work/projects/vscode-antlr4
> node ./node_modules/vscode/bin/install

Detected VS Code engine version: ^1.17.0
Found minimal version that qualifies engine range: 1.17.0
Fetching vscode.d.ts from: https://raw.githubusercontent.com/Microsoft/vscode/be377c0faf7574a59f84940f593a6849f12e4de7/src/vs/vscode.d.ts
vscode.d.ts successfully installed!

up to date in 2.685s
Mikes-iMac:vscode-antlr4 mike$ npm run compile

> [email protected] compile /Volumes/Extern/Work/projects/vscode-antlr4
> tsc --outDir ./out/src

Mikes-iMac:vscode-antlr4 mike$ 

Then in out/src/frontend you can find the transpiled SourceContext.js.

from vscode-antlr4.

smwikipedia avatar smwikipedia commented on May 23, 2024

Below are my try. Bold part are my command inputs.

C:\D\Sources.2\github\vscode-antlr4>npm update

C:\D\Sources.2\github\vscode-antlr4>npm install

> [email protected] postinstall C:\D\Sources.2\github\vscode-antlr4
> node ./node_modules/vscode/bin/install

Detected VS Code engine version: ^1.17.0
Found minimal version that qualifies engine range: 1.17.0
Fetching vscode.d.ts from: https://raw.githubusercontent.com/Microsoft/vscode/be377c0faf7574a59f84940f593a6849f12e4de7/src/vs/vscode.d.ts
vscode.d.ts successfully installed!

C:\D\Sources.2\github\vscode-antlr4>npm run compile

> [email protected] compile C:\D\Sources.2\github\vscode-antlr4
> tsc --outDir ./out/src

src/backend/ContextSymbolTable.ts(255,38): error TS2554: Expected 0 arguments, but got 1.
src/backend/SourceContext.ts(593,78): error TS2339: Property 'add' does not exist on type 'Symbol[]'.
src/backend/SourceContext.ts(596,9): error TS2322: Type 'Symbol[]' is not assignable to type 'Set'.
Property 'add' is missing in type 'Symbol[]'.
src/backend/facade.ts(479,38): error TS2554: Expected 0 arguments, but got 1.
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! [email protected] compile: tsc --outDir ./out/src
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the [email protected] compile script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\mshao\AppData\Roaming\npm-cache_logs\2018-03-24T16_02_25_053Z-debug.log

from vscode-antlr4.

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

If you like rate the extension on the vscode Marketplace.

from vscode-antlr4.

smwikipedia avatar smwikipedia commented on May 23, 2024

Sure I will rate it 5.😀

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.