SwiftStudies / OysterKit

OysterKit is a framework that provides a native Swift scanning, lexical analysis, and parsing capabilities. In addition it provides a language that can be used to rapidly define the rules used by OysterKit called STLR
BSD 2-Clause "Simplified" License
177 stars 23 forks source link

Wrong data structure created for array of choices #104

Open diniska opened 2 months ago

diniska commented 2 months ago

First example

It generates code that doesn't compile:

grammar Example

offOrOn = ("0" | "1")+

generates:

public struct Example: Codable {
    public let offOrOn : OffOrOn
    ...
}

Second example

It generates the structure that won't be able to represent the parsed string:

grammar Example

off = "0"
on = "1"

mix = (off | on)+

result:

public struct Example: Codable {

    // Mix
    public enum Mix: Codable {
        case on(on:[Swift.String])
        case off(off:[Swift.String])
    }
    ...
}