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

remove constraints on rules and token names #1291

Closed
jlguenego opened this issue Dec 13, 2020 · 7 comments
Closed

remove constraints on rules and token names #1291

jlguenego opened this issue Dec 13, 2020 · 7 comments
Labels

Comments

@jlguenego
Copy link
Contributor

First of all, thanks for this great lib.

I have this error during the performSelfAnalysis check.

Error: Parser Definition Errors detected:
 Invalid Grammar Token name: ->ENCODING-CONTROL<- it must match the pattern: ->/^[a-zA-Z_]\w*$/<-
    at D:\formation\asn.1\node_modules\chevrotain\src\parse\parser\parser.ts:237:15
    at ASN1CstParser.PerformanceTracer.TRACE_INIT (D:\formation\asn.1\node_modules\chevrotain\src\parse\parser\traits\perf_tracer.ts:50:14)
    at ASN1CstParser.Parser.j(D:\formation\asn.1\node_modules\chevrotain\src\parse\parser\parser.ts:151:10)
    at new ASN1CstParser (D:\formation\asn.1\src\analysis\ASN1CstParser.ts:169:10)

In the ASN1 language, there are some keyword that contains a dash character (-) like for instance :

ENCODING-CONTROL
RELATIVE-OID-IRI
ABSTRACT-SYNTAX
TYPE-IDENTIFIER
MINUS-INFINITY
PLUS-INFINITY
NOT-A-NUMBER
RELATIVE-OID
TIME-OF-DAY
DATE-TIME
OID-IRI

Is there a reason for this control ?
What is the recommanded way to proceed with this kind of keyword?

You can see my library that is using chevrotain here:
https://github.com/jlguenego/asn.1

@bd82
Copy link
Member

bd82 commented Dec 14, 2020

I think this constraint is an historic leftover which could be removed (PRs welcome 😄 ).

However the limitation is on a token's name, not what the token pattern matches.
So there is nothing stopping you from creating a ENCODING_CONTROL token which consumes "ENCODING-CONTROL" string

@jlguenego
Copy link
Contributor Author

understood. So this is not a critical bug .
Nonetheless I am going to do this PR ... for fun 😄

@bd82
Copy link
Member

bd82 commented Dec 16, 2020

That would be most welcome 👍

jlguenego added a commit to jlguenego/chevrotain that referenced this issue Dec 16, 2020
@jlguenego
Copy link
Contributor Author

I tried to do it ;)

jlguenego added a commit to jlguenego/chevrotain that referenced this issue Dec 20, 2020
@bd82 bd82 changed the title ASN1 keyword with dash ('-') character not accepted. Why that ? Un-needed limitations of Token and Rule names ? Dec 21, 2020
@bd82 bd82 changed the title Un-needed limitations of Token and Rule names ? Un-needed constraints of Token and Rule names ? Dec 21, 2020
@bd82 bd82 closed this as completed in a794d0e Dec 21, 2020
@jlguenego
Copy link
Contributor Author

jlguenego commented Dec 21, 2020

Just for info, I just released a website that shows ASN.1 language stuff. This website is using chevrotain behinds.
https://asn1.netlify.app/

Thanks again for this.

@bd82
Copy link
Member

bd82 commented Dec 22, 2020

Now I finally know what ASN.1 is:

I will hopefully release a new Version of Chevrotain with the fix later this week.
I will keep the issue open until then.

@bd82 bd82 reopened this Dec 22, 2020
@bd82 bd82 added the API label Jan 2, 2021
@bd82 bd82 changed the title Un-needed constraints of Token and Rule names ? remove constraints on rules and token names Jan 2, 2021
@bd82
Copy link
Member

bd82 commented Jan 2, 2021

released in 7.1.0

@bd82 bd82 closed this as completed Jan 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants