import parser
import toolcontext
+import phase
+
+import modelbuilder #FIXME useless
+
+redef class ToolContext
+ var literal_phase: Phase = new LiteralPhase(self, null)
+end
+
+private class LiteralPhase
+ super Phase
+
+ redef fun process_nmodule(nmodule) do nmodule.do_literal(toolcontext)
+end
redef class AModule
# Visit the module to compute the real value of the literal-related node of the AST.
var value: nullable String
redef fun accept_literal(v)
do
- var txt
- if self isa AStringExpr then
- txt = self.n_string.text
- else if self isa AStartStringExpr then
- txt = self.n_string.text
- else if self isa AMidStringExpr then
- txt = self.n_string.text
- else if self isa AEndStringExpr then
- txt = self.n_string.text
- else abort
- self.value = txt.substring(1, txt.length-2).unescape_nit
+ var txt = self.n_string.text
+ var skip = 1
+ if txt[0] == txt[1] and txt.length >= 6 then skip = 3
+ self.value = txt.substring(skip, txt.length-(2*skip)).unescape_nit
end
end