A token is a node that has a text
but no children.
nitc :: Token :: _cached_text
nitc :: Token :: _ending_prods
The productions that ends withself
, if any
nitc :: Token :: _is_ending_line
Is self the last AST token on its line in the sourcenitc :: Token :: _is_starting_line
Is self the first AST token on its line in the sourcenitc :: Token :: _prev_looses
Loose tokens that precedeself
.
nitc :: Token :: _prev_token
The previous token in the Lexer.nitc :: Token :: _starting_prods
The productions that starts withself
, if any
nitc :: Token :: blank_before
The verbatim blank text betweenprev_token
and self
nitc :: Token :: cached_text
nitc :: Token :: cached_text=
nitc :: Token :: defaultinit
nitc :: Token :: ending_prods
The productions that ends withself
, if any
nitc :: Token :: ending_prods=
The productions that ends withself
, if any
nitc :: Token :: first_ast_token=
The first AST token.nitc :: Token :: first_real_token_in_line
The first real token that starts the line ofself
nitc :: Token :: first_token_in_line
The first AST token that starts the line ofself
.
nitc :: Token :: is_ending_line
Is self the last AST token on its line in the sourcenitc :: Token :: is_ending_line=
Is self the last AST token on its line in the sourcenitc :: Token :: is_starting_line
Is self the first AST token on its line in the sourcenitc :: Token :: is_starting_line=
Is self the first AST token on its line in the sourcenitc :: Token :: last_ast_token=
The last AST token.nitc :: Token :: last_real_token_in_line
The last read token that ends the line ofself
nitc :: Token :: last_token_in_line
The last AST token that starts the line ofself
nitc :: Token :: next_looses=
Loose tokens that followself
nitc :: Token :: next_token=
The next token in the Lexer.nitc :: Token :: parser_index
nitc :: Token :: prev_looses=
Loose tokens that precedeself
.
nitc :: Token :: prev_token=
The previous token in the Lexer.nitc :: Token :: starting_prods
The productions that starts withself
, if any
nitc :: Token :: starting_prods=
The productions that starts withself
, if any
nitc :: pretty $ Token :: accept_pretty_printer
Start visit ofself
using a PrettyPrinterVisitor
nitc :: pretty $ Token :: collect_length
Collect the length (inChar
) of the node.
nitc $ Token :: is_structural
Isself
a token or a pure-structural production like AQId
?
nitc $ Token :: replace_child
Replace a child with an other node in the ASTnitc :: pretty $ Token :: was_inline
Doesself
was written in one line before transformation?
nitc :: Token :: _cached_text
nitc :: Token :: _ending_prods
The productions that ends withself
, if any
nitc :: ANode :: _is_broken
The indication that the node did not pass some semantic verifications.nitc :: Token :: _is_ending_line
Is self the last AST token on its line in the sourcenitc :: Token :: _is_starting_line
Is self the first AST token on its line in the sourcenitc :: Token :: _prev_looses
Loose tokens that precedeself
.
nitc :: Token :: _prev_token
The previous token in the Lexer.nitc :: Token :: _starting_prods
The productions that starts withself
, if any
nitc :: ANode :: accept_ast_validation
nitc :: ANode :: accept_auto_super_init
nitc :: ANode :: accept_flow_visitor
nitc :: ANode :: accept_forward_analysis
Apply the forward analysisv
to self
.
nitc :: ANode :: accept_literal
nitc :: ANode :: accept_post_typing
nitc :: ANode :: accept_pretty_printer
Start visit ofself
using a PrettyPrinterVisitor
nitc :: ANode :: accept_reaching_defs
Apply a ReachingDefsAnalysis toself
.
nitc :: ANode :: accept_regex_visitor
nitc :: ANode :: accept_scope_visitor
nitc :: ANode :: accept_simple_misc
nitc :: ANode :: accept_string_finder
nitc :: ANode :: after_simple_misc
nitc :: ANode :: bad_expr_message
An additional information message to explain the role of a child expression.nitc :: Token :: blank_before
The verbatim blank text betweenprev_token
and self
nitc :: Token :: cached_text
nitc :: Token :: cached_text=
nitc :: ANode :: check_callsite
core :: Object :: class_factory
Implementation used byget_class
to create the specific class.
nitc :: ANode :: collect_annotations_by_name
Do a deep search and return an array of node that are annotatednitc :: ANode :: collect_length
Collect the length (inChar
) of the node.
nitc :: ANode :: collect_tokens_by_text
Do a deep search and return an array of tokens that match a given textnitc :: ANode :: common_parent
The most specific common parent betweenself
and other
nitc :: ANode :: create_contracts
nitc :: ANode :: decorate_tag
Add aditionnal information on a child-token and return an additionnal HInfoBox on itnitc :: ANode :: defaultinit
nitc :: Token :: defaultinit
core :: Object :: defaultinit
core :: Cloneable :: defaultinit
nitc :: ANode :: do_cloneable
nitc :: Token :: ending_prods
The productions that ends withself
, if any
nitc :: Token :: ending_prods=
The productions that ends withself
, if any
nitc :: Token :: first_ast_token=
The first AST token.nitc :: Token :: first_real_token_in_line
The first real token that starts the line ofself
nitc :: Token :: first_token_in_line
The first AST token that starts the line ofself
.
nitc :: ANode :: force_block=
Forceself
to be rendered as a block.
nitc :: ANode :: force_inline=
Forceself
to be rendered as a line.
nitc :: ANode :: full_transform_visitor
nitc :: ANode :: hot_location
The location of the important part of the node (identifier or whatever)nitc :: ANode :: is_broken=
The indication that the node did not pass some semantic verifications.nitc :: Token :: is_ending_line
Is self the last AST token on its line in the sourcenitc :: Token :: is_ending_line=
Is self the last AST token on its line in the sourcenitc :: ANode :: is_noserialize
Is this node annotated to not be made serializable?core :: Object :: is_same_instance
Return true ifself
and other
are the same instance (i.e. same identity).
core :: Object :: is_same_serialized
Isself
the same as other
in a serialization context?
core :: Object :: is_same_type
Return true ifself
and other
have the same dynamic type.
nitc :: ANode :: is_serialize
Is this node annotated to be made serializable?nitc :: Token :: is_starting_line
Is self the first AST token on its line in the sourcenitc :: Token :: is_starting_line=
Is self the first AST token on its line in the sourcenitc :: ANode :: is_structural
Isself
a token or a pure-structural production like AQId
?
nitc :: Token :: last_ast_token=
The last AST token.nitc :: Token :: last_real_token_in_line
The last read token that ends the line ofself
nitc :: Token :: last_token_in_line
The last AST token that starts the line ofself
nitc :: ANode :: must_be_block
Doesself
have to be rendered as a block?
nitc :: ANode :: must_be_inline
Doesself
have be rendered as a line?
core :: Object :: native_class_name
The class name of the object in CString format.nitc :: Token :: next_looses=
Loose tokens that followself
nitc :: Token :: next_token=
The next token in the Lexer.core :: Object :: output_class_name
Display class name on stdout (debug only).nitc :: ANode :: parentize_tokens
Visit the AST and computes advanced AST attributes on Tokens and Prodnitc :: Token :: parser_index
nitc :: Token :: prev_looses=
Loose tokens that precedeself
.
nitc :: Token :: prev_token=
The previous token in the Lexer.nitc :: ANode :: replace_child
Replace a child with an other node in the ASTnitc :: ANode :: replace_with
Replace itself with an other node in the ASTnitc :: Token :: starting_prods
The productions that starts withself
, if any
nitc :: Token :: starting_prods=
The productions that starts withself
, if any
nitc :: ANode :: was_inline
Doesself
was written in one line before transformation?
# Ancestor of all tokens
# A token is a node that has a `text` but no children.
abstract class Token
super ANode
# The raw content on the token
fun text: String is abstract
# The raw content on the token
fun text=(text: String) is abstract
# The previous token in the Lexer.
# May have disappeared in the AST
var prev_token: nullable Token = null
# The next token in the Lexer.
# May have disappeared in the AST
var next_token: nullable Token = null
# Is `self` a token discarded from the AST?
#
# Loose tokens are not present in the AST.
# It means they were identified by the lexer but were discarded by the parser.
# It also means that they are not visited or manipulated by AST-related functions.
#
# Each loose token is attached to the non-loose token that precedes or follows it.
# The rules are the following:
#
# * tokens that follow a non-loose token on a same line are attached to it.
# See `next_looses`.
# * other tokens, thus that precede a non-loose token on the same line or the next one,
# are attached to this one. See `prev_looses`.
#
# Loose tokens are mostly end of lines (`TEol`) and comments (`TComment`).
# Whitespace are ignored by the lexer, so they are not even considered as loose tokens.
# See `blank_before` to get the whitespace that separate tokens.
var is_loose = false
redef fun is_structural do return true
redef fun dump_info(v) do return " {text.escape_to_c}"
# Loose tokens that precede `self`.
#
# These tokens start the line or belong to a line with only loose tokens.
var prev_looses = new Array[Token] is lazy
# Loose tokens that follow `self`
#
# These tokens are on the same line than `self`.
var next_looses = new Array[Token] is lazy
# The verbatim blank text between `prev_token` and `self`
fun blank_before: String
do
if prev_token == null then return ""
var from = prev_token.location.pend+1
var to = location.pstart
return location.file.string.substring(from,to-from)
end
redef fun to_s: String do
return "'{text}'"
end
redef fun visit_all(v: Visitor) do end
redef fun replace_child(old_child: ANode, new_child: nullable ANode) do end
end
src/parser/parser_nodes.nit:345,1--412,3
redef class Token
private var cached_text: nullable String
redef fun text
do
var res = _cached_text
if res != null then return res
res = location.text
_cached_text = res
return res
end
redef fun text=(text)
do
_cached_text = text
end
fun parser_index: Int is abstract
end
src/parser/lexer_work.nit:21,1--39,3
redef class Token
# Is self the first AST token on its line in the source
# Computed by `parentize_tokens`
#
# Note, some tokens detached from the AST
# may precede `self` even if `is_starting_line` is true
# One can use `first_real_token_in_line` to get the real starting token
var is_starting_line = false
# Is self the last AST token on its line in the source
# Computed by `parentize_tokens`
#
# Note, some tokens detached from the AST (like comments)
# may follow `self` even if `is_ending_line` is true.
# One can use `last_real_token_in_line` to get the real ending token
var is_ending_line = false
# The first real token that starts the line of `self`
#
# This could return a token that is detached from the AST.
# See `first_token_in_line` if a AST token is required.
fun first_real_token_in_line: Token
do
var line = location.line_start
var t = self
loop
var p = t.prev_token
if p == null or p.location.line_start != line then
return t
end
t = p
end
end
# The first AST token that starts the line of `self`.
# May be null is the line contains only detached tokens (only comment)
#
# Computed by `parentize_tokens`
#
# ENSURE `result != null implies result.is_starting_line`
fun first_token_in_line: nullable Token
do
return first_real_token_in_line.first_ast_token
end
# The first AST token.
# This only work on the `first_real_token_in_line`
private var first_ast_token: nullable Token
# The last read token that ends the line of `self`
#
# This usually return a detached token lake a TEol or a comment.
# See `last_token_in_line` if a AST token is required.
fun last_real_token_in_line: Token
do
var line = location.line_start
var t = self
loop
var p = t.next_token
if p == null or p.location.line_start != line then
return t
end
t = p
end
end
# The last AST token that starts the line of `self`
# May be null is the line contains only detached tokens (only comment)
#
# Computed by `parentize_tokens`
#
# ENSURE `result.is_ending_line`
fun last_token_in_line: nullable Token
do
return last_real_token_in_line.last_ast_token
end
# The last AST token.
# This only work on the `last_real_token_in_line`
private var last_ast_token: nullable Token
# The productions that starts with `self`, if any
# Productions goes from the most general to the most specific
#
# Computed by `parentize_tokens`
var starting_prods: nullable Array[Prod]
# The productions that ends with `self`, if any
# Productions goes from the most specific to the most general
#
# Computed by `parentize_tokens`
var ending_prods: nullable Array[Prod]
end
src/astutil.nit:109,1--201,3
redef class Token
private fun accept_simple_misc_token(v: SimpleMiscVisitor)
do
end
end
src/frontend/simple_misc_analysis.nit:90,1--94,3
redef class Token
redef fun accept_pretty_printer(v) do
v.add text.trim
v.current_token = next_token
end
redef fun collect_length do return text.length
redef fun is_inlinable do return true
redef fun was_inline do return true
end
src/pretty.nit:348,1--357,3