A modified lexer that feed tokens before and after the real tokens.

Introduced properties

private var _injected_after: List[Token]

nitc :: InjectedLexer :: _injected_after

The tokens to use after the real tokens (in order).
private var _injected_before: List[Token]

nitc :: InjectedLexer :: _injected_before

The tokens to use before the real tokens (in order).
fun injected_after: List[Token]

nitc :: InjectedLexer :: injected_after

The tokens to use after the real tokens (in order).
protected fun injected_after=(injected_after: List[Token])

nitc :: InjectedLexer :: injected_after=

The tokens to use after the real tokens (in order).
fun injected_before: List[Token]

nitc :: InjectedLexer :: injected_before

The tokens to use before the real tokens (in order).
protected fun injected_before=(injected_before: List[Token])

nitc :: InjectedLexer :: injected_before=

The tokens to use before the real tokens (in order).
private fun is_finished=(is_finished: Bool)

nitc :: InjectedLexer :: is_finished=

Redefined properties

redef type SELF: InjectedLexer

nitc $ InjectedLexer :: SELF

Type of this instance, automatically specialized in every class
redef fun get_token: nullable Token

nitc $ InjectedLexer :: get_token

Primitive method to return a token, or return null if it is discarded

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 _cr: Bool

nitc :: Lexer :: _cr

Was the last character a carriage-return?
private var _file: SourceFile

nitc :: Lexer :: _file

The source file
private var _injected_after: List[Token]

nitc :: InjectedLexer :: _injected_after

The tokens to use after the real tokens (in order).
private var _injected_before: List[Token]

nitc :: InjectedLexer :: _injected_before

The tokens to use before the real tokens (in order).
private var _last_token: nullable Token

nitc :: Lexer :: _last_token

The last peeked token to chain them
private var _line: Int

nitc :: Lexer :: _line

Current line number in the input stream
private var _pos: Int

nitc :: Lexer :: _pos

Current column in the input stream
private var _state: Int

nitc :: Lexer :: _state

Lexer current state
private var _stream_pos: Int

nitc :: Lexer :: _stream_pos

Current character in the stream
private var _token: nullable Token

nitc :: Lexer :: _token

Last peeked token
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 cr: Bool

nitc :: Lexer :: cr

Was the last character a carriage-return?
protected fun cr=(cr: Bool)

nitc :: Lexer :: cr=

Was the last character a carriage-return?
fun file: SourceFile

nitc :: Lexer :: file

The source file
protected fun file=(file: SourceFile)

nitc :: Lexer :: file=

The source file
fun get_class: CLASS

core :: Object :: get_class

The meta-object representing the dynamic type of self.
protected fun get_token: nullable Token

nitc :: Lexer :: get_token

Primitive method to return a token, or return null if it is discarded
fun hash: Int

core :: Object :: hash

The hash code of the object.
init init

core :: Object :: init

fun injected_after: List[Token]

nitc :: InjectedLexer :: injected_after

The tokens to use after the real tokens (in order).
protected fun injected_after=(injected_after: List[Token])

nitc :: InjectedLexer :: injected_after=

The tokens to use after the real tokens (in order).
fun injected_before: List[Token]

nitc :: InjectedLexer :: injected_before

The tokens to use before the real tokens (in order).
protected fun injected_before=(injected_before: List[Token])

nitc :: InjectedLexer :: injected_before=

The tokens to use before the real tokens (in order).
fun inspect: String

core :: Object :: inspect

Developer readable representation of self.
protected fun inspect_head: String

core :: Object :: inspect_head

Return "CLASSNAME:#OBJECTID".
private fun is_finished=(is_finished: Bool)

nitc :: InjectedLexer :: is_finished=

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.
private fun last_token: nullable Token

nitc :: Lexer :: last_token

The last peeked token to chain them
private fun last_token=(last_token: nullable Token)

nitc :: Lexer :: last_token=

The last peeked token to chain them
fun lexer_accept(i: Int): Int

nitc :: TablesCapable :: lexer_accept

The accept value of the lexer at i
fun lexer_goto(i: Int, j: Int): Int

nitc :: TablesCapable :: lexer_goto

The goto value of the lexer at row i, column j-1
fun line: Int

nitc :: Lexer :: line

Current line number in the input stream
protected fun line=(line: Int)

nitc :: Lexer :: line=

Current line number in the input stream
protected abstract fun make_token(accept_token: Int, location: Location): Token

nitc :: Lexer :: make_token

Allocate the right Token object for a given identifier
private intern fun native_class_name: CString

core :: Object :: native_class_name

The class name of the object in CString format.
fun next: Token

nitc :: Lexer :: next

Give and consume 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 parser_action(i: Int, j: Int): Int

nitc :: TablesCapable :: parser_action

The action value of the parser at row i, column j-1
fun parser_goto(i: Int, j: Int): Int

nitc :: TablesCapable :: parser_goto

The goto value of the parser at row i, column j-1
fun peek: Token

nitc :: Lexer :: peek

Give the next token (but do not consume it)
fun pos: Int

nitc :: Lexer :: pos

Current column in the input stream
protected fun pos=(pos: Int)

nitc :: Lexer :: pos=

Current column in the input stream
fun serialization_hash: Int

core :: Object :: serialization_hash

Hash value use for serialization
private fun state: Int

nitc :: Lexer :: state

Lexer current state
private fun state=(state: Int)

nitc :: Lexer :: state=

Lexer current state
private fun state_initial: Int

nitc :: Lexer :: state_initial

Constante state values
fun stream_pos: Int

nitc :: Lexer :: stream_pos

Current character in the stream
protected fun stream_pos=(stream_pos: Int)

nitc :: Lexer :: stream_pos=

Current character in the stream
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.
fun token: nullable Token

nitc :: Lexer :: token

Last peeked token
protected fun token=(token: nullable Token)

nitc :: Lexer :: token=

Last peeked token
package_diagram nitc::InjectedLexer InjectedLexer nitc::Lexer Lexer nitc::InjectedLexer->nitc::Lexer nitc::TablesCapable TablesCapable nitc::Lexer->nitc::TablesCapable ...nitc::TablesCapable ... ...nitc::TablesCapable->nitc::TablesCapable

Ancestors

interface Object

core :: Object

The root of the class hierarchy.
interface TablesCapable

nitc :: TablesCapable

Interface allowing the acces of the tables used during the parsing.

Parents

class Lexer

nitc :: Lexer

The lexer extract NIT tokens from an input stream.

Class definitions

nitc $ InjectedLexer
# A modified lexer that feed tokens before and after the real tokens.
class InjectedLexer
	super Lexer

	# The tokens to use before the real tokens (in order).
	var injected_before = new List[Token]

	# The tokens to use after the real tokens (in order).
	# The real EOF token is produced after these tokens.
	var injected_after = new List[Token]
	private var is_finished = false

	redef fun get_token
	do
		if not injected_before.is_empty then
			var tok = injected_before.shift
			return tok
		end
		if not is_finished then
			var next = super
			if not next isa EOF then return next
			injected_after.push(next)
			is_finished = true
		end

		var tok = injected_after.shift
		return tok
	end
end
src/parser_util.nit:225,1--253,3