A abstract lexer engine generated by nitcc

Introduced properties

private var _chars: SequenceRead[Char]

nitcc_runtime :: Lexer :: _chars

Current
private var _col_start: Int

nitcc_runtime :: Lexer :: _col_start

Cursor current column (in chars, starting from 1)
private var _line_start: Int

nitcc_runtime :: Lexer :: _line_start

Cursor current line (starting from 1)
private var _pos_start: Int

nitcc_runtime :: Lexer :: _pos_start

Cursor current position (in chars, starting from 0)
private var _stream: String

nitcc_runtime :: Lexer :: _stream

The input stream of characters
protected fun chars=(chars: SequenceRead[Char])

nitcc_runtime :: Lexer :: chars=

Current
fun col_start: Int

nitcc_runtime :: Lexer :: col_start

Cursor current column (in chars, starting from 1)
protected fun col_start=(col_start: Int)

nitcc_runtime :: Lexer :: col_start=

Cursor current column (in chars, starting from 1)
fun lex: CircularArray[NToken]

nitcc_runtime :: Lexer :: lex

Lexize a stream of characters and return a sequence of tokens
fun line_start: Int

nitcc_runtime :: Lexer :: line_start

Cursor current line (starting from 1)
protected fun line_start=(line_start: Int)

nitcc_runtime :: Lexer :: line_start=

Cursor current line (starting from 1)
fun next_token: nullable NToken

nitcc_runtime :: Lexer :: next_token

Move the cursor and return the next token.
fun pos_start: Int

nitcc_runtime :: Lexer :: pos_start

Cursor current position (in chars, starting from 0)
protected fun pos_start=(pos_start: Int)

nitcc_runtime :: Lexer :: pos_start=

Cursor current position (in chars, starting from 0)
protected abstract fun start_state: DFAState

nitcc_runtime :: Lexer :: start_state

The stating state for lexing
fun stream: String

nitcc_runtime :: Lexer :: stream

The input stream of characters
protected fun stream=(stream: String)

nitcc_runtime :: Lexer :: stream=

The input stream of characters

Redefined properties

redef type SELF: Lexer

nitcc_runtime $ Lexer :: SELF

Type of this instance, automatically specialized in every class

All properties

fun !=(other: nullable Object): Bool

core :: Object :: !=

Have self and other different values?
fun ==(other: nullable Object): Bool

core :: Object :: ==

Have self and other the same value?
type CLASS: Class[SELF]

core :: Object :: CLASS

The type of the class of self.
type SELF: Object

core :: Object :: SELF

Type of this instance, automatically specialized in every class
private var _chars: SequenceRead[Char]

nitcc_runtime :: Lexer :: _chars

Current
private var _col_start: Int

nitcc_runtime :: Lexer :: _col_start

Cursor current column (in chars, starting from 1)
private var _line_start: Int

nitcc_runtime :: Lexer :: _line_start

Cursor current line (starting from 1)
private var _pos_start: Int

nitcc_runtime :: Lexer :: _pos_start

Cursor current position (in chars, starting from 0)
private var _stream: String

nitcc_runtime :: Lexer :: _stream

The input stream of characters
protected fun chars=(chars: SequenceRead[Char])

nitcc_runtime :: Lexer :: chars=

Current
protected fun class_factory(name: String): CLASS

core :: Object :: class_factory

Implementation used by get_class to create the specific class.
fun class_name: String

core :: Object :: class_name

The class name of the object.
fun col_start: Int

nitcc_runtime :: Lexer :: col_start

Cursor current column (in chars, starting from 1)
protected fun col_start=(col_start: Int)

nitcc_runtime :: Lexer :: col_start=

Cursor current column (in chars, starting from 1)
fun get_class: CLASS

core :: Object :: get_class

The meta-object representing the dynamic type of self.
fun hash: Int

core :: Object :: hash

The hash code of the object.
init init

core :: Object :: init

fun inspect: String

core :: Object :: inspect

Developer readable representation of self.
protected fun inspect_head: String

core :: Object :: inspect_head

Return "CLASSNAME:#OBJECTID".
intern fun is_same_instance(other: nullable Object): Bool

core :: Object :: is_same_instance

Return true if self and other are the same instance (i.e. same identity).
fun is_same_serialized(other: nullable Object): Bool

core :: Object :: is_same_serialized

Is self the same as other in a serialization context?
intern fun is_same_type(other: Object): Bool

core :: Object :: is_same_type

