mna / pigeon

Command pigeon generates parsers in Go from a PEG grammar.
BSD 3-Clause "New" or "Revised" License
822 stars 66 forks source link

Invalid rune literal syntax generation for class matcher #147

Open sno2 opened 2 months ago

sno2 commented 2 months ago

Given this grammar:

ox80_oxBF <- [\200-\277]

The generated grammar code has a syntax error saying more than one character in rune literal:

var g = &grammar{
    rules: []*rule{
        {
            name: "ox80_oxBF",
            pos:  position{line: 1, col: 1, offset: 0},
            expr: &charClassMatcher{
                pos:        position{line: 1, col: 14, offset: 13},
                val:        "[\\200-\\277]",
                ranges:     []rune{'\u0080', '┬┐'}, // <- error here
                ignoreCase: false,
                inverted:   false,
            },
        },
    },
}

Thank you for your work.

fy0 commented 2 months ago

I got this:

        {
            name: "ox80_oxBF",
            expr: &charClassMatcher{
                val:        "[\\200-\\277]",
                ranges:     []rune{'\u0080', '¿'},
                ignoreCase: false,
                inverted:   false,
            },
        },

It seems ok:

ord('¿') 191

ord('\277') 191

sno2 commented 2 months ago

@fy0 Seems like something spooky is going on... I am on Windows using the latest release. What are you on?

fy0 commented 1 month ago

@fy0 Seems like something spooky is going on... I am on Windows using the latest release. What are you on?

Same, on windows 11.