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

re generates wrong JSON #186

Closed
pkuzmin opened this issue Dec 11, 2019 · 2 comments
Closed

re generates wrong JSON #186

pkuzmin opened this issue Dec 11, 2019 · 2 comments
Labels

Comments

@pkuzmin
Copy link

pkuzmin commented Dec 11, 2019

In this case, there is not enough comma.

./build/bin/re -pl json "^[abc]$"
{
        "states": [
                {
                        "end": false,
                        "edges": [
                                { "char":  "a", "to": 1},
                                { "char":  "b", "to": 1}
                                { "char":  "c", "to": 1}
                        ]
                },
                {
                        "end": true,
                        "edges": [
                        ]
                }
        ],
        "start": 0
}

But here everything is fine.

./build/bin/re -pl json "^[ace]$"
{
        "states": [
                {
                        "end": false,
                        "edges": [
                                { "char":  "a", "to": 1},
                                { "char":  "c", "to": 1},
                                { "char":  "e", "to": 1}
                        ]
                },
                {
                        "end": true,
                        "edges": [
                        ]
                }
        ],
        "start": 0
}
@katef
Copy link
Owner

katef commented Dec 12, 2019

Thank you very much!
Addressed in 19f5388

@katef
Copy link
Owner

katef commented Dec 12, 2019

Incidentally, the json output there is a quite literal representation of an FSM, with every transition spelled out explicitly.

That might be exactly what you wanted, but depending on what you're looking for, you might also be interested in the re -pl irjson output. That comes from a later phase of processing (just before code generation), and contains various optimisations, for example folding together ranges of adjacent transitions.

See #94 for a quick overview of the IR nodes.

@katef katef closed this as completed Dec 12, 2019
@katef katef added the bug label Dec 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants