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

add lark-based grammar #325

Merged
merged 3 commits into from
Nov 15, 2018
Merged

add lark-based grammar #325

merged 3 commits into from
Nov 15, 2018

Conversation

dirk-thomas
Copy link
Member

@dirk-thomas dirk-thomas commented Nov 15, 2018

This is the fourth PR integrating #298 step-by-step.

Builds on top of #324.

The grammar covers a subset of the IDL spec.

Linux CI: Build Status

@dirk-thomas dirk-thomas added enhancement New feature or request in review Waiting for review (Kanban column) labels Nov 15, 2018
@dirk-thomas dirk-thomas self-assigned this Nov 15, 2018
@dirk-thomas dirk-thomas requested a review from sloretz November 15, 2018 00:32
@dirk-thomas dirk-thomas force-pushed the idl-stage-4 branch 2 times, most recently from 5a3c364 to 3acd3ea Compare November 15, 2018 04:44
@dirk-thomas dirk-thomas changed the title add lark-based grammar and ast-to-object representation add lark-based grammar Nov 15, 2018
@dirk-thomas dirk-thomas force-pushed the idl-stage-4 branch 2 times, most recently from ea95a18 to 21c349a Compare November 15, 2018 17:25
Copy link
Contributor

@sloretz sloretz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems fine to me.

I played around with it locally using

import os
path = os.path.dirname(__file__)
with open(os.path.join(path, 'grammar.lark')) as fin:
    grammar = fin.read()

from lark import Lark
parser = Lark(grammar, start='specification')

import code
code.interact(local=locals())

There are some odd things that I assume will be caught by something after the parser, like any literal can be assigned to any type.

# Parser accepts this
parser.parse('const double not_a_double = "Hello World";')

rosidl_parser/rosidl_parser/grammar.lark Show resolved Hide resolved
rosidl_parser/rosidl_parser/grammar.lark Outdated Show resolved Hide resolved
@dirk-thomas
Copy link
Member Author

any literal can be assigned to any type.

Correct, that kind of check is out of scope for the grammar.

@dirk-thomas
Copy link
Member Author

dirk-thomas commented Nov 15, 2018

I disabled the union_dcl as well as the native_dcl which we both don't support atm: 95b264f

@dirk-thomas dirk-thomas merged commit 83baf3c into master Nov 15, 2018
@dirk-thomas dirk-thomas deleted the idl-stage-4 branch November 15, 2018 22:38
@dirk-thomas dirk-thomas removed the in review Waiting for review (Kanban column) label Nov 15, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants