oranoran / antlr4-autosuggest-js

JavaScript auto-suggest engine for ANTLR4 grammars
MIT License
42 stars 16 forks source link

Not able to make correct suggestion #1

Closed debashish2014 closed 6 years ago

debashish2014 commented 6 years ago

Hi,

I am using the following Test.G4, which is a very simple grammar for variable declaration.

grammar Test;

file: (varDecl)+ EOF;

varDecl : type ID '=' NUMBER ';' ;

type: 'float' | 'int' | 'decimal' ; // user-defined types

ID : LETTER (LETTER | [0-9])* ;

NUMBER: DIGIT+;

fragment LETTER : [a-zA-Z] ;

fragment DIGIT : [0-9];

SPACES : [ \u000B\t\r\n] -> channel(HIDDEN) ;

Ideally, if a user types "int a", then the expected suggestions will be '=', but it is not finding any suggestion. Anything wrong here?

oranoran commented 6 years ago

@debashish2014, thanks for reporting. I found & fixed the root cause. Will push and publish an update soon, pending a final review of the code.

oranoran commented 6 years ago

@debashish2014, version 0.2.2 has been built with this fix. Will close the issue in the next few days unless you report any further issues.

debashish2014 commented 6 years ago

Hi @oranoran , Thank you for the fix. I will test and verify.

debashish2014 commented 6 years ago

Hi @oranoran , Thank you so much for authoring such a wonderful project. The issue has been fixed for the Test.G4.

However, I wrote another grammar file for testing as shown below, which unfortunately is not working. If user types 'SHOW EMPLOYEE' or 'SELECT EMPLOYEE' then the suggestion should be 'FOR' and 'WHERE'.

grammar autocomplete;

query : query_stmt EOF ;

query_stmt : start_keyword literal_name filter_name ;

filter_name : 'FOR' | 'WHERE' ;

start_keyword : 'SHOW' | 'SELECT' ;

literal_name : IDENTIFIER ;

IDENTIFIER: LETTER (LETTER | [0-9])*;

SPACES : [ \u000B\t\r\n] -> channel(HIDDEN) ;

UNEXPECTED_CHAR : . ;

fragment DIGIT : [0-9];

fragment LETTER : [a-zA-Z] ;

oranoran commented 6 years ago

Thanks @debashish2014! Can you create a new issue for this? I will close this one and check out the new issue.

debashish2014 commented 6 years ago

Sure thing. Will do.