Return true if self and other have the same dynamic type.
fun lex: CircularArray[NToken]

nitcc_runtime :: Lexer :: lex

Lexize a stream of characters and return a sequence of tokens
fun line_start: Int

nitcc_runtime :: Lexer :: line_start

Cursor current line (starting from 1)
protected fun line_start=(line_start: Int)

nitcc_runtime :: Lexer :: line_start=

Cursor current line (starting from 1)
private intern fun native_class_name: CString

core :: Object :: native_class_name

The class name of the object in CString format.
fun next_token: nullable NToken

nitcc_runtime :: Lexer :: next_token

Move the cursor and return the next token.
intern fun object_id: Int

core :: Object :: object_id

An internal hash code for the object based on its identity.
fun output

core :: Object :: output

Display self on stdout (debug only).
intern fun output_class_name

core :: Object :: output_class_name

Display class name on stdout (debug only).
fun pos_start: Int

nitcc_runtime :: Lexer :: pos_start

Cursor current position (in chars, starting from 0)
protected fun pos_start=(pos_start: Int)

nitcc_runtime :: Lexer :: pos_start=

Cursor current position (in chars, starting from 0)
fun serialization_hash: Int

core :: Object :: serialization_hash

Hash value use for serialization
protected abstract fun start_state: DFAState

nitcc_runtime :: Lexer :: start_state

The stating state for lexing
fun stream: String

nitcc_runtime :: Lexer :: stream

The input stream of characters
protected fun stream=(stream: String)

nitcc_runtime :: Lexer :: stream=

The input stream of characters
intern fun sys: Sys

core :: Object :: sys

Return the global sys object, the only instance of the Sys class.
abstract fun to_jvalue(env: JniEnv): JValue

core :: Object :: to_jvalue

fun to_s: String

core :: Object :: to_s

User readable representation of self.
package_diagram nitcc_runtime::Lexer Lexer core::Object Object nitcc_runtime::Lexer->core::Object

Parents

interface Object

core :: Object

The root of the class hierarchy.

Class definitions

nitcc_runtime $ Lexer
# A abstract lexer engine generated by nitcc
abstract class Lexer
	# The input stream of characters
	var stream: String

	# The stating state for lexing
	# Used by generated parsers
	protected fun start_state: DFAState is abstract

	# Lexize a stream of characters and return a sequence of tokens
	fun lex: CircularArray[NToken]
	do
		var res = new CircularArray[NToken]
		chars = stream.chars
		loop
			var t = next_token
			if t != null then res.add t
			if t isa NEof or t isa NError then break
		end
		return res
	end

	# Cursor current position (in chars, starting from 0)
	var pos_start = 0

	# Cursor current line (starting from 1)
	var line_start = 1

	# Cursor current column (in chars, starting from 1)
	var col_start = 1

	# Current
	var chars: SequenceRead[Char] is noinit

	# Move the cursor and return the next token.
	#
	# Returns a `NEof` and the end.
	# Returns `null` if the token is ignored.
	fun next_token: nullable NToken
	do
		var state = start_state
		var pos = pos_start
		var pos_end = pos_start - 1
		var line = line_start
		var line_end = line_start - 1
		var col = col_start
		var col_end = col_start - 1
		var last_state: nullable DFAState = null
		var text = stream
		var chars = self.chars
		var length = text.length
		loop
			if state.is_accept then
				pos_end = pos - 1
				line_end = line
				col_end = col
				last_state = state
			end
			var c
			var next
			if pos >= length then
				c = '\0'
				next = null
			else
				c = chars[pos]
				next = state.trans(c)
			end
			if next == null then
				var token
				if pos_start < length then
					if last_state == null then
						token = new NLexerError
						var position = new Position(pos_start, pos, line_start, line, col_start, col)
						token.position = position
						token.text = text.substring(pos_start, pos-pos_start+1)
					else if not last_state.is_ignored then
						var position = new Position(pos_start, pos_end, line_start, line_end, col_start, col_end)
						token = last_state.make_token(position, text)
					else
						token = null
					end
				else
					token = new NEof
					var position = new Position(pos, pos, line, line, col, col)
					token.position = position
					token.text = ""
				end
				pos_start = pos_end + 1
				line_start = line_end
				col_start = col_end

				return token
			end
			state = next
			pos += 1
			col += 1
			if c == '\n' then
				line += 1
				col = 1
			end
		end
	end
end
lib/nitcc_runtime/nitcc_runtime.nit:157,1--259,3