Also improve the documentation.
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
Pull-Request: #1055
Reviewed-by: Jean Privat <jean@pryen.org>
directory. `gen-one.sh` handle only one project at a time while `gen-all.sh`
works on a collection of projects grouped in a directory. For detail about how
to invoke each script, see the comments in these scripts.
+
+
+## Python
+
+The built-in filter of Doxygen for Python is very basic. For example, it
+recognizes anything in the “docstrings” as verbatim detailed description. In
+order to enhance the processing of the Python scripts, the
+[doxypypy](https://github.com/Feneric/doxypypy) filter may be used.
super
end
end
+
+# Importation logics for Python.
+class PythonSource
+ super SourceLanguage
+
+ redef fun apply_member_type(member, type_text) do
+ # Doxygen may forgot to remove the `def` keyword on methods.
+ extract_keyword(type_text, "def")
+ super
+ end
+end
init do
sources["any"] = new DefaultSource
sources["java"] = new JavaSource
+ sources["python"] = new PythonSource
var prefix = new OptionText("""
{{{"NAME".bold}}}
var keys = new Array[String].from(sources.keys)
opt_src_lang = new OptionEnum(keys,
- "The programming language to assume when processing chunk in the declarations left as-is by Doxygen. Use `any` (the default) to disable any language-specific processing.",
+ "The programming language to assume when processing chunks in the declarations left as-is by Doxygen. Use `any` (the default) to disable any language-specific processing.",
keys.index_of("any"), "--src-lang")
option_context.add_option(opt_src_lang)
end
# Add handling of multi-line descriptions.
#
-# Note: The algorithm is naive and do not handle internationalisation and
-# escape sequences.
+# Note: The algorithm is naive and do not handle internationalisation,
+# multi-byte characters and control characters.
redef class Option
redef fun pretty(off) do
# Execute a GET request on Github API.
#
# This method returns raw json data.
- # See other `get_*` methods to use more expressive types.
+ # See other `load_*` methods to use more expressive types.
#
# var api = new GithubAPI(get_github_oauth)
# var obj = api.get("repos/privat/nit")
# var repo = api.load_repo("privat/nit")
# assert repo.name == "nit"
# assert repo.owner.login == "privat"
+ # assert repo.default_branch.name == "master"
fun load_repo(full_name: String): nullable Repo do
var repo = new Repo(self, full_name)
repo.load_from_github
if was_error then return null
return repo
end
+
+ # Get the Github branch with `name`.
+ #
+ # Returns `null` if the branch cannot be found.
+ #
+ # var api = new GithubAPI(get_github_oauth)
+ # var repo = api.load_repo("privat/nit")
+ # assert repo isa Repo
+ # var branch = api.load_branch(repo, "master")
+ # assert branch.name == "master"
+ # assert branch.commit isa Commit
+ fun load_branch(repo: Repo, name: String): nullable Branch do
+ var branch = new Branch(self, repo, name)
+ branch.load_from_github
+ if was_error then return null
+ return branch
+ end
+
+ # Get the Github commit with `sha`.
+ #
+ # Returns `null` if the commit cannot be found.
+ #
+ # var api = new GithubAPI(get_github_oauth)
+ # var repo = api.load_repo("privat/nit")
+ # assert repo isa Repo
+ # var commit = api.load_commit(repo, "64ce1f")
+ # assert commit isa Commit
+ fun load_commit(repo: Repo, sha: String): nullable Commit do
+ var commit = new Commit(self, repo, sha)
+ commit.load_from_github
+ if was_error then return null
+ return commit
+ end
end
# Something returned by the Github API.
fun owner: User do
return new User.from_json(api, json["owner"].as(JsonObject))
end
+
+ # List of branches associated with their names.
+ fun branches: Map[String, Branch] do
+ api.message(1, "Get branches for {full_name}")
+ var array = api.get("repos/{full_name}/branches")
+ var res = new HashMap[String, Branch]
+ if not array isa JsonArray then return res
+ for obj in array do
+ if not obj isa JsonObject then continue
+ var name = obj["name"].to_s
+ res[name] = new Branch.from_json(api, self, obj)
+ end
+ return res
+ end
+
+ # Repo default branch.
+ fun default_branch: Branch do
+ var name = json["default_branch"].to_s
+ var branch = api.load_branch(self, name)
+ assert branch isa Branch
+ return branch
+ end
+end
+
+# A `RepoEntity` is something contained in a `Repo`.
+abstract class RepoEntity
+ super GithubEntity
+
+ # Repo that contains `self`.
+ var repo: Repo
+
+ # Init `self` from a `json` object.
+ init from_json(api: GithubAPI, repo: Repo, json: JsonObject) do
+ self.api = api
+ self.repo = repo
+ self.json = json
+ end
+end
+
+# A Github branch.
+#
+# Should be accessed from `GithubAPI::load_branch`.
+#
+# See <https://developer.github.com/v3/repos/#list-branches>.
+class Branch
+ super RepoEntity
+
+ redef var key is lazy do return "{repo.key}/branches/{name}"
+
+ # Branch name.
+ var name: String
+
+ redef init from_json(api, repo, json) do
+ self.name = json["name"].to_s
+ super
+ end
+
+ # Get the last commit of `self`.
+ fun commit: Commit do
+ return new Commit.from_json(api, repo, json["commit"].as(JsonObject))
+ end
+
+ # List all commits in `self`.
+ #
+ # This can be long depending on the branch size.
+ # Commit are returned in an unspecified order.
+ fun commits: Array[Commit] do
+ var res = new Array[Commit]
+ var done = new HashSet[String]
+ var todos = new Array[Commit]
+ todos.add commit
+ while not todos.is_empty do
+ var commit = todos.pop
+ if done.has(commit.sha) then continue
+ done.add commit.sha
+ res.add commit
+ for parent in commit.parents do
+ todos.add parent
+ end
+ end
+ return res
+ end
+end
+
+# A Github commit.
+#
+# Should be accessed from `GithubAPI::load_commit`.
+#
+# See <https://developer.github.com/v3/commits/>.
+class Commit
+ super RepoEntity
+
+ redef var key is lazy do return "{repo.key}/commits/{sha}"
+
+ # Commit SHA.
+ var sha: String
+
+ redef init from_json(api, repo, json) do
+ self.sha = json["sha"].to_s
+ super
+ end
+
+ # Parent commits of `self`.
+ fun parents: Array[Commit] do
+ var res = new Array[Commit]
+ var parents = json["parents"]
+ if not parents isa JsonArray then return res
+ for obj in parents do
+ if not obj isa JsonObject then continue
+ res.add(api.load_commit(repo, obj["sha"].to_s).as(not null))
+ end
+ return res
+ end
+
+ # Author of the commit.
+ fun author: nullable User do
+ if not json.has_key("author") then return null
+ var user = json["author"]
+ if not user isa JsonObject then return null
+ return new User.from_json(api, user)
+ end
+
+ # Committer of the commit.
+ fun committer: nullable User do
+ if not json.has_key("committer") then return null
+ var user = json["author"]
+ if not user isa JsonObject then return null
+ return new User.from_json(api, user)
+ end
+
+ # Authoring date as ISODate.
+ fun author_date: ISODate do
+ var commit = json["commit"].as(JsonObject)
+ var author = commit["author"].as(JsonObject)
+ return new ISODate.from_string(author["date"].to_s)
+ end
+
+ # Commit date as ISODate.
+ fun commit_date: ISODate do
+ var commit = json["commit"].as(JsonObject)
+ var author = commit["committer"].as(JsonObject)
+ return new ISODate.from_string(author["date"].to_s)
+ end
+
+ # Commit message.
+ fun message: String do return json["commit"].as(JsonObject)["message"].to_s
end
## OTHER OPTIONS
+`--vm`
+: Run the virtual machine instead of the naive interpreter (experimental)
+
+The virtual machine is currently under heavy development and, unless you are developing the vm, there is no reason to use this option yet.
+
`-o`
: Does nothing. Used for compatibility.
module annotation
import modelbuilder
-private import literal
+import literal
import model::mmodule_data
redef class Prod
end
return res.first
end
-
- # Return all its annotations of a given name in the order of their declaration
- # Retun an empty array if no such an annotation.
- fun get_annotations(name: String): Array[AAnnotation]
- do
- var res = new Array[AAnnotation]
- var nas = n_annotations
- if nas == null then return res
- for na in nas.n_items do
- if na.name != name then continue
- res.add(na)
- end
- return res
- end
end
redef class AAnnotation
- # The name of the annotation
- fun name: String
- do
- return n_atid.n_id.text
- end
-
# Get the single argument of `self` as a `String`.
# Raise error and return null on any inconsistency.
fun arg_as_string(modelbuilder: ModelBuilder): nullable String
end
end
-redef class AExpr
- # Get `self` as a `String`.
- # Return null if not a string.
- fun as_string: nullable String
- do
- if not self isa AStringFormExpr then return null
- return self.value.as(not null)
- end
-
- # Get `self` as an `Int`.
- # Return null if not an integer.
- fun as_int: nullable Int
- do
- if not self isa AIntExpr then return null
- return self.value.as(not null)
- end
-
- # Get `self` as a single identifier.
- # Return null if not a single identifier.
- fun as_id: nullable String
- do
- if self isa AMethidExpr then
- return self.collect_text
- end
- if not self isa ACallExpr then return null
- if not self.n_expr isa AImplicitSelfExpr then return null
- if not self.n_args.n_exprs.is_empty then return null
- return self.n_id.text
- end
-end
-
redef class ModelBuilder
# Collect all annotations by `name` assocated to `mmodule` and its imported modules.
# Note that visibility is not considered.
end
redef class MEntity
- # HTML Escaped name
- fun nitdoc_name: String is abstract
+ # HTML-escaped name.
+ fun nitdoc_name: String do return name.html_escape
# ID used as a HTML unique ID and in file names.
#
# A template link to the mentity `nitdoc_id`
fun tpl_anchor: TplLink do
var tpl = new TplLink("#{nitdoc_id}", nitdoc_name)
+ var mdoc = mdoc_or_fallback
if mdoc != null then
tpl.title = mdoc.short_comment
end
# A template link to the mentity `nitdoc_url`
fun tpl_link: TplLink do
var tpl = new TplLink(nitdoc_url, nitdoc_name)
+ var mdoc = mdoc_or_fallback
if mdoc != null then
tpl.title = mdoc.short_comment
end
# A template article that briefly describe the entity
fun tpl_short_article: TplArticle do
var tpl = tpl_article
+ var mdoc = mdoc_or_fallback
if mdoc != null then
tpl.content = mdoc.tpl_short_comment
end
var lnk = new Template
lnk.add new TplLabel.with_classes(tpl_css_classes)
lnk.add tpl_link
+ var mdoc = mdoc_or_fallback
if mdoc != null then
lnk.add ": "
lnk.add mdoc.tpl_short_comment
private fun tpl_concern_item: TplListItem do
var lnk = new Template
lnk.add tpl_anchor
+ var mdoc = mdoc_or_fallback
if mdoc != null then
lnk.add ": "
lnk.add mdoc.tpl_short_comment
redef class MProject
redef var nitdoc_id = name.to_cmangle is lazy
- redef fun nitdoc_name do return name.html_escape
redef fun nitdoc_url do return root.nitdoc_url
- redef fun mdoc do
- if root != null then
- return root.mdoc
- end
- return super
- end
-
redef fun tpl_declaration do
var tpl = new Template
tpl.add "<span>project "
end
redef class MGroup
- redef fun nitdoc_name do return name.html_escape
-
redef var nitdoc_id is lazy do
if parent != null then
return "{parent.nitdoc_id}__{name.to_cmangle}"
end
redef class MModule
- redef fun nitdoc_name do return name.html_escape
-
redef var nitdoc_id is lazy do
if mgroup != null then
if mgroup.mmodules.length == 1 then
redef fun tpl_definition do
var tpl = new TplClassDefinition
+ var mdoc = mdoc_or_fallback
if mdoc != null then
tpl.comment = mdoc.tpl_comment
end
end
redef class MClass
- redef fun nitdoc_name do return name.html_escape
redef var nitdoc_id = "{intro_mmodule.nitdoc_id}__{name.to_cmangle}" is lazy
redef fun nitdoc_url do return "class_{nitdoc_id}.html"
- redef fun mdoc do return intro.mdoc
+ redef fun mdoc_or_fallback do return intro.mdoc
redef fun tpl_declaration do return intro.tpl_declaration
tpl.add "["
var parameter_names = new Array[String]
for p in mparameters do
- parameter_names.add(p.name)
+ parameter_names.add(p.nitdoc_name)
end
tpl.add parameter_names.join(", ")
tpl.add "]"
redef var nitdoc_id = "{mmodule.nitdoc_id}__{name.to_cmangle}" is lazy
redef fun nitdoc_url do return "{mclass.nitdoc_url}#{nitdoc_id}"
+ redef fun mdoc_or_fallback do return mdoc or else mclass.mdoc_or_fallback
+
redef fun tpl_namespace do
var tpl = new Template
tpl.add mmodule.tpl_namespace
title.add "in "
title.add mmodule.tpl_namespace
tpl.subtitle = title
+ var mdoc = mdoc_or_fallback
if mdoc != null then
tpl.content = mdoc.tpl_comment
end
if not mparameters.is_empty then
tpl.add "["
for i in [0..mparameters.length[ do
- tpl.add "{mparameters[i].name}: "
+ tpl.add "{mparameters[i].nitdoc_name}: "
tpl.add bound_mtype.arguments[i].tpl_signature
if i < mparameters.length - 1 then tpl.add ", "
end
redef fun tpl_definition do
var tpl = new TplClassDefinition
tpl.namespace = tpl_namespace
+ var mdoc = mdoc_or_fallback
if mdoc != null then
tpl.comment = mdoc.tpl_comment
end
redef fun tpl_css_classes do
var set = new HashSet[String]
if is_intro then set.add "intro"
- set.add_all mclass.intro.modifiers
- set.add_all modifiers
+ for m in mclass.intro.modifiers do set.add m.to_cmangle
+ for m in modifiers do set.add m.to_cmangle
return set.to_a
end
var tpl = new Template
for modifier in modifiers do
if modifier == "public" then continue
- tpl.add "{modifier} "
- end
- return tpl
- end
-
- redef fun tpl_list_item do
- var lnk = new Template
- lnk.add new TplLabel.with_classes(tpl_css_classes)
- lnk.add tpl_link
- if mdoc != null then
- lnk.add ": "
- lnk.add mdoc.tpl_short_comment
- else if mclass.intro.mdoc != null then
- lnk.add ": "
- lnk.add mclass.intro.mdoc.tpl_short_comment
- end
- return new TplListItem.with_content(lnk)
- end
-
- redef fun tpl_anchor: TplLink do
- var tpl = new TplLink("#{nitdoc_id}", nitdoc_name)
- if mdoc != null then
- tpl.title = mdoc.short_comment
- else if mclass.intro.mdoc != null then
- tpl.title = mclass.intro.mdoc.short_comment
- end
- return tpl
- end
-
- redef fun tpl_link: TplLink do
- var tpl = new TplLink(nitdoc_url, nitdoc_name)
- if mdoc != null then
- tpl.title = mdoc.short_comment
- else if mclass.intro.mdoc != null then
- tpl.title = mclass.intro.mdoc.short_comment
+ tpl.add "{modifier.html_escape} "
end
return tpl
end
redef class MProperty
redef var nitdoc_id = "{intro_mclassdef.mclass.nitdoc_id}__{name.to_cmangle}" is lazy
- redef fun nitdoc_name do return name.html_escape
redef fun nitdoc_url do return "property_{nitdoc_id}.html"
- redef fun mdoc do return intro.mdoc
+ redef fun mdoc_or_fallback do return intro.mdoc
redef fun tpl_namespace do
var tpl = new Template
redef var nitdoc_id = "{mclassdef.nitdoc_id}__{name.to_cmangle}" is lazy
redef fun nitdoc_url do return "{mproperty.nitdoc_url}#{nitdoc_id}"
- redef fun tpl_anchor: TplLink do
- var tpl = new TplLink("#{nitdoc_id}", nitdoc_name)
- if mdoc != null then
- tpl.title = mdoc.short_comment
- else if mproperty.intro.mdoc != null then
- tpl.title = mproperty.intro.mdoc.short_comment
- end
- return tpl
- end
-
- redef fun tpl_link: TplLink do
- var tpl = new TplLink(nitdoc_url, nitdoc_name)
- if mdoc != null then
- tpl.title = mdoc.short_comment
- else if mproperty.intro.mdoc != null then
- tpl.title = mproperty.intro.mdoc.short_comment
- end
- return tpl
- end
+ redef fun mdoc_or_fallback do return mdoc or else mproperty.mdoc_or_fallback
redef fun tpl_namespace do
var tpl = new Template
title.add mclassdef.tpl_link
tpl.title = title
tpl.subtitle = tpl_declaration
+ var mdoc = mdoc_or_fallback
if mdoc != null then
tpl.content = mdoc.tpl_comment
end
redef fun tpl_definition do
var tpl = new TplDefinition
tpl.namespace = mclassdef.tpl_namespace
+ var mdoc = mdoc_or_fallback
if mdoc != null then
tpl.comment = mdoc.tpl_comment
end
redef fun tpl_css_classes do
var set = new HashSet[String]
if is_intro then set.add "intro"
- set.add_all mproperty.intro.modifiers
- set.add_all modifiers
+ for m in mproperty.intro.modifiers do set.add m.to_cmangle
+ for m in modifiers do set.add m.to_cmangle
return set.to_a
end
var tpl = new Template
for modifier in modifiers do
if modifier == "public" then continue
- tpl.add "{modifier} "
+ tpl.add "{modifier.html_escape} "
end
return tpl
end
var anchor = tpl_link
anchor.href = "{mclassdef.mclass.nitdoc_url}#{mproperty.nitdoc_id}"
lnk.add anchor
+ var mdoc = mdoc_or_fallback
if mdoc != null then
lnk.add ": "
lnk.add mdoc.tpl_short_comment
- else if mproperty.intro.mdoc != null then
- lnk.add ": "
- lnk.add mproperty.intro.mdoc.tpl_short_comment
end
return new TplListItem.with_content(lnk)
end
var anchor = mclassdef.tpl_link
anchor.href = "{mclassdef.mclass.nitdoc_url}#{mproperty.nitdoc_id}"
lnk.add anchor
+ var mdoc = mdoc_or_fallback
if mdoc != null then
lnk.add ": "
lnk.add mdoc.tpl_short_comment
var tpl = new Template
var params = new Array[String]
for param in intro.msignature.mparameters do
- params.add param.name
+ params.add param.name.html_escape
end
if not params.is_empty then
tpl.add "("
redef class MParameterType
redef fun tpl_link do
- return new TplLink.with_title("{mclass.nitdoc_url}#FT_{name}", name, "formal type")
+ return new TplLink.with_title("{mclass.nitdoc_url}#FT_{name.to_cmangle}", name, "formal type")
end
redef fun tpl_signature do return tpl_link
end
redef fun tpl_definition do
var tpl = new TplClassDefinition
tpl.namespace = mclassdef.tpl_namespace
+ var mdoc = mdoc_or_fallback
if mdoc != null then
tpl.comment = mdoc.tpl_comment
end
var source = ctx.opt_source.value
if source == null then
var url = location.file.filename.simplify_path
- return "<a target='_blank' title='Show source' href=\"{url}\">View Source</a>"
+ return "<a target='_blank' title='Show source' href=\"{url.html_escape}\">View Source</a>"
end
# THIS IS JUST UGLY ! (but there is no replace yet)
var x = source.split_with("%f")
x = source.split_with("%L")
source = x.join(location.line_end.to_s)
source = source.simplify_path
- return "<a target='_blank' title='Show source' href=\"{source.to_s}\">View Source</a>"
+ return "<a target='_blank' title='Show source' href=\"{source.to_s.html_escape}\">View Source</a>"
end
# MProject description template
var article = mproject.tpl_article
article.subtitle = mproject.tpl_declaration
article.content = mproject.tpl_definition
- if mproject.mdoc != null then
- article.content = mproject.mdoc.tpl_short_comment
+ var mdoc = mproject.mdoc_or_fallback
+ if mdoc != null then
+ article.content = mdoc.tpl_short_comment
end
return article
end
else
var cls_url = mprop.intro.mclassdef.mclass.nitdoc_url
var def_url = "{cls_url}#{mprop.nitdoc_id}"
- var lnk = new TplLink.with_title(def_url, mprop.name, "Go to introduction")
+ var lnk = new TplLink.with_title(def_url, mprop.nitdoc_name,
+ "Go to introduction")
title.add "redef "
title.add lnk
end
article.title_classes.add "signature"
article.summary_title = "{mprop.nitdoc_name}"
article.subtitle = main_mpropdef.tpl_namespace
- if main_mpropdef.mdoc != null then
- article.content = main_mpropdef.mdoc.tpl_comment
+ if main_mpropdef.mdoc_or_fallback != null then
+ article.content = main_mpropdef.mdoc_or_fallback.tpl_comment
end
var subarticle = new TplArticle("{main_mpropdef.nitdoc_id}.redefs")
# Add redef in same `MClass`
redef_article.title_classes.add "signature info"
redef_article.css_classes.add "nospace"
var redef_content = new Template
- if mpropdef.mdoc != null then
- redef_content.add mpropdef.mdoc.tpl_comment
+ if mpropdef.mdoc_or_fallback != null then
+ redef_content.add mpropdef.mdoc_or_fallback.tpl_comment
end
redef_article.content = redef_content
subarticle.add_child redef_article
classes.add "inherit"
var cls_url = mprop.intro.mclassdef.mclass.nitdoc_url
var def_url = "{cls_url}#{mprop.nitdoc_id}"
- var lnk = new TplLink(def_url, mprop.name)
- if mprop.intro.mdoc != null then lnk.title = mprop.intro.mdoc.short_comment
+ var lnk = new TplLink(def_url, mprop.nitdoc_name)
+ var mdoc = mprop.intro.mdoc_or_fallback
+ if mdoc != null then lnk.title = mdoc.short_comment
var item = new Template
item.add new TplLabel.with_classes(classes)
item.add lnk
var section = new TplSection.with_title("top", tpl_title)
section.subtitle = mclass.intro.tpl_declaration
var article = new TplArticle("comment")
- if mclass.mdoc != null then
- article.content = mclass.mdoc.tpl_comment
+ var mdoc = mclass.mdoc_or_fallback
+ if mdoc != null then
+ article.content = mdoc.tpl_comment
end
section.add_child article
return section
class TplPage
super Template
- # Page title in HTML header
+ # The unescaped page title to put in the HTML header.
var title: String is writable, noinit
# Page url
addn " <link rel='stylesheet' href='{css}/Nitdoc.QuickSearch.css'/>"
addn " <link rel='stylesheet' href='{css}/Nitdoc.ModalBox.css'/>"
addn " <link rel='stylesheet' href='{css}/Nitdoc.GitHub.css'/>"
- addn " <title>{title}</title>"
+ addn " <title>{title.html_escape}</title>"
addn "</head>"
add "<body"
for attr in body_attrs do add attr
# Link href
var href: String is writable
- # Text to display in the link
+ # The raw HTML content to display in the link
var text: Streamable is writable
- # Optional title
+ # The unescaped optional title.
var title: nullable String = null is writable
init with_title(href, text, title: String) do
redef fun rendering do
add "<a href=\""
- add href
+ add href.html_escape
add "\""
if title != null then
add " title=\""
- add title.as(not null)
+ add title.as(not null).html_escape
add "\""
end
add ">"
# Implementation of the method-related annotation `cached`
#
-# Note this module can be used as a reference on how to implements
-# complex annotation that modify both the model and the AST of a Nit program
+# The cached annotation is deprecated, use the `lazy` annotation instead.
module cached
import modelize
intrude import modelize::modelize_property
redef class ToolContext
+ # Process the `cached` annotation on methods
var cached_phase: Phase = new CachedPhase(self, [modelize_property_phase])
end
private import annotation
redef class ToolContext
+ # Check for unknown annotation in each module
var check_annotation_phase: Phase = new CheckAnnotationPhase(self, null)
end
abstract
intern
extern
+no_warning
pkgconfig
c_compiler_option
# Collect and orchestration of main frontend phases
module frontend
+import no_warning
import simple_misc_analysis
import literal
import modelize
redef class ToolContext
# FIXME: there is conflict in linex in nitc, so use this trick to force invocation
private var dummy: Bool = do_dummy
- fun do_dummy: Bool
+
+ # SEE `dummy`
+ private fun do_dummy: Bool
do
# Force easy warnings after modelbuilder
phases.add_edge(simple_misc_analysis_phase, modelize_property_phase)
--- /dev/null
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Fill toolcontext information about blacklisting of warnings.
+module no_warning
+
+import modelbuilder
+private import literal
+
+redef class ToolContext
+ # The phase should be executed before any warning on the module is processed.
+ var no_warning_phase: Phase = new NoWarningPhase(self, [literal_phase])
+end
+
+private class NoWarningPhase
+ super Phase
+
+ redef fun process_nmodule(nmodule)
+ do
+ # Get the mmodule
+ var mmodule = nmodule.mmodule
+ assert mmodule != null
+
+ # If no decl block then quit
+ var nmoduledecl = nmodule.n_moduledecl
+ if nmoduledecl == null then return
+
+ var modelbuilder = toolcontext.modelbuilder
+
+ # Get all the new annotations
+ var name = "no_warning"
+ var annots = nmoduledecl.get_annotations(name)
+
+ if annots.is_empty then return
+
+ var source = nmodule.location.file
+ if source == null then
+ modelbuilder.warning(annots.first, "file-less-module", "Warning: annotation `{name}` does not currently work on file-less modules.")
+ return
+ end
+
+ for annot in annots do
+ var args = annot.n_args
+ if args.is_empty then
+ modelbuilder.error(annot, "Annotation error: `{name}` needs a list of warnings. Use `\"all\"` to disable all warnings.")
+ continue
+ end
+ for arg in args do
+ var tag = arg.as_string
+ if tag == null then
+ modelbuilder.error(arg, "Annotation error: `{name}` expects String as arguments.")
+ continue
+ end
+
+ toolcontext.warning_blacklist[source].add(tag)
+ end
+ end
+ end
+end
private import annotation
redef class ToolContext
+ # Generate serialization and deserialization methods on `auto_serializable` annotated classes.
var serialization_phase_pre_model: Phase = new SerializationPhasePreModel(self, null)
+
+ # The second phase of the serialization
var serialization_phase_post_model: Phase = new SerializationPhasePostModel(self,
[modelize_class_phase, serialization_phase_pre_model])
import phase
redef class ToolContext
+ # Execute `AModule::do_simple_misc_analysis` on each module.
var simple_misc_analysis_phase: Phase = new SimpleMiscAnalysisPhase(self, null)
end
# See the License for the specific language governing permissions and
# limitations under the License.
-# Highliting of Nit AST
+# Highlighting of Nit AST
module highlight
import frontend
html.add_class("nitcode")
end
+ # The entry-point of the highlighting.
+ # Will fill `html` with the generated HTML content.
fun enter_visit(n: ANode)
do
n.parentize_tokens
return res
end
+ # The module HTML page
fun href: String
do
return name + ".html"
return res
end
+ # The class HTML page (an anchor in the module page)
fun href: String
do
return mmodule.href + "#" + to_s
return res
end
+ # The property HTML page (an anchor in the module page)
fun href: String
do
return self.mclassdef.mmodule.href + "#" + self.to_s
import phase
redef class ToolContext
+ # Parses literal values in the whole AST and produces errors if needed
var literal_phase: Phase = new LiteralPhase(self, null)
end
private fun accept_literal(v: LiteralVisitor) do end
end
+redef class AExpr
+ # Get `self` as a `String`.
+ # Return null if not a string.
+ fun as_string: nullable String
+ do
+ if not self isa AStringFormExpr then return null
+ return self.value.as(not null)
+ end
+
+ # Get `self` as an `Int`.
+ # Return null if not an integer.
+ fun as_int: nullable Int
+ do
+ if not self isa AIntExpr then return null
+ return self.value.as(not null)
+ end
+
+ # Get `self` as a single identifier.
+ # Return null if not a single identifier.
+ fun as_id: nullable String
+ do
+ if self isa AMethidExpr then
+ return self.collect_text
+ end
+ if not self isa ACallExpr then return null
+ if not self.n_expr isa AImplicitSelfExpr then return null
+ if not self.n_args.n_exprs.is_empty then return null
+ return self.n_id.text
+ end
+end
+
+
redef class AIntExpr
# The value of the literal int once computed.
var value: nullable Int
# See the License for the specific language governing permissions and
# limitations under the License.
-# This module is used to model Nit source-file and locations in source-file
+# Nit source-file and locations in source-file
module location
# A raw text Nit source file
super Comparable
redef type OTHER: Location
+ # The associated source-file
var file: nullable SourceFile
+
+ # The starting line number (starting from 1)
var line_start: Int
+
+ # The stopping line number (starting from 1)
var line_end: Int
# Start of this location on `line_start`
# Require: `column_start >= 0`
var column_start: Int
+ # End of this location on `line_end`
var column_end: Int
# The index in the start character in the source
private var text_cache: nullable String = null
- init with_file(f: SourceFile) do init(f,0,0,0,0)
-
redef fun ==(other: nullable Object): Bool do
if other == null then return false
if not other isa Location then return false
# is empty if the class is not generic
var mparameters = new Array[MParameterType]
+ # Initialize `mparameters` from their names.
protected fun setup_parameter_names(parameter_names: nullable Array[String]) is
autoinit
do
end
end
+ # Returns a new parameter with the `mtype` resolved.
+ # See `MType::resolve_for` for details.
fun resolve_for(mtype: MType, anchor: nullable MClassType, mmodule: MModule, cleanup_virtual: Bool): MParameter
do
if not self.mtype.need_anchor then return self
redef class ADoc
private var mdoc_cache: nullable MDoc
+
+ # Convert `self` to a `MDoc`
fun to_mdoc: MDoc
do
var res = mdoc_cache
import modelbuilder
redef class ToolContext
+ # Run `AModule::build_classes` on each module
var modelize_class_phase: Phase = new ModelizeClassPhase(self, null)
end
private import annotation
redef class ToolContext
+ # Run `AClassdef::build_property` on the classdefs of each module
var modelize_property_phase: Phase = new ModelizePropertyPhase(self, [modelize_class_phase])
end
end
redef class AClassdef
- var build_properties_is_done = false
+ # Marker used in `ModelBuilder::build_properties`
+ private var build_properties_is_done = false
# The free init (implicitely constructed by the class if required)
var mfree_init: nullable MMethodDef = null
import interpreter
import frontend
import parser_util
+import vm
# Create a tool context to handle options and paths
var toolcontext = new ToolContext
toolcontext.option_context.add_option(opt)
var opt_eval = new OptionBool("Specifies the program from command-line", "-e")
var opt_loop = new OptionBool("Repeatedly run the program for each line in file-name arguments", "-n")
-toolcontext.option_context.add_option(opt_eval, opt_loop)
+var opt_vm = new OptionBool("Run the virtual machine instead of the naive interpreter (experimental)", "--vm")
+toolcontext.option_context.add_option(opt_eval, opt_loop, opt_vm)
# We do not add other options, so process them now!
toolcontext.process_options(args)
modelbuilder.run_debugger_autorun(self_mm, self_args)
else if toolcontext.opt_debugger_mode.value then
modelbuilder.run_debugger(self_mm, self_args)
+else if opt_vm.value then
+ modelbuilder.run_virtual_machine(self_mm, self_args)
else
modelbuilder.run_naive_interpreter(self_mm, self_args)
end
var self_mm = mainmodule
var self_args = arguments
-modelbuilder.run_naive_interpreter(self_mm, self_args)
+modelbuilder.run_virtual_machine(self_mm, self_args)
# Lexer and its tokens.
# This file was generated by SableCC (http://www.sablecc.org/).
-module lexer
+module lexer is no_warning("missing-doc")
intrude import parser_nodes
intrude import lexer_work
# Parser.
# This file was generated by SableCC (http://www.sablecc.org/).
-module parser
+module parser is no_warning("missing-doc", "unread-variable")
intrude import parser_prod
intrude import parser_work
# Raw AST node hierarchy.
# This file was generated by SableCC (http://www.sablecc.org/).
-module parser_abs
+module parser_abs is no_warning("missing-doc")
import location
# Visit all nodes in order.
# Thus, call `v.enter_visit(e)` for each child `e`
fun visit_all(v: Visitor) is abstract
+
+ # Do a deep search and return an array of tokens that match a given text
+ fun collect_tokens_by_text(text: String): Array[Token]
+ do
+ var v = new CollectTokensByTextVisitor(text)
+ v.enter_visit(self)
+ return v.result
+ end
+
+ # Do a deep search and return an array of node that are annotated
+ # The attached node can be retrieved by two invocations of parent
+ fun collect_annotations_by_name(name: String): Array[AAnnotation]
+ do
+ var v = new CollectAnnotationsByNameVisitor(name)
+ v.enter_visit(self)
+ return v.result
+ end
+end
+
+private class CollectTokensByTextVisitor
+ super Visitor
+ var text: String
+ var result = new Array[Token]
+ redef fun visit(node)
+ do
+ node.visit_all(self)
+ if node isa Token and node.text == text then result.add(node)
+ end
end
+private class CollectAnnotationsByNameVisitor
+ super Visitor
+ var name: String
+ var result = new Array[AAnnotation]
+ redef fun visit(node)
+ do
+ node.visit_all(self)
+ if node isa AAnnotation and node.n_atid.n_id.text == name then result.add(node)
+ end
+end
+
+
# A sequence of nodes
# It is a specific class (instead of using a Array) to track the parent/child relation when nodes are added or removed
class ANodes[E: ANode]
# All the annotations attached directly to the node
var n_annotations: nullable AAnnotations = null is writable
+ # Return all its annotations of a given name in the order of their declaration
+ # Retun an empty array if no such an annotation.
+ fun get_annotations(name: String): Array[AAnnotation]
+ do
+ var res = new Array[AAnnotation]
+ var nas = n_annotations
+ if nas == null then return res
+ for na in nas.n_items do
+ if na.name != name then continue
+ res.add(na)
+ end
+ return res
+ end
+
redef fun replace_with(n: ANode)
do
super
end
end
-# A standard identifier (variable, method...). They start with a lowercase.
+# A standard identifier (variable, method...). They start with a lowercase.
class TId
super Token
redef fun to_s
class AModule
super Prod
+ # The declaration part of the module
var n_moduledecl: nullable AModuledecl = null is writable
+
+ # List of importation clauses
var n_imports = new ANodes[AImport](self)
+
+ # List of extern blocks
var n_extern_code_blocks = new ANodes[AExternCodeBlock](self)
+
+ # List of class definition (including top-level methods and the main)
var n_classdefs = new ANodes[AClassdef](self)
end
-# The declaration of the module with the documentation, name, and annotations
-class AModuledecl
+# Abstract class for definition of entities
+abstract class ADefinition
super Prod
+ # The documentation
var n_doc: nullable ADoc = null is writable
+
+ # The `redef` keyword
var n_kwredef: nullable TKwredef = null is writable
- var n_visibility: AVisibility is writable, noinit
+
+ # The declared visibility
+ var n_visibility: nullable AVisibility = null is writable
+end
+
+# The declaration of the module with the documentation, name, and annotations
+class AModuledecl
+ super ADefinition
+
+ # The `module` keyword
var n_kwmodule: TKwmodule is writable, noinit
+
+ # The declared module name
var n_name: AModuleName is writable, noinit
end
# A import clause of a module
abstract class AImport
super Prod
+
+ # The declared visibility
+ var n_visibility: AVisibility is writable, noinit
+
+ # The `import` keyword
+ var n_kwimport: TKwimport is writable, noinit
end
# A standard import clause. eg `import x`
class AStdImport
super AImport
- var n_visibility: AVisibility is writable, noinit
- var n_kwimport: TKwimport is writable, noinit
+ # The imported module name
var n_name: AModuleName is writable, noinit
end
# The special import clause of the kernel module. eg `import end`
class ANoImport
super AImport
- var n_visibility: AVisibility is writable, noinit
- var n_kwimport: TKwimport is writable, noinit
+ # The `end` keyword, that indicate the root module
var n_kwend: TKwend is writable, noinit
end
# An implicit or explicit public visibility modifier
class APublicVisibility
super AVisibility
+ # The `public` keyword, if any
var n_kwpublic: nullable TKwpublic is writable
end
# An explicit private visibility modifier
class APrivateVisibility
super AVisibility
+ # The `private` keyword
var n_kwprivate: TKwprivate is writable, noinit
end
# An explicit protected visibility modifier
class AProtectedVisibility
super AVisibility
+ # The `protected` keyword
var n_kwprotected: TKwprotected is writable, noinit
end
# An explicit intrude visibility modifier
class AIntrudeVisibility
super AVisibility
+ # The `intrude` keyword
var n_kwintrude: TKwintrude is writable, noinit
end
# There is tow special case of class definition
abstract class AClassdef
super Prod
+ # All the declared properties (including the main method)
var n_propdefs = new ANodes[APropdef](self)
end
# A standard class definition with a name, superclasses and properties
class AStdClassdef
super AClassdef
- var n_doc: nullable ADoc = null is writable
- var n_kwredef: nullable TKwredef = null is writable
- var n_visibility: AVisibility is writable, noinit
+ super ADefinition
+
+ # The class kind (interface, abstract class, etc.)
var n_classkind: AClasskind is writable, noinit
+
+ # The name of the class
var n_id: nullable TClassid = null is writable
+
+ # The list of formal parameter types
var n_formaldefs = new ANodes[AFormaldef](self)
+
+ # The extern block code
var n_extern_code_block: nullable AExternCodeBlock = null is writable
+
+ # The list of super-classes
var n_superclasses = new ANodes[ASuperclass](self)
+
+ # The `end` keyword
var n_kwend: TKwend is writable, noinit
+
redef fun hot_location do return n_id.location
end
# A default, or concrete class modifier (just `class`)
class AConcreteClasskind
super AClasskind
+
+ # The `class` keyword.
var n_kwclass: TKwclass is writable, noinit
end
# An abstract class modifier (`abstract class`)
class AAbstractClasskind
super AClasskind
+
+ # The `abstract` keyword.
var n_kwabstract: TKwabstract is writable, noinit
+
+ # The `class` keyword.
var n_kwclass: TKwclass is writable, noinit
end
# An interface class modifier (`interface`)
class AInterfaceClasskind
super AClasskind
+
+ # The `interface` keyword.
var n_kwinterface: TKwinterface is writable, noinit
end
# An enum/universal class modifier (`enum class`)
class AEnumClasskind
super AClasskind
+
+ # The `enum` keyword.
var n_kwenum: TKwenum is writable, noinit
end
# An extern class modifier (`extern class`)
class AExternClasskind
super AClasskind
+
+ # The `extern` keyword.
var n_kwextern: TKwextern is writable, noinit
+
+ # The `class` keyword.
var n_kwclass: nullable TKwclass = null is writable
end
# The definition of a formal generic parameter type. eg `X: Y`
class AFormaldef
super Prod
+
+ # The name of the parameter type
var n_id: TClassid is writable, noinit
+
# The bound of the parameter type
var n_type: nullable AType = null is writable
end
# A super-class. eg `super X`
class ASuperclass
super Prod
+
+ # The super keyword
var n_kwsuper: TKwsuper is writable, noinit
+
+ # The super-class (indicated as a type)
var n_type: AType is writable, noinit
end
# The definition of a property
abstract class APropdef
- super Prod
- var n_doc: nullable ADoc = null is writable
- var n_kwredef: nullable TKwredef = null is writable
- var n_visibility: nullable AVisibility = null is writable
+ super ADefinition
end
# A definition of an attribute
# For historical reason, old-syle and new-style attributes use the same `ANode` sub-class
class AAttrPropdef
super APropdef
+
+ # The identifier for a old-style attribute (null if new-style)
var n_kwvar: TKwvar is writable, noinit
# The identifier for a new-style attribute (null if old-style)
var n_id2: TId is writable, noinit
+ # The declared type of the attribute
var n_type: nullable AType = null is writable
- # The initial value, if any
+ # The initial value, if any (set with `=`)
var n_expr: nullable AExpr = null is writable
+ # The initial value, if any (set with `do return`)
var n_block: nullable AExpr = null is writable
redef fun hot_location
# A definition of all kind of method (including constructors)
class AMethPropdef
super APropdef
+
+ # The `fun` keyword, if any
var n_kwmeth: nullable TKwmeth = null is writable
+
+ # The `init` keyword, if any
var n_kwinit: nullable TKwinit = null is writable
+
+ # The `new` keyword, if any
var n_kwnew: nullable TKwnew = null is writable
+
+ # The name of the method, if any
var n_methid: nullable AMethid = null is writable
+
+ # The signature of the method, if any
var n_signature: nullable ASignature = null is writable
+
+ # The body (in Nit) of the method, if any
var n_block: nullable AExpr = null is writable
+
+ # The list of declared callbacks (for extern methods)
var n_extern_calls: nullable AExternCalls = null is writable
+
+ # The body (in extern code) of the method, if any
var n_extern_code_block: nullable AExternCodeBlock = null is writable
+
redef fun hot_location
do
if n_methid != null then
# Declaration of callbacks for extern methods
class AExternCalls
super Prod
+
+ # The `import` keyword
var n_kwimport: TKwimport is writable, noinit
+
+ # The list of declared callbacks
var n_extern_calls: ANodes[AExternCall] = new ANodes[AExternCall](self)
end
# A single callback declaration on a method on the current receiver
class ALocalPropExternCall
super APropExternCall
+
+ # The name of the called-back method
var n_methid: AMethid is writable, noinit
end
# A single callback declaration on a method on an explicit receiver type.
class AFullPropExternCall
super APropExternCall
+
+ # The type of the receiver of the called-back method
var n_type: AType is writable, noinit
+
+ # The dot `.`
var n_dot: nullable TDot = null is writable
+
+ # The name of the called-back method
var n_methid: AMethid is writable, noinit
end
# A single callback declaration on a method on a constructor
class AInitPropExternCall
super APropExternCall
+
+ # The allocated type
var n_type: AType is writable, noinit
end
# A single callback declaration on a `super` call
class ASuperExternCall
super AExternCall
+
+ # The `super` keyword
var n_kwsuper: TKwsuper is writable, noinit
end
# A single callback declaration on a cast to a given type
class ACastAsExternCall
super ACastExternCall
+
+ # The origin type of the cast
var n_from_type: AType is writable, noinit
+
+ # The dot (`.`)
var n_dot: nullable TDot = null is writable
+
+ # The `as` keyword
var n_kwas: TKwas is writable, noinit
+
+ # The destination of the cast
var n_to_type: AType is writable, noinit
end
# A single callback declaration on a cast to a nullable type
class AAsNullableExternCall
super ACastExternCall
+
+ # The origin type to cast as nullable
var n_type: AType is writable, noinit
+
+ # The `as` keyword
var n_kwas: TKwas is writable, noinit
+
+ # The `nullable` keyword
var n_kwnullable: TKwnullable is writable, noinit
end
# A single callback declaration on a cast to a non-nullable type
class AAsNotNullableExternCall
super ACastExternCall
+
+ # The destination type on a cast to not nullable
var n_type: AType is writable, noinit
+
+ # The `as` keyword.
var n_kwas: TKwas is writable, noinit
+
+ # The `not` keyword
var n_kwnot: TKwnot is writable, noinit
+
+ # The `nullable` keyword
var n_kwnullable: TKwnullable is writable, noinit
end
# A definition of a virtual type
class ATypePropdef
super APropdef
+
+ # The `type` keyword
var n_kwtype: TKwtype is writable, noinit
+
+ # The name of the virtual type
var n_id: TClassid is writable, noinit
+
+ # The bound of the virtual type
var n_type: AType is writable, noinit
end
# A method name with a simple identifier
class AIdMethid
super AMethid
+
+ # The simple identifier
var n_id: TId is writable, noinit
end
# A method name `+`
class APlusMethid
super AMethid
+
+ # The `+` symbol
var n_plus: TPlus is writable, noinit
end
# A method name `-`
class AMinusMethid
super AMethid
+
+ # The `-` symbol
var n_minus: TMinus is writable, noinit
end
# A method name `*`
class AStarMethid
super AMethid
+
+ # The `*` symbol
var n_star: TStar is writable, noinit
end
# A method name `**`
class AStarstarMethid
super AMethid
+
+ # The `**` symbol
var n_starstar: TStarstar is writable, noinit
end
# A method name `/`
class ASlashMethid
super AMethid
+
+ # The `/` symbol
var n_slash: TSlash is writable, noinit
end
# A method name `%`
class APercentMethid
super AMethid
+
+ # The `%` symbol
var n_percent: TPercent is writable, noinit
end
# A method name `==`
class AEqMethid
super AMethid
+
+ # The `==` symbol
var n_eq: TEq is writable, noinit
end
# A method name `!=`
class ANeMethid
super AMethid
+
+ # The `!=` symbol
var n_ne: TNe is writable, noinit
end
# A method name `<=`
class ALeMethid
super AMethid
+
+ # The `<=` symbol
var n_le: TLe is writable, noinit
end
# A method name `>=`
class AGeMethid
super AMethid
+
+ # The `>=` symbol
var n_ge: TGe is writable, noinit
end
# A method name `<`
class ALtMethid
super AMethid
+
+ # The `<` symbol
var n_lt: TLt is writable, noinit
end
# A method name `>`
class AGtMethid
super AMethid
+
+ # The `>` symbol
var n_gt: TGt is writable, noinit
end
# A method name `<<`
class ALlMethid
super AMethid
+
+ # The `<<` symbol
var n_ll: TLl is writable, noinit
end
# A method name `>>`
class AGgMethid
super AMethid
+
+ # The `>>` symbol
var n_gg: TGg is writable, noinit
end
# A method name `[]`
class ABraMethid
super AMethid
+
+ # The `[` symbol
var n_obra: TObra is writable, noinit
+
+ # The `]` symbol
var n_cbra: TCbra is writable, noinit
end
# A method name `<=>`
class AStarshipMethid
super AMethid
+
+ # The `<=>` symbol
var n_starship: TStarship is writable, noinit
end
# A setter method name with a simple identifier (with a `=`)
class AAssignMethid
super AMethid
+
+ # The base identifier
var n_id: TId is writable, noinit
+
+ # The `=` symbol
var n_assign: TAssign is writable, noinit
end
# A method name `[]=`
class ABraassignMethid
super AMethid
+
+ # The `[` symbol
var n_obra: TObra is writable, noinit
+
+ # The `]` symbol
var n_cbra: TCbra is writable, noinit
+
+ # The `=` symbol
var n_assign: TAssign is writable, noinit
end
# A signature in a method definition. eg `(x,y:X,z:Z):T`
class ASignature
super Prod
+
+ # The `(` symbol
var n_opar: nullable TOpar = null is writable
+
+ # The list of parameters
var n_params = new ANodes[AParam](self)
+
+ # The `)` symbol
var n_cpar: nullable TCpar = null is writable
+
+ # The return type
var n_type: nullable AType = null is writable
end
# A parameter definition in a signature. eg `x:X`
class AParam
super Prod
+
+ # The name of the parameter
var n_id: TId is writable, noinit
+
+ # The type of the parameter, if any
var n_type: nullable AType = null is writable
+
+ # The `...` symbol to indicate varargs
var n_dotdotdot: nullable TDotdotdot = null is writable
end
# A static type. eg `nullable X[Y]`
class AType
super Prod
+ # The `nullable` keyword
var n_kwnullable: nullable TKwnullable = null is writable
# The name of the class or of the formal type
# A label at the end of a block or in a break/continue statement. eg `label x`
class ALabel
super Prod
+
+ # The `label` keyword
var n_kwlabel: TKwlabel is writable, noinit
+
+ # The name of the label, if any
var n_id: nullable TId is writable
end
# The last `AExpr` gives the value of the whole block
class ABlockExpr
super AExpr
+
+ # The list of statements in the bloc.
+ # The last element is often considered as an expression that give the value of the whole block.
var n_expr = new ANodes[AExpr](self)
+
+ # The `end` keyword
var n_kwend: nullable TKwend = null is writable
end
# A declaration of a local variable. eg `var x: X = y`
class AVardeclExpr
super AExpr
+
+ # The `var` keyword
var n_kwvar: TKwvar is writable, noinit
+
+ # The name of the local variable
var n_id: TId is writable, noinit
+
+ # The declaration type of the local variable
var n_type: nullable AType = null is writable
+
+ # The `=` symbol (for the initial value)
var n_assign: nullable TAssign = null is writable
# The initial value, if any
# A `return` statement. eg `return x`
class AReturnExpr
super AExpr
+
+ # The `return` keyword
var n_kwreturn: nullable TKwreturn = null is writable
+
+ # The return value, if any
var n_expr: nullable AExpr = null is writable
end
# Something that has a label.
abstract class ALabelable
super Prod
+
+ # The associated label declatation
var n_label: nullable ALabel = null is writable
end
abstract class AEscapeExpr
super AExpr
super ALabelable
+
+ # The return value, if nay (unused currently)
var n_expr: nullable AExpr = null is writable
end
# A `break` statement.
class ABreakExpr
super AEscapeExpr
+
+ # The `break` keyword
var n_kwbreak: TKwbreak is writable, noinit
end
# An `abort` statement
class AAbortExpr
super AExpr
+
+ # The `abort` keyword
var n_kwabort: TKwabort is writable, noinit
end
# A `continue` statement
class AContinueExpr
super AEscapeExpr
+
+ # The `continue` keyword.
var n_kwcontinue: nullable TKwcontinue = null is writable
end
class ADoExpr
super AExpr
super ALabelable
+
+ # The `do` keyword
var n_kwdo: TKwdo is writable, noinit
+
+ # The list of statements of the `do`.
var n_block: nullable AExpr = null is writable
end
# A `if` statement
class AIfExpr
super AExpr
+
+ # The `if` keyword
var n_kwif: TKwif is writable, noinit
+
+ # The expression used as the condition of the `if`
var n_expr: AExpr is writable, noinit
+
+ # The body of the `then` part
var n_then: nullable AExpr = null is writable
+
+ # The body of the `else` part
var n_else: nullable AExpr = null is writable
end
-# A `if` expression
+# A `if` expression (ternary conditional). eg. `if true then 1 else 0`
class AIfexprExpr
super AExpr
+
+ # The `if` keyword
var n_kwif: TKwif is writable, noinit
+
+ # The expression used as the condition of the `if`
var n_expr: AExpr is writable, noinit
+
+ # The `then` keyword
var n_kwthen: TKwthen is writable, noinit
+
+ # The expression in the `then` part
var n_then: AExpr is writable, noinit
+
+ # The `else` keyword
var n_kwelse: TKwelse is writable, noinit
+
+ # The expression in the `else` part
var n_else: AExpr is writable, noinit
end
class AWhileExpr
super AExpr
super ALabelable
+
+ # The `while` keyword
var n_kwwhile: TKwwhile is writable, noinit
+
+ # The expression used as the condition of the `while`
var n_expr: AExpr is writable, noinit
+
+ # The `do` keyword
var n_kwdo: TKwdo is writable, noinit
+
+ # The body of the loop
var n_block: nullable AExpr = null is writable
end
class ALoopExpr
super AExpr
super ALabelable
+
+ # The `loop` keyword
var n_kwloop: TKwloop is writable, noinit
+
+ # The body of the loop
var n_block: nullable AExpr = null is writable
end
class AForExpr
super AExpr
super ALabelable
+
+ # The `for` keyword
var n_kwfor: TKwfor is writable, noinit
+
+ # The list of name of the automatic variables
var n_ids = new ANodes[TId](self)
+
+ # The expression used as the collection to iterate on
var n_expr: AExpr is writable, noinit
+
+ # The `do` keyword
var n_kwdo: TKwdo is writable, noinit
+
+ # The body of the loop
var n_block: nullable AExpr = null is writable
end
# An `assert` statement
class AAssertExpr
super AExpr
+
+ # The `assert` keyword
var n_kwassert: TKwassert is writable, noinit
+
+ # The name of the assert, if any
var n_id: nullable TId = null is writable
+
+ # The expression used as the condition of the `assert`
var n_expr: AExpr is writable, noinit
+
+ # The body to execute when the assert fails
var n_else: nullable AExpr = null is writable
end
# Whatever is a simple assignment. eg `= something`
abstract class AAssignFormExpr
super AExpr
+
+ # The `=` symbol
var n_assign: TAssign is writable, noinit
+
+ # The right-value to assign.
var n_value: AExpr is writable, noinit
end
# Whatever is a combined assignment. eg `+= something`
abstract class AReassignFormExpr
super AExpr
+
+ # The combined operator (eg. `+=`)
var n_assign_op: AAssignOp is writable, noinit
+
+ # The right-value to apply on the combined operator.
var n_value: AExpr is writable, noinit
end
# A `once` expression. eg `once x`
class AOnceExpr
super AExpr
+
+ # The `once` keyword
var n_kwonce: TKwonce is writable, noinit
+
+ # The expression to evaluate only one time
var n_expr: AExpr is writable, noinit
end
super AExpr
end
-# A `or` expression
-class AOrExpr
+# Something that is binary boolean expression
+abstract class ABinBoolExpr
super ABoolExpr
+
+ # The first boolean operand
var n_expr: AExpr is writable, noinit
+
+ # The second boolean operand
var n_expr2: AExpr is writable, noinit
end
+# A `or` expression
+class AOrExpr
+ super ABinBoolExpr
+end
+
# A `and` expression
class AAndExpr
- super ABoolExpr
- var n_expr: AExpr is writable, noinit
- var n_expr2: AExpr is writable, noinit
+ super ABinBoolExpr
end
# A `or else` expression
class AOrElseExpr
- super ABoolExpr
- var n_expr: AExpr is writable, noinit
- var n_expr2: AExpr is writable, noinit
+ super ABinBoolExpr
end
# A `implies` expression
class AImpliesExpr
- super ABoolExpr
- var n_expr: AExpr is writable, noinit
- var n_expr2: AExpr is writable, noinit
+ super ABinBoolExpr
end
# A `not` expression
class ANotExpr
super ABoolExpr
+
+ # The `not` keyword
var n_kwnot: TKwnot is writable, noinit
+
+ # The boolean operand of the `not`
var n_expr: AExpr is writable, noinit
end
# A type-ckeck expression. eg `x isa T`
class AIsaExpr
super ABoolExpr
+
+ # The expression to check
var n_expr: AExpr is writable, noinit
+
+ # The destination type to check to
var n_type: AType is writable, noinit
end
# A unary minus expression. eg `-x`
class AUminusExpr
super ASendExpr
+
+ # The `-` symbol
var n_minus: TMinus is writable, noinit
end
# An explicit instantiation. eg `new T`
class ANewExpr
super AExpr
+
+ # The `new` keyword
var n_kwnew: TKwnew is writable, noinit
+
+ # The `type` keyword
var n_type: AType is writable, noinit
# The name of the named-constructor, if any
var n_id: nullable TId = null is writable
+
+ # The arguments of the `new`
var n_args: AExprs is writable, noinit
end
# A call to `super`. OR a call of a super-constructor
class ASuperExpr
super AExpr
+
+ # The qualifier part before the super (currenlty unused)
var n_qualified: nullable AQualified = null is writable
+
+ # The `super` keyword
var n_kwsuper: TKwsuper is writable, noinit
+
+ # The arguments of the super
var n_args: AExprs is writable, noinit
end
# Note: because `init` is a keyword and not a `TId`, the explicit call to init cannot be a `ACallFormExpr`.
class AInitExpr
super ASendExpr
+
+ # The `init` keyword
var n_kwinit: TKwinit is writable, noinit
+
+ # The arguments of the init
var n_args: AExprs is writable, noinit
end
# Whatever looks-like a call of the brackets `[]` operator.
abstract class ABraFormExpr
super ASendExpr
+
+ # The arguments inside the brackets
var n_args: AExprs is writable, noinit
end
# Whatever is an access to a local variable
abstract class AVarFormExpr
super AExpr
+
+ # The name of the attribute
var n_id: TId is writable, noinit
end
# A literal range, open or closed
abstract class ARangeExpr
super AExpr
+
+ # The left (lower) element of the range
var n_expr: AExpr is writable, noinit
+
+ # The right (uppr) element of the range
var n_expr2: AExpr is writable, noinit
end
# A closed literal range. eg `[x..y]`
class ACrangeExpr
super ARangeExpr
+
+ # The opening bracket `[`
var n_obra: TObra is writable, noinit
+
+ # The closing bracket `]`
var n_cbra: TCbra is writable, noinit
end
# An open literal range. eg `[x..y[`
class AOrangeExpr
super ARangeExpr
+
+ # The opening bracket `[`
var n_obra: TObra is writable, noinit
+
+ # The closing bracket `[` (because open range)
var n_cbra: TObra is writable, noinit
end
# A literal array. eg. `[x,y,z]`
class AArrayExpr
super AExpr
+
+ # The opening bracket `[`
var n_obra: TObra is writable, noinit
+
+ # The elements of the array
var n_exprs = new ANodes[AExpr](self)
+
+ # The type of the element of the array (if any)
var n_type: nullable AType = null is writable
+
+ # The closing bracket `]`
var n_cbra: TCbra is writable, noinit
end
-# A read of `self`
+# A read of `self`
class ASelfExpr
super AExpr
+
+ # The `self` keyword
var n_kwself: nullable TKwself is writable
end
# A `true` boolean literal constant
class ATrueExpr
super ABoolExpr
+
+ # The `true` keyword
var n_kwtrue: TKwtrue is writable, noinit
end
+
# A `false` boolean literal constant
class AFalseExpr
super ABoolExpr
+
+ # The `false` keyword
var n_kwfalse: TKwfalse is writable, noinit
end
+
# A `null` literal constant
class ANullExpr
super AExpr
+
+ # The `null` keyword
var n_kwnull: TKwnull is writable, noinit
end
+
# An integer literal
class AIntExpr
super AExpr
end
+
# An integer literal in decimal format
class ADecIntExpr
super AIntExpr
+
+ # The decimal token
var n_number: TNumber is writable, noinit
end
+
# An integer literal in hexadecimal format
class AHexIntExpr
super AIntExpr
+
+ # The hexadecimal token
var n_hex_number: THexNumber is writable, noinit
end
+
# A float literal
class AFloatExpr
super AExpr
+
+ # The float token
var n_float: TFloat is writable, noinit
end
+
# A character literal
class ACharExpr
super AExpr
+
+ # The character token
var n_char: TChar is writable, noinit
end
+
# A string literal
abstract class AStringFormExpr
super AExpr
+
+ # The string token
var n_string: Token is writable, noinit
end
# Each part is modeled a sequence of expression. eg. `["a{, x, }b{, y, }c"]`
class ASuperstringExpr
super AExpr
+
+ # The list of the expressions of the superstring
var n_exprs = new ANodes[AExpr](self)
end
# A simple parenthesis. eg `(x)`
class AParExpr
super AExpr
+
+ # The opening parenthesis
var n_opar: TOpar is writable, noinit
+
+ # The inner expression
var n_expr: AExpr is writable, noinit
+
+ # The closing parenthesis
var n_cpar: TCpar is writable, noinit
end
-# A type cast. eg `x.as(T)`
-class AAsCastExpr
+# A cast, against a type or `not null`
+class AAsCastForm
super AExpr
+
+ # The expression to cast
var n_expr: AExpr is writable, noinit
+
+ # The `as` keyword
var n_kwas: TKwas is writable, noinit
+
+ # The opening parenthesis
var n_opar: nullable TOpar = null is writable
- var n_type: AType is writable, noinit
+
+ # The closing parenthesis
var n_cpar: nullable TCpar = null is writable
end
+# A type cast. eg `x.as(T)`
+class AAsCastExpr
+ super AAsCastForm
+
+ # The target type to cast to
+ var n_type: AType is writable, noinit
+end
+
# A as-not-null cast. eg `x.as(not null)`
class AAsNotnullExpr
- super AExpr
- var n_expr: AExpr is writable, noinit
- var n_kwas: TKwas is writable, noinit
- var n_opar: nullable TOpar = null is writable
+ super AAsCastForm
+
+ # The `not` keyword
var n_kwnot: TKwnot is writable, noinit
+
+ # The `null` keyword
var n_kwnull: TKwnull is writable, noinit
- var n_cpar: nullable TCpar = null is writable
end
# A is-set check of old-style attributes. eg `isset x._a`
class AIssetAttrExpr
super AAttrFormExpr
+
+ # The `isset` keyword
var n_kwisset: TKwisset is writable, noinit
end
# An ellipsis notation used to pass an expression as it, in a vararg parameter
class AVarargExpr
super AExpr
+
+ # The passed expression
var n_expr: AExpr is writable, noinit
+
+ # The `...` symbol
var n_dotdotdot: TDotdotdot is writable, noinit
end
# A list of expression separated with commas (arguments for instance)
class AManyExpr
super AExpr
+
+ # The list of expressions
var n_exprs = new ANodes[AExpr](self)
end
# Can only be found in special construction like arguments of annotations.
class ATypeExpr
super AExpr
+
+ # The encapsulated type
var n_type: AType is writable, noinit
end
# Can only be found in special construction like arguments of annotations.
class AMethidExpr
super AExpr
- # The receiver, is any
+
+ # The receiver
var n_expr: AExpr is writable, noinit
+
+ # The encapsulated method identifier
var n_id: AMethid is writable, noinit
end
# A special expression that encapsulate an annotation
# Can only be found in special construction like arguments of annotations.
+#
+# The encapsulated annotations are in `n_annotations`
class AAtExpr
super AExpr
end
# A special expression to debug types
class ADebugTypeExpr
super AExpr
+
+ # The `debug` keyword
var n_kwdebug: TKwdebug is writable, noinit
+
+ # The `type` keyword
var n_kwtype: TKwtype is writable, noinit
+
+ # The expression to check
var n_expr: AExpr is writable, noinit
+
+ # The type to check
var n_type: AType is writable, noinit
end
# A list of expression separated with commas (arguments for instance)
abstract class AExprs
super Prod
+
+ # The list of expressions
var n_exprs = new ANodes[AExpr](self)
end
# A list of expressions enclosed in parentheses
class AParExprs
super AExprs
+
+ # The opening parenthesis
var n_opar: TOpar is writable, noinit
+
+ # The closing parenthesis
var n_cpar: TCpar is writable, noinit
end
# A list of expressions enclosed in brackets
class ABraExprs
super AExprs
+
+ # The opening bracket
var n_obra: TObra is writable, noinit
+
+ # The closing bracket
var n_cbra: TCbra is writable, noinit
end
# The `+=` assignment operation
class APlusAssignOp
super AAssignOp
+
+ # The `+=` operator
var n_pluseq: TPluseq is writable, noinit
end
# The `-=` assignment operator
class AMinusAssignOp
super AAssignOp
+
+ # The `-=` operator
var n_minuseq: TMinuseq is writable, noinit
end
# A possibly fully-qualified module identifier
class AModuleName
super Prod
+
+ # The starting quad (`::`)
var n_quad: nullable TQuad = null is writable
+
+ # The list of quad-separated project/group identifiers
var n_path = new ANodes[TId](self)
+
+ # The final module identifier
var n_id: TId is writable, noinit
end
# A language declaration for an extern block
class AInLanguage
super Prod
+
+ # The `in` keyword
var n_kwin: TKwin is writable, noinit
+
+ # The language name
var n_string: TString is writable, noinit
end
# An full extern block
class AExternCodeBlock
super Prod
+
+ # The language declration
var n_in_language: nullable AInLanguage = null is writable
+
+ # The block of extern code
var n_extern_code_segment: TExternCodeSegment is writable, noinit
end
# A possible full method qualifier.
class AQualified
super Prod
+
+ # The starting quad (`::`)
var n_quad: nullable TQuad = null is writable
+
+ # The list of quad-separated project/group/module identifiers
var n_id = new ANodes[TId](self)
+
+ # A class identifier
var n_classid: nullable TClassid = null is writable
end
# It contains the block of comments just above the declaration
class ADoc
super Prod
+
+ # A list of lines of comment
var n_comment = new ANodes[TComment](self)
end
# A group of annotation on a node
+#
+# This same class is used for the 3 kind of annotations:
+#
+# * *is* annotations. eg `module foo is bar`.
+# * *at* annotations. eg `foo@bar` or `foo@(bar,baz)`.
+# * *class* annotations, defined in classes.
class AAnnotations
super Prod
+
+ # The `@` symbol, for *at* annotations
var n_at: nullable TAt = null is writable
+
+ # The opening parenthesis in *at* annotations
var n_opar: nullable TOpar = null is writable
+
+ # The list of annotations
var n_items = new ANodes[AAnnotation](self)
+
+ # The closing parenthesis in *at* annotations
var n_cpar: nullable TCpar = null is writable
end
# A single annotation
class AAnnotation
- super Prod
- var n_doc: nullable ADoc = null is writable
- var n_kwredef: nullable TKwredef = null is writable
- var n_visibility: nullable AVisibility is writable
+ super ADefinition
+
+ # The name of the annotation
var n_atid: AAtid is writable, noinit
+
+ # The opening parenthesis of the arguments
var n_opar: nullable TOpar = null is writable
+
+ # The list of arguments
var n_args = new ANodes[AExpr](self)
+
+ # The closing parenthesis
var n_cpar: nullable TCpar = null is writable
+
+ # The name of the annotation
+ fun name: String
+ do
+ return n_atid.n_id.text
+ end
end
# An annotation name
abstract class AAtid
super Prod
+
+ # The identifier of the annotation.
+ # Can be a TId of a keyword
var n_id: Token is writable, noinit
end
# The root of the AST
class Start
super Prod
+
+ # The main module
var n_base: nullable AModule is writable
+
+ # The end of file (or error) token
var n_eof: EOF is writable
end
# Production AST nodes full definition.
# This file was generated by SableCC (http://www.sablecc.org/).
-module parser_prod
+module parser_prod is no_warning("missing-doc")
import lexer
intrude import parser_nodes
$ output 'parser_abs.nit'
# Raw AST node hierarchy.
# This file was generated by SableCC (http://www.sablecc.org/).
-module parser_abs
+module parser_abs is no_warning("missing-doc")
import location
$ output 'lexer.nit'
# Lexer and its tokens.
# This file was generated by SableCC (http://www.sablecc.org/).
-module lexer
+module lexer is no_warning("missing-doc")
$ if $usermodule
intrude import $usermodule
$ output 'parser_prod.nit'
# Production AST nodes full definition.
# This file was generated by SableCC (http://www.sablecc.org/).
-module parser_prod
+module parser_prod is no_warning("missing-doc")
import lexer
$ if $usermodule
$ output 'parser.nit'
# Parser.
# This file was generated by SableCC (http://www.sablecc.org/).
-module parser
+module parser is no_warning("missing-doc", "unread-variable")
intrude import parser_prod
intrude import parser_work
end
end
+# 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
return tok
end
end
-
-redef class ANode
- # Do a deep search and return an array of tokens that match a given text
- fun collect_tokens_by_text(text: String): Array[Token]
- do
- var v = new CollectTokensByTextVisitor(text)
- v.enter_visit(self)
- return v.result
- end
-
- # Do a deep search and return an array of node that are annotated
- # The attached node can be retrieved by two invocation of parent
- fun collect_annotations_by_name(name: String): Array[AAnnotation]
- do
- var v = new CollectAnnotationsByNameVisitor(name)
- v.enter_visit(self)
- return v.result
- end
-end
-
-private class CollectTokensByTextVisitor
- super Visitor
- var text: String
- var result = new Array[Token]
- redef fun visit(node)
- do
- node.visit_all(self)
- if node isa Token and node.text == text then result.add(node)
- end
-end
-
-private class CollectAnnotationsByNameVisitor
- super Visitor
- var name: String
- var result = new Array[AAnnotation]
- redef fun visit(node)
- do
- node.visit_all(self)
- if node isa AAnnotation and node.n_atid.n_id.text == name then result.add(node)
- end
-end
redef class ToolContext
# The various registered phases to performs
- # The order in the poset is the dependance of phases
+ # The order in the poset is the dependence of phases
#
# While you can directly modify the poset (nodes and edges),
# it is often simpler to use the constructor in `Phase`
end
end
+ # The list of registered phases in the application order.
fun phases_list: Sequence[Phase]
do
var phases = self.phases.to_a
errors_info
end
- fun phase_process_npropdef(phase: Phase, npropdef: APropdef)
+ # Process the given `phase` on the `npropdef`
+ # Called by `run_phases`
+ protected fun phase_process_npropdef(phase: Phase, npropdef: APropdef)
do
phase.process_npropdef(npropdef)
end
# See the License for the specific language governing permissions and
# limitations under the License.
-# Computing of super-constructors that must be implicitely called at the begin of constructors.
+# Computing of super-constructors that must be implicitly called at the begin of constructors.
# The current rules are a bit crazy but whatever.
module auto_super_init
private import annotation
redef class ToolContext
+ # Phase that inject `super` in constructors that need it.
var auto_super_init_phase: Phase = new AutoSuperInitPhase(self, [typing_phase])
end
import scope
redef class ToolContext
+ # Run `APropdef::do_flow` on each propdef
var flow_phase: Phase = new FlowPhase(self, [scope_phase])
end
import flow
redef class ToolContext
+ # Run `APropdef::do_local_var_init` on each propdef
var local_var_init_phase: Phase = new LocalVarInitPhase(self, [flow_phase])
end
import phase
redef class ToolContext
+ # Run `APropdef::do_scope` on each propdef.
var scope_phase: Phase = new ScopePhase(self, null)
end
var block: String
end
-class SearchAssertVisitor
- super Visitor
- var foundit = false
- redef fun visit(node)
- do
- if foundit then
- return
- else if node isa AAssertExpr then
- foundit = true
- return
- else
- node.visit_all(self)
- end
- end
-end
-
redef class ModelBuilder
+ # Total number analyzed `MEntity`
var total_entities = 0
+
+ # The number of `MEntity` that have some documentation
var doc_entities = 0
+
+ # The total number of executed docunits
var unit_entities = 0
+
+ # The number failed docunits
var failed_entities = 0
+ # Extracts and executes all the docunits in the `mmodule`
+ # Returns a JUnit-compatible `<testsuite>` XML element that contains the results of the executions.
fun test_markdown(mmodule: MModule): HTMLTag
do
var ts = new HTMLTag("testsuite")
import location
import version
import template
+import more_collections
# A warning or an error
class Message
# Set this value to `true` if you need to keep the program going in case of error.
var keep_going = false is writable
+ # List of tags per source-file whose warnings are not displayed.
+ #
+ # Initially empty, it is up to the toll to fill it.
+ # The tag "all" means all warnings and advices.
+ var warning_blacklist = new MultiHashMap[SourceFile, String]
+
+ # Is the source-file of `l` associated with `tag` in `warning_blacklist`?
+ #
+ # currently returns `false` if `l` is null or does not have a source-file.
+ fun is_warning_blacklisted(l: nullable Location, tag: String): Bool
+ do
+ if l == null then return false
+ var f = l.file
+ if f == null then return false
+ var tags = warning_blacklist.get_or_null(f)
+ if tags == null then return false
+ return tags.has("all") or tags.has(tag)
+ end
+
# Output all current stacked messages and display total error informations
#
# Return true if no errors occurred.
do
if opt_warning.value.has("no-{tag}") then return
if not opt_warning.value.has(tag) and opt_warn.value == 0 then return
+ if is_warning_blacklisted(l, tag) then return
messages.add(new Message(l, tag, text))
warning_count = warning_count + 1
if opt_stop_on_first_error.value then check_errors
do
if opt_warning.value.has("no-{tag}") then return
if not opt_warning.value.has(tag) and opt_warn.value <= 1 then return
+ if is_warning_blacklisted(l, tag) then return
messages.add(new Message(l, tag, text))
warning_count = warning_count + 1
if opt_stop_on_first_error.value then check_errors
import perfect_hashing
redef class ModelBuilder
- redef fun run_naive_interpreter(mainmodule: MModule, arguments: Array[String])
+ fun run_virtual_machine(mainmodule: MModule, arguments: Array[String])
do
var time0 = get_time
self.toolcontext.info("*** NITVM STARTING ***", 1)
--src-lang java -- root-namespace ../contrib/neo_doxygen/tests/root-namespace/xml
--src-lang java -- inner-class ../contrib/neo_doxygen/tests/inner-class/xml
-- python-def ../contrib/neo_doxygen/tests/python-def/xml
+--src-lang python -- python-def ../contrib/neo_doxygen/tests/python-def/xml
bench_
nit_args1
nit_args3
+nit_args4
nitvm_args1
nitvm_args3
nitc_args1
nitc_args5
nitc_args6
nitc_args8
-test_markdown_args1
+nitunit_args
+test_docdown_args
pep8analysis
-test_android_platform
-android
-nitcc_parser_gen
-mnit
emscripten
+nitserial_args
+nitunit_args
+nitpretty_args
+hamming_number
+hailstone
+test_map
+nitls
+nituml
-h, --help Show the help (this page).
- --src-lang The programming language to assume when processing chunk in the
+ --src-lang The programming language to assume when processing chunks in the
declarations left as-is by Doxygen. Use `any` (the default) to
- disable any language-specific processing. <any, java>
+ disable any language-specific processing. <any, java, python>
--- /dev/null
+Reading ../contrib/neo_doxygen/tests/python-def/xml... Done.
+3 files read.
+Linking nodes...\e[s \e[u\e[J Done.
+Saving 10 nodes...
+---===DONE===---
+Saving 17 edges...
+Edge
+=type=4:ROOT
+=properties=JsonObject(0):
+{}
+----
+=from=Node
+=labels=Array(3):
+10:python-def
+7:MEntity
+8:MProject
+=properties=JsonObject(1):
+{"name":"python-def"}
+----
+=to=Entity#0:
+=labels=Array(3):
+10:python-def
+7:MEntity
+6:MGroup
+=properties=JsonObject(1):
+{"name":"python-def"}
+
+
+Edge
+=type=7:PROJECT
+=properties=JsonObject(0):
+{}
+----
+=from=Entity#0:
+=labels=Array(3):
+10:python-def
+7:MEntity
+6:MGroup
+=properties=JsonObject(1):
+{"name":"python-def"}
+----
+=to=Node
+=labels=Array(3):
+10:python-def
+7:MEntity
+8:MProject
+=properties=JsonObject(1):
+{"name":"python-def"}
+
+
+Edge
+=type=6:PARENT
+=properties=JsonObject(0):
+{}
+----
+=from=Entity#12:namespacefoo
+=labels=Array(3):
+10:python-def
+7:MEntity
+6:MGroup
+=properties=JsonObject(4):
+{"kind":"namespace","visibility":"","name":"foo","location":"%SOURCE_DIRECTORY%\/foo.py:1,1--1,1"}
+----
+=to=Entity#0:
+=labels=Array(3):
+10:python-def
+7:MEntity
+6:MGroup
+=properties=JsonObject(1):
+{"name":"python-def"}
+
+
+Edge
+=type=5:NESTS
+=properties=JsonObject(0):
+{}
+----
+=from=Entity#0:
+=labels=Array(3):
+10:python-def
+7:MEntity
+6:MGroup
+=properties=JsonObject(1):
+{"name":"python-def"}
+----
+=to=Entity#12:namespacefoo
+=labels=Array(3):
+10:python-def
+7:MEntity
+6:MGroup
+=properties=JsonObject(4):
+{"kind":"namespace","visibility":"","name":"foo","location":"%SOURCE_DIRECTORY%\/foo.py:1,1--1,1"}
+
+
+Edge
+=type=8:DECLARES
+=properties=JsonObject(0):
+{}
+----
+=from=Entity#12:namespacefoo
+=labels=Array(3):
+10:python-def
+7:MEntity
+6:MGroup
+=properties=JsonObject(4):
+{"kind":"namespace","visibility":"","name":"foo","location":"%SOURCE_DIRECTORY%\/foo.py:1,1--1,1"}
+----
+=to=Entity#0:
+=labels=Array(3):
+10:python-def
+7:MEntity
+7:MModule
+=properties=JsonObject(2):
+{"location":"%SOURCE_DIRECTORY%\/foo.py:1,1--1,1","name":"foo"}
+
+
+Edge
+=type=10:INTRODUCES
+=properties=JsonObject(0):
+{}
+----
+=from=Entity#0:
+=labels=Array(3):
+10:python-def
+7:MEntity
+7:MModule
+=properties=JsonObject(2):
+{"location":"%SOURCE_DIRECTORY%\/foo.py:1,1--1,1","name":"foo"}
+----
+=to=Entity#0:
+=labels=Array(3):
+10:python-def
+7:MEntity
+6:MClass
+=properties=JsonObject(4):
+{"kind":"class","visibility":"public","name":"(self)","location":"%SOURCE_DIRECTORY%\/foo.py:1,1--1,1"}
+
+
+Edge
+=type=7:DEFINES
+=properties=JsonObject(0):
+{}
+----
+=from=Entity#0:
+=labels=Array(3):
+10:python-def
+7:MEntity
+7:MModule
+=properties=JsonObject(2):
+{"location":"%SOURCE_DIRECTORY%\/foo.py:1,1--1,1","name":"foo"}
+----
+=to=Entity#0:
+=labels=Array(3):
+10:python-def
+7:MEntity
+9:MClassDef
+=properties=JsonObject(3):
+{"location":"%SOURCE_DIRECTORY%\/foo.py:1,1--1,1","is_intro":true,"name":"(self)"}
+
+
+Edge
+=type=7:DEFINES
+=properties=JsonObject(0):
+{}
+----
+=from=Entity#47:namespacefoo_1aab1e88a2212b202c20f3c9bd799a1ad4
+=labels=Array(4):
+10:python-def
+7:MEntity
+8:MPropDef
+10:MMethodDef
+=properties=JsonObject(8):
+{"location":"%SOURCE_DIRECTORY%\/foo.py:16,1--20,1","is_intern":false,"is_extern":false,"is_abstract":false,"visibility":"public","name":"bar","mdoc":["A bar function in the foo namespace.","By default, Doxygen recognizes anything in the docstrings as verbatim\ndetailed description."],"is_intro":true}
+----
+=to=Entity#0:
+=labels=Array(4):
+10:python-def
+7:MEntity
+9:MProperty
+7:MMethod
+=properties=JsonObject(3):
+{"visibility":"public","is_init":false,"name":"bar"}
+
+
+Edge
+=type=9:SIGNATURE
+=properties=JsonObject(0):
+{}
+----
+=from=Entity#47:namespacefoo_1aab1e88a2212b202c20f3c9bd799a1ad4
+=labels=Array(4):
+10:python-def
+7:MEntity
+8:MPropDef
+10:MMethodDef
+=properties=JsonObject(8):
+{"location":"%SOURCE_DIRECTORY%\/foo.py:16,1--20,1","is_intern":false,"is_extern":false,"is_abstract":false,"visibility":"public","name":"bar","mdoc":["A bar function in the foo namespace.","By default, Doxygen recognizes anything in the docstrings as verbatim\ndetailed description."],"is_intro":true}
+----
+=to=Entity#0:
+=labels=Array(4):
+10:python-def
+7:MEntity
+5:MType
+10:MSignature
+=properties=JsonObject(0):
+{}
+
+
+Edge
+=type=7:PROJECT
+=properties=JsonObject(0):
+{}
+----
+=from=Entity#12:namespacefoo
+=labels=Array(3):
+10:python-def
+7:MEntity
+6:MGroup
+=properties=JsonObject(4):
+{"kind":"namespace","visibility":"","name":"foo","location":"%SOURCE_DIRECTORY%\/foo.py:1,1--1,1"}
+----
+=to=Node
+=labels=Array(3):
+10:python-def
+7:MEntity
+8:MProject
+=properties=JsonObject(1):
+{"name":"python-def"}
+
+
+Edge
+=type=9:CLASSTYPE
+=properties=JsonObject(0):
+{}
+----
+=from=Entity#0:
+=labels=Array(3):
+10:python-def
+7:MEntity
+6:MClass
+=properties=JsonObject(4):
+{"kind":"class","visibility":"public","name":"(self)","location":"%SOURCE_DIRECTORY%\/foo.py:1,1--1,1"}
+----
+=to=Entity#0:
+=labels=Array(4):
+10:python-def
+7:MEntity
+5:MType
+10:MClassType
+=properties=JsonObject(1):
+{"name":"(self)"}
+
+
+Edge
+=type=5:CLASS
+=properties=JsonObject(0):
+{}
+----
+=from=Entity#0:
+=labels=Array(4):
+10:python-def
+7:MEntity
+5:MType
+10:MClassType
+=properties=JsonObject(1):
+{"name":"(self)"}
+----
+=to=Entity#0:
+=labels=Array(3):
+10:python-def
+7:MEntity
+6:MClass
+=properties=JsonObject(4):
+{"kind":"class","visibility":"public","name":"(self)","location":"%SOURCE_DIRECTORY%\/foo.py:1,1--1,1"}
+
+
+Edge
+=type=9:BOUNDTYPE
+=properties=JsonObject(0):
+{}
+----
+=from=Entity#0:
+=labels=Array(3):
+10:python-def
+7:MEntity
+9:MClassDef
+=properties=JsonObject(3):
+{"location":"%SOURCE_DIRECTORY%\/foo.py:1,1--1,1","is_intro":true,"name":"(self)"}
+----
+=to=Entity#0:
+=labels=Array(4):
+10:python-def
+7:MEntity
+5:MType
+10:MClassType
+=properties=JsonObject(1):
+{"name":"(self)"}
+
+
+Edge
+=type=6:MCLASS
+=properties=JsonObject(0):
+{}
+----
+=from=Entity#0:
+=labels=Array(3):
+10:python-def
+7:MEntity
+9:MClassDef
+=properties=JsonObject(3):
+{"location":"%SOURCE_DIRECTORY%\/foo.py:1,1--1,1","is_intro":true,"name":"(self)"}
+----
+=to=Entity#0:
+=labels=Array(3):
+10:python-def
+7:MEntity
+6:MClass
+=properties=JsonObject(4):
+{"kind":"class","visibility":"public","name":"(self)","location":"%SOURCE_DIRECTORY%\/foo.py:1,1--1,1"}
+
+
+Edge
+=type=10:INTRODUCES
+=properties=JsonObject(0):
+{}
+----
+=from=Entity#0:
+=labels=Array(3):
+10:python-def
+7:MEntity
+9:MClassDef
+=properties=JsonObject(3):
+{"location":"%SOURCE_DIRECTORY%\/foo.py:1,1--1,1","is_intro":true,"name":"(self)"}
+----
+=to=Entity#0:
+=labels=Array(4):
+10:python-def
+7:MEntity
+9:MProperty
+7:MMethod
+=properties=JsonObject(3):
+{"visibility":"public","is_init":false,"name":"bar"}
+
+
+Edge
+=type=14:INTRO_CLASSDEF
+=properties=JsonObject(0):
+{}
+----
+=from=Entity#0:
+=labels=Array(4):
+10:python-def
+7:MEntity
+9:MProperty
+7:MMethod
+=properties=JsonObject(3):
+{"visibility":"public","is_init":false,"name":"bar"}
+----
+=to=Entity#0:
+=labels=Array(3):
+10:python-def
+7:MEntity
+9:MClassDef
+=properties=JsonObject(3):
+{"location":"%SOURCE_DIRECTORY%\/foo.py:1,1--1,1","is_intro":true,"name":"(self)"}
+
+
+Edge
+=type=8:DECLARES
+=properties=JsonObject(0):
+{}
+----
+=from=Entity#0:
+=labels=Array(3):
+10:python-def
+7:MEntity
+9:MClassDef
+=properties=JsonObject(3):
+{"location":"%SOURCE_DIRECTORY%\/foo.py:1,1--1,1","is_intro":true,"name":"(self)"}
+----
+=to=Entity#47:namespacefoo_1aab1e88a2212b202c20f3c9bd799a1ad4
+=labels=Array(4):
+10:python-def
+7:MEntity
+8:MPropDef
+10:MMethodDef
+=properties=JsonObject(8):
+{"location":"%SOURCE_DIRECTORY%\/foo.py:16,1--20,1","is_intern":false,"is_extern":false,"is_abstract":false,"visibility":"public","name":"bar","mdoc":["A bar function in the foo namespace.","By default, Doxygen recognizes anything in the docstrings as verbatim\ndetailed description."],"is_intro":true}
+
+
+---===DONE===---
-for x in nitg-g nitg-s nitg-sg nitg-e niti; do
+#!/bin/bash
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Run some tests on each engine
+for x in nitg-g nitg-s nitg-sg nitg-e niti nitvm; do
echo "--engine $x"
./tests.sh --engine $x "$@"
done
;;
nitvm)
isinterpret=true
+ enginebinname=nit
+ OPT="--vm $OPT"
savdirs="sav/niti/"
;;
emscripten)