From: Jean Privat Date: Tue, 15 Apr 2014 13:49:52 +0000 (-0400) Subject: parser: split `AIntExpr` and `ADecIntExpr` X-Git-Tag: v0.6.6~111^2~4 X-Git-Url: http://nitlanguage.org parser: split `AIntExpr` and `ADecIntExpr` next commit will introduce AHexIntExpr Signed-off-by: Jean Privat --- diff --git a/src/astbuilder.nit b/src/astbuilder.nit index 96948ea..fa1d188 100644 --- a/src/astbuilder.nit +++ b/src/astbuilder.nit @@ -32,7 +32,7 @@ class ASTBuilder # Make a new Int literal fun make_int(value: Int): AIntExpr do - return new AIntExpr.make(value, mmodule.get_primitive_class("Int").mclass_type) + return new ADecIntExpr.make(value, mmodule.get_primitive_class("Int").mclass_type) end # Make a new instatiation @@ -220,7 +220,7 @@ redef class AType end end -redef class AIntExpr +redef class ADecIntExpr private init make(value: Int, t: MType) do self.value = value diff --git a/src/literal.nit b/src/literal.nit index 9ea79f0..92f137b 100644 --- a/src/literal.nit +++ b/src/literal.nit @@ -65,6 +65,9 @@ end redef class AIntExpr # The value of the literal int once computed. var value: nullable Int +end + +redef class ADecIntExpr redef fun accept_literal(v) do self.value = self.n_number.text.to_i diff --git a/src/parser/parser_abs.nit b/src/parser/parser_abs.nit index 48e2e1d..2493164 100644 --- a/src/parser/parser_abs.nit +++ b/src/parser/parser_abs.nit @@ -999,7 +999,7 @@ class ANullExpr readable var _n_kwnull: TKwnull readable var _n_annotations: nullable AAnnotations = null end -class AIntExpr +class ADecIntExpr super AExpr readable var _n_number: TNumber readable var _n_annotations: nullable AAnnotations = null diff --git a/src/parser/parser_nodes.nit b/src/parser/parser_nodes.nit index 5a6fd23..c9db2fa 100644 --- a/src/parser/parser_nodes.nit +++ b/src/parser/parser_nodes.nit @@ -1542,6 +1542,10 @@ end # An integer literal class AIntExpr super AExpr +end +# An integer literal in decimal format +class ADecIntExpr + super AIntExpr readable writable var _n_number: TNumber end # A float literal