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

Allow multiple adjacent string literals in lark grammar #3143

Closed
wants to merge 2 commits into from

Conversation

benber86
Copy link
Contributor

@benber86 benber86 commented Nov 2, 2022

What I did

Python and Vyper allow multiple adjacent string literals like b: String[4] = "aa" "bb" or b: String[4] = "aa"'bb'.

I updated the lark grammar to handle parsing such statements which are currently unsupported.

How I did it

Added a ?strings: STRING+ rule and changed STRING to strings in the ?literal rule.

How to verify it

The following Vyper code:

b: constant(String[4]) = 'aa'"bb"

can now be parsed as:

[Node(constant_def, [Node(constant_private, [Leaf(NAME, 'b'), Leaf(COLON, ':'), Node(constant, [Leaf(CONSTANT, 'constant'), Leaf(LPAR, '('), Node(type, [Node(array_def, [Leaf(NAME, 'String'), Leaf(LSQB, '['), Leaf(DEC_NUMBER, '4'), Leaf(RSQB, ']')])]), Leaf(RPAR, ')')])]), Leaf(EQUAL, '='), Node(strings, [Leaf(STRING, "'aa'"), Leaf(STRING, '"bb"')])]), Leaf(_NEWLINE, '\n\n')]

Commit message

Allow multiple adjacent string literals in lark grammar

Description for the changelog

Cute Animal Picture

image

@codecov-commenter
Copy link

codecov-commenter commented Nov 2, 2022

Codecov Report

Merging #3143 (3936ead) into master (5d10ea0) will decrease coverage by 1.02%.
Report is 1 commits behind head on master.
The diff coverage is n/a.

❗ Current head 3936ead differs from pull request most recent head f53fef2. Consider uploading reports for the commit f53fef2 to get more accurate results

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

@@            Coverage Diff             @@
##           master    #3143      +/-   ##
==========================================
- Coverage   89.50%   88.49%   -1.02%     
==========================================
  Files          80       95      +15     
  Lines       11342    10760     -582     
  Branches     2553     2266     -287     
==========================================
- Hits        10152     9522     -630     
+ Misses        797      796       -1     
- Partials      393      442      +49     

see 113 files with indirect coverage changes

📣 Codecov offers a browser extension for seamless coverage viewing on GitHub. Try it in Chrome or Firefox today!

@charles-cooper charles-cooper enabled auto-merge (squash) November 7, 2023 22:36
@charles-cooper
Copy link
Member

on second thought, i think this results in harder to read code, and we shouldn't officially support it in the vyper grammar.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants