Introduced properties

private var _last_token: nullable Token

nitc :: PTokenVisitor :: _last_token

private var _stack: Array[Prod]

nitc :: PTokenVisitor :: _stack

productions that need a fisrt token
private fun last_token: nullable Token

nitc :: PTokenVisitor :: last_token

private fun last_token=(last_token: nullable Token)

nitc :: PTokenVisitor :: last_token=

private fun stack: Array[Prod]

nitc :: PTokenVisitor :: stack

productions that need a fisrt token
private fun stack=(stack: Array[Prod])

nitc :: PTokenVisitor :: stack=

productions that need a fisrt token
private fun work(n: ANode)

nitc :: PTokenVisitor :: work

Redefined properties

redef type SELF: PTokenVisitor

nitc $ PTokenVisitor :: SELF

Type of this instance, automatically specialized in every class
redef fun visit(n: ANode)

nitc $ PTokenVisitor :: visit

What the visitor do when a node is visited

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 _current_node: nullable ANode

nitc :: Visitor :: _current_node

The current visited node
private var _last_token: nullable Token

nitc :: PTokenVisitor :: _last_token

private var _stack: Array[Prod]

nitc :: PTokenVisitor :: _stack

productions that need a fisrt 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 current_node: nullable ANode

nitc :: Visitor :: current_node

The current visited node
fun current_node=(current_node: nullable ANode)

nitc :: Visitor :: current_node=

The current visited node
fun enter_visit(e: nullable ANode)

nitc :: Visitor :: enter_visit

Ask the visitor to visit a given node.
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.
private fun last_token: nullable Token

nitc :: PTokenVisitor :: last_token

private fun last_token=(last_token: nullable Token)

nitc :: PTokenVisitor :: last_token=

private intern fun native_class_name: CString

core :: Object :: native_class_name

The class name of the object in CString format.
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 serialization_hash: Int

core :: Object :: serialization_hash

Hash value use for serialization
private fun stack: Array[Prod]

nitc :: PTokenVisitor :: stack

productions that need a fisrt token
private fun stack=(stack: Array[Prod])

nitc :: PTokenVisitor :: stack=

productions that need a fisrt token
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.
protected abstract fun visit(e: ANode)

nitc :: Visitor :: visit

What the visitor do when a node is visited
private fun work(n: ANode)

nitc :: PTokenVisitor :: work

package_diagram nitc::astutil::PTokenVisitor PTokenVisitor nitc::Visitor Visitor nitc::astutil::PTokenVisitor->nitc::Visitor core::Object Object nitc::Visitor->core::Object ...core::Object ... ...core::Object->core::Object

Ancestors

interface Object

core :: Object

The root of the class hierarchy.

Parents

abstract class Visitor

nitc :: Visitor

Abstract standard visitor on the AST

Class definitions

nitc $ PTokenVisitor
private class PTokenVisitor
	super Visitor

	var last_token: nullable Token = null

	# productions that need a fisrt token
	var stack = new Array[Prod]

	fun work(n: ANode)
	do
		enter_visit(n)
		# process remaining detashed tokens
		var c = last_token
		if c != null then
			c.is_ending_line = true
			c.last_real_token_in_line.last_ast_token = c
			c = c.next_token
		end
		var r = n.root
		while c != null and c.parent == null do
			c.parent = r
			c = c.next_token
		end
	end

	redef fun visit(n)
	do
		if not n isa Token then
			assert n isa Prod
			stack.push(n)
			n.visit_all(self)
			if n.first_token == null then
				# epsilon production, just discard
				assert stack.pop == n
			else
				var t = last_token
				if t != null then
					# last token ends the production
					n.last_token = t
					if t.ending_prods == null then t.ending_prods = new Array[Prod]
					t.ending_prods.add n
				end
			end
			return
		end

		# We have a token, give it to prods that need one
		if not stack.is_empty then
			n.starting_prods = new Array[Prod]
			for p in stack do
				p.first_token = n
				n.starting_prods.add p
			end
			stack.clear
		end

		var last_token = last_token

		# n starts a new line
		if last_token == null or last_token.location.line_start != n.location.line_start then
			n.is_starting_line = true
			n.first_real_token_in_line.first_ast_token = n

		end
		# last_token ended a line
		if last_token != null and last_token.location.line_start != n.location.line_start then
			last_token.is_ending_line = true
			last_token.last_real_token_in_line.last_ast_token = last_token
		end

		# Get the common parent
		var p
		if last_token == null then
			p = n.root
		else
			p = last_token.common_parent(n)
		end
		if p isa Prod then
			# And apply it to detached tokens between `last_token` and `n`
			var c = n.prev_token
			while c != null and c.parent == null do
				c.parent = p
				c = c.prev_token
			end
		end

		self.last_token = n
	end
end
src/astutil.nit:204,1--292,3