/// Auto-generated by `cmd/build`. Do not edit manually.
/// Literal terminals from the WebIDL grammar.
/// Source: https://webidl.spec.whatwg.org/#idl-grammar

///|
/// Grammar keyword literals, sorted by length descending.
let keywords : Array[String] = [
  "SharedArrayBuffer", "Uint8ClampedArray", "ObservableArray", "BigUint64Array",
  "async_iterable", "async_sequence", "BigInt64Array", "Float16Array", "Float32Array",
  "Float64Array", "unrestricted", "ArrayBuffer", "FrozenArray", "Uint16Array", "Uint32Array",
  "constructor", "stringifier", "ByteString", "Int16Array", "Int32Array", "Uint8Array",
  "dictionary", "-Infinity", "DOMString", "Int8Array", "USVString", "attribute",
  "interface", "namespace", "undefined", "DataView", "Infinity", "callback", "includes",
  "iterable", "optional", "readonly", "required", "sequence", "unsigned", "Promise",
  "boolean", "deleter", "inherit", "maplike", "partial", "setlike", "typedef", "bigint",
  "double", "getter", "object", "record", "setter", "static", "symbol", "const",
  "false", "float", "mixin", "octet", "short", "byte", "enum", "long", "null", "true",
  "NaN", "any", "or",
]

///|
/// Grammar punctuation literals, sorted by length descending.
let punctuation : Array[String] = [
  "...", "(", ")", "*", ",", "-", ".", ":", ";", "<", "=", ">", "?", "[", "]", "{",
  "}",
]

///|
/// Returns whether `text` is a grammar keyword literal.
fn is_keyword(text : StringView) -> Bool {
  for kw in keywords {
    if text == kw[:] {
      return true
    }
  }
  false
}

///|
/// Try to match a grammar punctuation literal at the start of `text`.
fn match_punctuation(text : StringView) -> Int {
  for p in punctuation {
    if text.has_prefix(p[:]) {
      return p.length()
    }
  }
  0
}