/* Generated by re2swift */
#sourceLocation(file: "codegen/swift/001_basic_d.re", line: 1)
// re2swift $INPUT -o $OUTPUT --api generic -d

func lex(_ s: UnsafeBufferPointer<UInt8>) -> Bool {
  var cursor = 0, marker = 0

  
#sourceLocation(file: "codegen/swift/001_basic_d.swift", line: 10)
  var yych: UInt8 = 0
  var yystate: UInt = 0
  yyl: while true {
    switch yystate {
      case 0:
        print("lex: '\(yych)' int state \(0)")
        yych = s[cursor]
        cursor += 1
        switch yych {
          case 0x30...0x39:
            yystate = 3
            continue yyl
          default:
            yystate = 1
            continue yyl
        }
      case 1:
        print("lex: '\(yych)' int state \(1)")
        yystate = 2
        continue yyl
      case 2:
        print("lex: '\(yych)' int state \(2)")
#sourceLocation(file: "codegen/swift/001_basic_d.re", line: 17)
        return false
#sourceLocation(file: "codegen/swift/001_basic_d.swift", line: 35)
      case 3:
        print("lex: '\(yych)' int state \(3)")
        marker = cursor
        yych = s[cursor]
        switch yych {
          case 0x00:
            cursor += 1
            yystate = 4
            continue yyl
          case 0x30...0x39:
            cursor += 1
            yystate = 5
            continue yyl
          default:
            yystate = 2
            continue yyl
        }
      case 4:
        print("lex: '\(yych)' int state \(4)")
#sourceLocation(file: "codegen/swift/001_basic_d.re", line: 16)
        return true
#sourceLocation(file: "codegen/swift/001_basic_d.swift", line: 57)
      case 5:
        print("lex: '\(yych)' int state \(5)")
        yych = s[cursor]
        switch yych {
          case 0x00:
            cursor += 1
            yystate = 4
            continue yyl
          case 0x30...0x39:
            cursor += 1
            yystate = 5
            continue yyl
          default:
            yystate = 6
            continue yyl
        }
      case 6:
        print("lex: '\(yych)' int state \(6)")
        cursor = marker
        yystate = 2
        continue yyl
      default: fatalError("internal lexer error")
    }
  }
#sourceLocation(file: "codegen/swift/001_basic_d.re", line: 18)

}

@main struct Program {
  static func main() {
    let s: StaticString = "123\0"
    s.withUTF8Buffer {
      assert(lex($0), "expected 123")
    }
  }
}
