Used to give position to tokens
nitcc_runtime :: Position :: col_end
nitcc_runtime :: Position :: col_end=
nitcc_runtime :: Position :: col_start
nitcc_runtime :: Position :: col_start=
nitcc_runtime :: Position :: defaultinit
nitcc_runtime :: Position :: line_end
nitcc_runtime :: Position :: line_end=
nitcc_runtime :: Position :: line_start
nitcc_runtime :: Position :: line_start=
nitcc_runtime :: Position :: pos_end
nitcc_runtime :: Position :: pos_end=
nitcc_runtime :: Position :: pos_start
nitcc_runtime :: Position :: pos_start=
nitcc_runtime $ Position :: SELF
Type of this instance, automatically specialized in every classnitcc_runtime $ Position :: core_serialize_to
Actual serialization ofself
to serializer
nitcc_runtime $ Position :: from_deserializer
Create an instance of this class from thedeserializer
serialization :: Serializable :: accept_json_serializer
Refinable service to customize the serialization of this class to JSONserialization :: Serializable :: accept_msgpack_attribute_counter
Hook to customize the behavior of theAttributeCounter
serialization :: Serializable :: accept_msgpack_serializer
Hook to customize the serialization of this class to MessagePackserialization :: Serializable :: add_to_bundle
Called by[]=
to dynamically choose the appropriate method according
core :: Object :: class_factory
Implementation used byget_class
to create the specific class.
nitcc_runtime :: Position :: col_end
nitcc_runtime :: Position :: col_end=
nitcc_runtime :: Position :: col_start
nitcc_runtime :: Position :: col_start=
serialization :: Serializable :: core_serialize_to
Actual serialization ofself
to serializer
core :: Object :: defaultinit
nitcc_runtime :: Position :: defaultinit
serialization :: Serializable :: from_deserializer
Create an instance of this class from thedeserializer
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.
nitcc_runtime :: Position :: line_end
nitcc_runtime :: Position :: line_end=
nitcc_runtime :: Position :: line_start
nitcc_runtime :: Position :: line_start=
serialization :: Serializable :: msgpack_extra_array_items
Hook to request a larger than usual metadata arraycore :: Object :: output_class_name
Display class name on stdout (debug only).nitcc_runtime :: Position :: pos_end
nitcc_runtime :: Position :: pos_end=
nitcc_runtime :: Position :: pos_start
nitcc_runtime :: Position :: pos_start=
serialization :: Serializable :: serialize_msgpack
Serializeself
to MessagePack bytes
serialization :: Serializable :: serialize_to
Serializeself
to serializer
serialization :: Serializable :: serialize_to_json
Serializeself
to JSON
serialization :: Serializable :: to_pretty_json
Serializeself
to plain pretty JSON
Serializer::serialize
# A position into a input stream
# Used to give position to tokens
class Position
serialize
var pos_start: Int
var pos_end: Int
var line_start: Int
var line_end: Int
var col_start: Int
var col_end: Int
redef fun to_s do return "{line_start}:{col_start}-{line_end}:{col_end}"
# Extract the content from the given source
fun extract(source: String): String
do
return source.substring(pos_start, pos_end-pos_start+1)
end
# Get the lines covered by `self` and underline the target columns.
#
# This is useful for pretty printing errors or debug the output
#
# ~~~
# var src = "var Foo = new Array[Int]"
# var pos = new Position(0,0, 1, 1, 5, 8)
#
# assert pos.underline(src) == """
# var Foo = new Array[Int]
# ^^^"""
# ~~~
fun underline(source: Text): String
do
var res = new FlatBuffer
# All the concerned lines
var lines = source.split("\n")
for line in [line_start..line_end] do
res.append lines[line-1]
res.append "\n"
end
# Cover all columns, no matter their lines
var col_start = col_start.min(col_end)
var col_end = self.col_start.max(col_end)
# " ^^^^"
var ptr = " "*(col_start-1).max(0) + "^"*(col_end-col_start)
res.append ptr
return res.to_s
end
end
lib/nitcc_runtime/nitcc_runtime.nit:310,1--363,3