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

Adding lexer for CDDL #1239

Closed
Anteru opened this issue Aug 31, 2019 · 6 comments
Closed

Adding lexer for CDDL #1239

Anteru opened this issue Aug 31, 2019 · 6 comments
Labels
A-lexing area: changes to individual lexers S-minor severity: minor T-feature type: a new feature X-imported imported from Bitbucket

Comments

@Anteru
Copy link
Collaborator

Anteru commented Aug 31, 2019

(Original issue 1535 created by tdubouch on 2019-08-17T06:56:37.002511+00:00)

Concise Data Definition Language (CDDL) describes JSON or CBOR data structure and has been standardized as of RFC 8610.

A first attempt at writing a lexer is available here. The lexer is loosely based on the grammar in the RFC but is already handling most of the cases. The test file contains all of the examples from the RFC.

@Anteru Anteru added T-feature type: a new feature X-imported imported from Bitbucket S-minor severity: minor labels Aug 31, 2019
@birkenfeld birkenfeld added the A-lexing area: changes to individual lexers label Nov 25, 2019
@birkenfeld
Copy link
Member

Please file a pull request 😄

@hellp
Copy link

hellp commented Jan 16, 2020

I've also worked on a CDDL lexer for pygments: https://github.com/hellp/pygments-cddl-lexer/ — not sure if I'll come back to it, but IIRC it's pretty complete, based on the RFC from March 2019.

@serianox
Copy link
Contributor

serianox commented Feb 2, 2020

Since @hellp lexer seemed much more cleaner and complete, I integrated it instead of mine (see #1379).

I had to fix one thing though, and I still don't know what happened. The first rule r'#' would send the lexer into infinite loop, and changing it to r[#] fixed the issue.

@hellp Is this ok with you?

@serianox
Copy link
Contributor

serianox commented Feb 2, 2020

Ok, just found out.
I had to set the whole regex to re.VERBOSE, because inline modifiers are now forbidden in Python re module. But then, the regex r'#' would become r'', which is indeed an infinite loop. Escaping the pound solves this... :|

@hellp
Copy link

hellp commented Feb 3, 2020

I'm fine with whatever works. Was the behavior of inline modifiers changed recently? It worked for me, I guess.

@serianox
Copy link
Contributor

serianox commented Feb 3, 2020

@hellp I discovered they have been deprecated in Python 3.x (maybe 3.4+), and are now forbidden at least in Python 3.7.5. Hence the changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lexing area: changes to individual lexers S-minor severity: minor T-feature type: a new feature X-imported imported from Bitbucket
Projects
None yet
Development

No branches or pull requests

4 participants