nitc :: regex_phase
nitc :: RegexPhase
nitc :: RegexVisitor
nitc :: regex_phase $ ACallExpr
A call with a standard method-name and any number of arguments. egx.m(y)
. OR just a simple id
nitc :: regex_phase $ ACallExpr
A call with a standard method-name and any number of arguments. egx.m(y)
. OR just a simple id
Serializable::inspect
to show more useful information
nitc :: modelbuilder
more_collections :: more_collections
Highly specific, but useful, collections-related classes.serialization :: serialization_core
Abstract services to serialize Nit objects to different formatsnitc :: toolcontext
Common command-line tool infrastructure than handle options and error messagescore :: union_find
union–find algorithm using an efficient disjoint-set data structurenitc :: api_metrics
nitc :: nitmetrics
A program that collects various metrics on nit programs and librariesnitc :: nitrestful
Tool generating boilerplate code linking RESTful actions to Nit methodsclone
method of the astbuilder tool
# Check for error in regular expressions from string literals
module regex_phase
private import parser_util
private import literal
import modelize
redef class ToolContext
# Phase checking for errors in regex
var regex_phase: Phase = new RegexPhase(self, [literal_phase])
end
private class RegexPhase
super Phase
redef fun process_nmodule(nmodule)
do
var visitor = new RegexVisitor(toolcontext)
nmodule.accept_regex_visitor visitor
end
end
private class RegexVisitor
super Visitor
var toolcontext: ToolContext
redef fun visit(n) do n.accept_regex_visitor(self)
end
redef class ANode
private fun accept_regex_visitor(v: RegexVisitor) do visit_all v
end
redef class ACallExpr
redef fun accept_regex_visitor(v)
do
var method = n_qid.n_id
var receiver = n_expr
# Check only string literals on which `to_re` is called
if method.text == "to_re" and receiver isa AStringFormExpr then
# Retrieve regex source
var re_src = receiver.value
# Check for errors by compiling it right now
var re = re_src.to_re
var error = re.compile
re.finalize
if error != null then
v.toolcontext.error(self.location, "Regex Error: " + error.to_s)
end
end
end
end
src/frontend/regex_phase.nit:15,1--73,3