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

[Feature] String parsing #974

Merged
merged 25 commits into from
May 24, 2021
Merged

[Feature] String parsing #974

merged 25 commits into from
May 24, 2021

Conversation

damirka
Copy link
Contributor

@damirka damirka commented May 19, 2021

Motivation

Closes #943.
Closes #944.

Test Plan

Features parser tests for string literals.

Related PRs

This PR is targeted to #957.

- currently uses back quotes "`" for strings, change later
- ast -> asg unimplemented, strings need to be processed on
canonicalization stage
@damirka damirka added feature A new feature. help-wanted Extra attention is needed labels May 19, 2021
@damirka damirka added this to the Leo Developer Preview III milestone May 19, 2021
@damirka damirka requested review from Protryon and gluax May 19, 2021 20:39
@damirka damirka self-assigned this May 19, 2021
@codecov
Copy link

codecov bot commented May 19, 2021

Codecov Report

Merging #974 (a3416c1) into feature/char-type (cd95f48) will increase coverage by 0.04%.
The diff coverage is 76.41%.

Impacted file tree graph

@@                  Coverage Diff                  @@
##           feature/char-type     #974      +/-   ##
=====================================================
+ Coverage              75.25%   75.29%   +0.04%     
=====================================================
  Files                    434      435       +1     
  Lines                  17425    17552     +127     
=====================================================
+ Hits                   13113    13216     +103     
- Misses                  4312     4336      +24     
Impacted Files Coverage Δ
asg/src/expression/constant.rs 65.92% <0.00%> (-0.75%) ⬇️
ast/src/errors/reducer.rs 5.55% <0.00%> (-1.59%) ⬇️
input/src/errors/parser.rs 26.53% <0.00%> (-2.36%) ⬇️
input/src/expressions/expression.rs 6.06% <0.00%> (-0.61%) ⬇️
parser/src/tokenizer/mod.rs 97.50% <ø> (-0.04%) ⬇️
input/src/expressions/string_expression.rs 20.00% <20.00%> (ø)
ast/src/expression/value.rs 72.97% <28.57%> (-10.90%) ⬇️
compiler/src/phases/reducing_director.rs 48.07% <60.00%> (-0.41%) ⬇️
input/src/values/char_types.rs 85.07% <72.22%> (+17.76%) ⬆️
parser/src/tokenizer/token.rs 90.52% <75.00%> (+2.29%) ⬆️
... and 16 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cd95f48...a3416c1. Read the comment docs.

@gluax
Copy link
Contributor

gluax commented May 22, 2021

Updated parsing to leverage the char parsing.
Now closes #951.

Wanted to bring up an interesting point I don't think we discussed as well. What about empty string? An empty string in Leo would resolve to [char; 0] which we don't allow.

This was linked to issues May 22, 2021
@gluax gluax linked an issue May 22, 2021 that may be closed by this pull request
4 tasks
@acoglio
Copy link
Collaborator

acoglio commented May 22, 2021

@gluax I think you are right that we didn't discuss the empty string issue at meetings, but it is mentioned in the RFC -- 4th paragraph in https://github.com/AleoHQ/leo/blob/master/docs/rfc/001-initial-strings.md#strings. It does feel strange at first, but then I think it makes sense once the flattening to R1CS is taken into consideration.

@gluax
Copy link
Contributor

gluax commented May 22, 2021

@acoglio Yea, I saw it in the RFC and your ABNF. I suppose I was asking since we never really discussed it and went along with it. It is probably not an issue for MVP purposes as well—just something to consider in the future.

@gluax
Copy link
Contributor

gluax commented May 23, 2021

After the recent commit:
Closes #947.
Closes #949.

This was linked to issues May 23, 2021
@gluax gluax marked this pull request as ready for review May 23, 2021 02:43
@gluax gluax requested review from collinc97 and acoglio May 23, 2021 02:43
Copy link
Collaborator

@acoglio acoglio left a comment

Choose a reason for hiding this comment

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

Looks good.

@gluax gluax removed their request for review May 23, 2021 03:23
@damirka
Copy link
Contributor Author

damirka commented May 24, 2021

@gluax I've added max value (127) for \x escape and tests for it. Overall this PR looks complete, I've run few programs locally and strings are working, inputs as well. Great work!

@acoglioI think we finally can merge it into char.

@acoglio acoglio merged commit f052579 into feature/char-type May 24, 2021
@acoglio acoglio deleted the feature/string-parsing branch May 24, 2021 17:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature A new feature. help-wanted Extra attention is needed
Projects
None yet
3 participants