"""This is a scanner."""
__copyright__ = """
If not otherwise stated, any source code generated by Coco/R (other than Coco/R itself) does not fall under the GNU General Public License.
"""
import typing
import array
from enum import IntEnum
from functools import wraps
from CoCoRuntime.scanner import Buffer, Scanner, prepareLiteralsTable


class ScannerEnum(IntEnum):
	eofSym = 0
	noSym = 16
	maxT = 16
	_EOF = 0
	_OptionalStart = 1
	_OptionalEnd = 2
	_ArgumentStart = 3
	_ArgumentEnd = 4
	_OpeningBrace = 5
	_ClosingBrace = 6
	_Comma = 7
	_AlternativeDelimiter = 8
	_QueryMarker = 9
	_Prefix = 10
	_SpecialPrefix = 11
	_integer = 12
	_identifierFragmentWithoutDigits = 13
	_WSS = 14
	_number = 15


class MyScanner(Scanner):
	__slots__ = ()

	@wraps(Scanner.__init__)
	def __init__(self, *args, **kwargs):
		"""This ctor is mandatory, don't delete it: otherwise self.__class__.ENUM will be None"""
		super().__init__(*args, **kwargs)

	ENUM = ScannerEnum
	charSetSize = 256
	maxT = 16
	start = array.array("b", (0, 0, 0, 0, 0, 0, 0, 0, 0, 14, 14, 14, 14, 14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 7, 0, 0, 0, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 9, 0, 3, 0, 4, 16, 0, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 1, 0, 2, 0, 13, 0, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 5, 8, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1))

	def initialization(self) -> None:
		pass

	def casing(self) -> None:
		pass

	literalsTable = prepareLiteralsTable({})

	def CheckLiteral(self) -> ScannerEnum:
		return self.__class__.literalsTable.get(self.t.val, self.t.kind)

	def scan1(self) -> bool:
		pass

	def scan2(self, buf: str) -> str:
		buf += str(self.ch)
		self.NextCh()
		return buf

	def scan3(self, state: int, apx: int, buf: str) -> typing.Tuple[typing.Optional[int], ScannerEnum, int, str]:
		if state == 12:
			if "0" <= self.ch <= "9":
				buf += str(self.ch)
				self.NextCh()
				return 12, self.t.kind, apx, buf
			return None, 12, apx, buf
		if state == 13:
			if "A" <= self.ch <= "Z" or self.ch == "_" or "a" <= self.ch <= "z":
				buf += str(self.ch)
				self.NextCh()
				return 13, self.t.kind, apx, buf
			return None, 13, apx, buf
		if state == 14:
			if 9 <= ord(self.ch) <= 13 or self.ch == " ":
				buf += str(self.ch)
				self.NextCh()
				return 14, self.t.kind, apx, buf
			return None, 14, apx, buf
		if state == 15:
			if self.ch == "?":
				buf += str(self.ch)
				self.NextCh()
				return 11, self.t.kind, apx, buf
			return None, 15, apx, buf
		if state == 16:
			if self.ch == ".":
				buf += str(self.ch)
				self.NextCh()
				return 15, self.t.kind, apx, buf
			return None, 9, apx, buf
		return state, self.t.kind, apx, buf

	finalStates = array.array("B", (ScannerEnum.noSym, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 15))
