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

Example fails with MatchError: line 1:1, expect value #154

Open
Jomy10 opened this issue Jul 28, 2023 · 0 comments
Open

Example fails with MatchError: line 1:1, expect value #154

Jomy10 opened this issue Jul 28, 2023 · 0 comments

Comments

@Jomy10
Copy link

Jomy10 commented Jul 28, 2023

Describe the bug
In the example on the readme, it fails with the message MatchError: line 1:1, expect value.

To Reproduce

❯ cat json.peg
@lifted entry = &. value !.;
@lifted value = object / array / string / number / true / false / null;

object = "{" (item ("," item)*)? "}";
item = string ":" value;

array = "[" (value ("," value)*)? "]";

@tight string = "\"" ([\u0020-\u0021] / [\u0023-\u005b] / [\u005d-\U0010ffff] / escape )* "\"";

true = "true";
false = "false";
null = "null";

@tight @squashed
number = minus? integral fractional? exponent?;

@tight @squashed @lifted
escape = "\\" ("\"" / "/" / "\\" / "b" / "f" / "n" / "r" / "t" / unicode);

@tight @squashed
unicode = "u" ([0-9] / [a-f] / [A-F]){4};

minus = "-";
plus = "+";

@squashed @tight
integral = "0" / [1-9] [0-9]*;

@squashed @tight
fractional = "." [0-9]+;

@tight
exponent = i"e" (plus / minus)? [0-9]+;

@spaced @lifted
whitespace = " " / "\r" / "\n" / "\t";

❯ cat data.json
[{"numbers": [1,,2.0,3e1]},[true,false,null],"xyz"]

❯ ./peppa parse -G json.peg -e entry data.json
data.json:
MatchError: line 1:1, expect value

Expected behavior
A successful parse

Desktop (please complete the following information):

  • OS: macOS 13.4

Additional context

  • shell: ZSH
  • c compiler: clang
❯ ./peppa -V
./peppa version 1.16.0
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

No branches or pull requests

1 participant