Merge: Use more intern methods and add intern factories for NativeString and NativeArray
[nit.git] / src / parser / nit.sablecc3xx
index fbe7925..98bbcc2 100644 (file)
@@ -27,6 +27,7 @@ all = [0 .. 0xFF];
 lowercase = ['a' .. 'z'];
 uppercase = ['A' .. 'Z'];
 digit = ['0' .. '9'];
+hexdigit = ['0'..'9'] | ['a'..'f'] | ['A'..'F'];
 letter = lowercase | uppercase | digit | '_';
 
 tab = 9;
@@ -114,6 +115,7 @@ kwwritable = 'writable';
 kwvar = 'var';
 kwintern = 'intern';
 kwextern = 'extern';
+kwpublic = 'public';
 kwprotected = 'protected';
 kwprivate = 'private';
 kwintrude = 'intrude';
@@ -182,6 +184,7 @@ id = lowercase letter*;
 attrid = '_' lowercase letter*;
 
 number = digit+;
+hex_number = ('0x' | '0X') hexdigit+;
 float = digit* '.' digit+;
 string = '"' str_body '"' | '"' '"' '"' long_str_body lsend1 | ''' ''' ''' long_sstr_body ''' ''' ''';
 start_string = '"' str_body '{' | '"' '"' '"' long_str_body lsend2;
@@ -205,18 +208,20 @@ Productions
 
 /* MODULES *******************************************************************/
 module
-       = moduledecl? [imports]:import* [extern_bodies]:extern_code_body* [classdefs]:classdef* implicit_top_class? implicit_main_class {-> New module(moduledecl, [imports.import], [extern_bodies.extern_code_block], [classdefs.classdef,implicit_top_class.classdef,implicit_main_class.classdef])};
+       = moduledecl? [imports]:import* [extern_bodies]:extern_code_body* [classdefs]:topdef* implicit_main_class {-> New module(moduledecl, [imports.import], [extern_bodies.extern_code_block], [classdefs.classdef,implicit_main_class.classdef])};
 
 moduledecl
        = [doc]:no kwmodule no module_name annotation_withend [n2]:n1 {-> New moduledecl(doc.doc, kwmodule, module_name, annotation_withend.annotations)};
 
 import
-       = {std} [doc]:no visibility kwimport no module_name annotation_withend [n2]:n1 {-> New import.std(visibility, kwimport, module_name, annotation_withend.annotations)}
-       | {no} [doc]:no visibility kwimport no kwend [n2]:n1 {-> New import.no(visibility, kwimport, kwend)}
+       = {std} [doc]:no redef visibility kwimport no module_name annotation_withend [n2]:n1 {-> New import.std(visibility, kwimport, module_name, annotation_withend.annotations)}
+       | {no} [doc]:no redef visibility kwimport no kwend [n2]:n1 {-> New import.no(visibility, kwimport, kwend)}
        ;
 
-implicit_top_class {-> classdef}
-       = propdefs_toplevel+ {-> New classdef.top([propdefs_toplevel.propdef])};
+topdef {-> classdef}
+       = {classdef} classdef {-> classdef}
+       | propdefs_toplevel {-> New classdef.top([propdefs_toplevel.propdef])}
+       ;
 
 implicit_main_class {-> classdef?}
        = implicit_main_meth {-> New classdef.main([implicit_main_meth.propdef])}
@@ -229,7 +234,7 @@ implicit_main_meth {-> propdef}
 
 /* CLASSES *******************************************************************/
 classdef
-       = [doc]:no redef visibility classkind no qualified? classid formaldefs line_annotations_forclass? extern_code_block? [superclasses]:superclass* propdefs* [n2]:no kwend {-> New classdef.std(doc.doc, redef.kwredef, visibility, classkind, classid, [formaldefs.formaldef], line_annotations_forclass.annotations, extern_code_block, [superclasses.superclass], [propdefs.propdef], kwend)};
+       = [doc]:no redef visibility classkind no qclassid formaldefs line_annotations_forclass? extern_code_block? [superclasses]:superclass* propdefs* [n2]:no kwend {-> New classdef.std(doc.doc, redef.kwredef, visibility, classkind, qclassid.classid, [formaldefs.formaldef], line_annotations_forclass.annotations, extern_code_block, [superclasses.superclass], [propdefs.propdef], kwend)};
 redef {-> kwredef?}
        = kwredef? {-> kwredef};
 classkind
@@ -237,7 +242,7 @@ classkind
        | {abstract} kwabstract kwclass
        | {interface} kwinterface
        | {enum} kwenum
-       | {extern} kwextern kwclass?
+       | {extern} kwextern kwclass
        ;
 
 formaldefs {-> formaldef*}
@@ -247,7 +252,7 @@ formaldefs {-> formaldef*}
 formaldefs_tail {-> formaldef}
        = comma no formaldef {-> formaldef};
 formaldef
-       = classid annotations? typing? {-> New formaldef(classid, typing.type, annotations)};
+       = classid annotations? typing_o {-> New formaldef(classid, typing_o.type, annotations)};
 
 superclass {-> superclass}
        = {super} no kwsuper [n2]:no type annotation_withend {-> New superclass(kwsuper, type, annotation_withend.annotations)}
@@ -258,16 +263,16 @@ propdefs~toplevel {-> propdef}
        ;
 propdef~toplevel {-> propdef}
        = {meth} [doc]:no redef visibility kwmeth methid signature annotation_noend? kwdo stmtso kwend_o {-> New propdef.concrete_meth(doc.doc, redef.kwredef, visibility, kwmeth, methid, signature, annotation_noend.annotations, stmtso.expr)}
-       | {assign_return} [doc]:no redef visibility kwmeth methid signature_withret assign no assign_return {-> New propdef.concrete_meth(doc.doc, redef.kwredef, visibility, kwmeth, methid, signature_withret.signature, Null, assign_return.expr)}
        | {nobody} [doc]:no redef visibility kwmeth methid signature annotation_withend_nonull {-> New propdef.deferred_meth(doc.doc, redef.kwredef, visibility, kwmeth, methid, signature.signature, annotation_withend_nonull.annotations)}
 !toplevel| {deferred} [doc]:no redef visibility kwmeth methid signature kwis kwabstract {-> New propdef.deferred_meth(doc.doc, redef.kwredef, visibility, kwmeth, methid, signature.signature, Null)}
-!toplevel| {intern} [doc]:no redef visibility kwmeth methid signature kwis kwintern {-> New propdef.intern_meth(doc.doc, redef.kwredef, visibility, kwmeth, methid, signature.signature)}
+       | {intern} [doc]:no redef visibility kwmeth methid signature kwis kwintern {-> New propdef.intern_meth(doc.doc, redef.kwredef, visibility, kwmeth, methid, signature.signature)}
+!toplevel| {intern_new} [doc]:no redef visibility kwnew methid? signature kwis kwintern {-> New propdef.intern_new(doc.doc, redef.kwredef, visibility, kwnew, methid, signature)}
        | {extern} [doc]:no redef visibility kwmeth methid signature kwis kwextern string_o extern_calls extern_code_block_o {-> New propdef.extern_meth(doc.doc, redef.kwredef, visibility, kwmeth, methid, signature.signature, string_o.string, extern_calls, extern_code_block_o.extern_code_block)}
        | {extern_implicit} [doc]:no redef visibility kwmeth methid signature extern_calls extern_code_block {-> New propdef.extern_meth(doc.doc, redef.kwredef, visibility, kwmeth, methid, signature.signature, Null, extern_calls, extern_code_block)}
-!toplevel| {var} [doc]:no readable? writable? redef visibility kwvar attrid typing? {-> New propdef.attr(doc.doc, readable.able, writable.able, redef.kwredef, visibility, kwvar, attrid, Null, typing.type, Null, Null)}
-!toplevel| {var2} [doc]:no readable? writable? redef visibility kwvar attrid typing? assign [n2]:no expr {-> New propdef.attr(doc.doc, readable.able, writable.able, redef.kwredef, visibility, kwvar, attrid, Null, typing.type, Null, expr)}
-!toplevel| {var3} [doc]:no redef visibility kwvar id typing? writable2? annotation_withend {-> New propdef.attr(doc.doc, Null, writable2.able, redef.kwredef, visibility, kwvar, Null, id, typing.type, annotation_withend.annotations, Null)}
-!toplevel| {var4} [doc]:no redef visibility kwvar id typing? writable2? assign [n2]:no expr annotation_withend {-> New propdef.attr(doc.doc, Null, writable2.able, redef.kwredef, visibility, kwvar, Null, id, typing.type, annotation_withend.annotations, expr.expr)}
+!toplevel| {var} [doc]:no readable? writable? redef visibility kwvar attrid typing_o {-> New propdef.attr(doc.doc, readable.able, writable.able, redef.kwredef, visibility, kwvar, attrid, Null, typing_o.type, Null, Null)}
+!toplevel| {var2} [doc]:no readable? writable? redef visibility kwvar attrid typing_o assign [n2]:no expr {-> New propdef.attr(doc.doc, readable.able, writable.able, redef.kwredef, visibility, kwvar, attrid, Null, typing_o.type, Null, expr)}
+!toplevel| {var3} [doc]:no redef visibility kwvar id typing_o writable? annotation_withend {-> New propdef.attr(doc.doc, Null, writable.able, redef.kwredef, visibility, kwvar, Null, id, typing_o.type, annotation_withend.annotations, Null)}
+!toplevel| {var4} [doc]:no redef visibility kwvar id typing_o writable? assign [n2]:no expr annotation_withend {-> New propdef.attr(doc.doc, Null, writable.able, redef.kwredef, visibility, kwvar, Null, id, typing_o.type, annotation_withend.annotations, expr.expr)}
 !toplevel| {init} [doc]:no redef visibility kwinit methid? signature annotation_noend? kwdo stmtso kwend_o {-> New propdef.concrete_init(doc.doc, redef.kwredef, visibility, kwinit, methid, signature, annotation_noend.annotations, stmtso.expr)}
 !toplevel| {type} [doc]:no redef visibility kwtype classid typing annotation_withend {-> New propdef.type(doc.doc, redef.kwredef, visibility, kwtype, classid, typing.type, annotation_withend.annotations)}
 !toplevel| {extern_init} [doc]:no redef visibility kwnew methid? signature kwis kwextern string_o extern_calls extern_code_block_o {-> New propdef.extern_init(doc.doc, redef.kwredef, visibility, kwnew, methid, signature, string_o.string, extern_calls, extern_code_block_o.extern_code_block)}
@@ -283,12 +288,9 @@ annotation_noend {-> annotations}
        | {more} kwis n1 line_annotations {-> line_annotations.annotations}
        ;
 readable {-> able}
-       = redef kwreadable {-> New able.read(redef.kwredef, kwreadable)}
+       = redef visibility kwreadable {-> New able.read(redef.kwredef, kwreadable)}
        ;
 writable {-> able}
-       = redef kwwritable {-> New able.write(redef.kwredef, Null, kwwritable)}
-       ;
-writable2 {-> able}
        = redef visibility kwwritable {-> New able.write(redef.kwredef, visibility, kwwritable)}
        ;
 
@@ -320,11 +322,11 @@ methid {-> methid}
        | {braassign} obra cbra assign {-> New methid.braassign(obra, cbra, assign)}
        ;
 
-signature~withret {-> signature}
+signature {-> signature}
        = opar no params cpar typing [no2]:no {-> New signature(opar, [params.param], cpar, typing.type)}
-!withret| {noret} opar no params cpar [no2]:no {-> New signature(opar, [params.param], cpar, Null)}
+       | {noret} opar no params cpar [no2]:no {-> New signature(opar, [params.param], cpar, Null)}
        | {nopar} typing no {-> New signature(Null, [], Null, typing.type)}
-!withret| {noparnoret} no {-> New signature(Null, [], Null, Null)}
+       | {noparnoret} no {-> New signature(Null, [], Null, Null)}
        ;
 
 params {-> param*} 
@@ -338,10 +340,6 @@ param
        | id annotations? typing dotdotdot? {-> New param(id, typing.type, dotdotdot, annotations)}
        ;
 
-assign_return{-> expr}
-       = expr_final {-> New expr.return(Null, expr_final.expr)}
-       ;
-
 extern_calls {-> extern_calls?}
        = kwimport no extern_call extern_call_tail* {-> New extern_calls( kwimport, [extern_call, extern_call_tail.extern_call] )}
        | {null} {-> Null}
@@ -349,25 +347,27 @@ extern_calls {-> extern_calls?}
 extern_call_tail {-> extern_call}
        = comma no extern_call {-> extern_call};
 extern_call {-> extern_call}
-    = {prop} extern_call_prop {-> extern_call_prop.extern_call}
-    | {cast} extern_call_cast {-> extern_call_cast.extern_call}
+       = {prop} extern_call_prop {-> extern_call_prop.extern_call}
+       | {cast} extern_call_cast {-> extern_call_cast.extern_call}
        | {super} kwsuper {-> New extern_call.super( kwsuper )}
-    ;
+       ;
 extern_call_prop {-> extern_call}
-    = {local} methid {-> New extern_call.local_prop( methid )}
-       | {full} type quad methid {-> New extern_call.full_prop( type, Null, methid )}
-       | {full2} type dot methid {-> New extern_call.full_prop( type, dot, methid )}
+       = {local} methid {-> New extern_call.local_prop( methid )}
+       | {full} type dot methid {-> New extern_call.full_prop( type, dot, methid )}
        | {init} type {-> New extern_call.init_prop( type )}
        ;
 extern_call_cast {-> extern_call}
-    = {as_cast} [from_type]:type dot? kwas [n2]:no opar [n3]:no [to_type]:type [n4]:no cpar {-> New extern_call.cast_as(from_type, dot, kwas, to_type)}
-       | {as_nullable} type dot? kwas [n2]:no kwnullable {-> New extern_call.as_nullable( type, kwas, kwnullable)}
-       | {as_not_nullable} type dot? kwas [n2]:no kwnot [n3]:no kwnullable {-> New extern_call.as_not_nullable( type, kwas, kwnot, kwnullable)}
+       = {as_cast} [from_type]:type dot kwas [n2]:no opar [n3]:no [to_type]:type [n4]:no cpar {-> New extern_call.cast_as(from_type, dot, kwas, to_type)}
+       | {as_cast2}[from_type]:type dot kwas [n2]:no [to_type]:type {-> New extern_call.cast_as(from_type, dot, kwas, to_type)}
+       | {as_nullable} type dot kwas [n2]:no opar [n3]:no kwnullable [n4]:no cpar {-> New extern_call.as_nullable( type, kwas, kwnullable)}
+       | {as_nullable2}type dot kwas [n2]:no kwnullable {-> New extern_call.as_nullable( type, kwas, kwnullable)}
+       | {as_not_nullable} type dot kwas [n2]:no opar [n3]:no kwnot [n4]:no kwnullable [n5]:no cpar {-> New extern_call.as_not_nullable( type, kwas, kwnot, kwnullable)}
+       | {as_not_nullable2}type dot kwas [n2]:no kwnot [n3]:no kwnullable {-> New extern_call.as_not_nullable( type, kwas, kwnot, kwnullable)}
        ;
 
 string_o {->string?} = string? {-> string};
 
-in_language = kwin string;
+in_language = kwin no string [n1]:no {-> New in_language(kwin, string)};
 extern_code_block = in_language? extern_code_segment;
 extern_code_block_o {-> extern_code_block?}
        = extern_code_block {-> extern_code_block}
@@ -386,6 +386,10 @@ types_tail {-> type}
        = comma no type {-> type};
 typing {-> type}
        = column no type {-> type};
+typing_o {-> type?}
+       = column no type {-> type}
+       | {null} {-> Null}
+       ;
 
 /* STATMENTS *****************************************************************/
 stmtso~withelse~withend {-> expr?}
@@ -415,8 +419,8 @@ stmt~withelse~noexpr~nopar {-> expr}
        | {loop} loop~withelse {-> loop~withelse.expr}
        | {for} for~withelse {-> for~withelse.expr}
        | {assert} assert~withelse {-> assert~withelse.expr}
-!noexpr        | {call} recv qualified? id args_nopar {-> New expr.call(recv.expr, id, args_nopar.exprs)}
-!noexpr        | {super} qualified? kwsuper args_nopar {-> New expr.super(qualified, kwsuper, args_nopar.exprs)}
+!noexpr        | {call} recv qid args_nopar {-> New expr.call(recv.expr, qid.id, args_nopar.exprs)}
+!noexpr        | {super} qualified_o kwsuper args_nopar {-> New expr.super(qualified_o.qualified, kwsuper, args_nopar.exprs)}
 !noexpr        | {init} recv qualified? kwinit args_nopar {-> New expr.init(recv.expr, kwinit, args_nopar.exprs)}
        | {debug_type_is} kwdebug kwtype type column expr_final~withelse {-> New expr.debug_type(kwdebug, kwtype, expr_final~withelse.expr, type) }
        ;
@@ -428,16 +432,16 @@ assign_continue~withelse{-> expr}
        ;
 
 vardecl~withelse{-> expr}
-       = kwvar id annotations? typing? {-> New expr.vardecl(kwvar, id, typing.type, Null, Null, annotations)}
-       | {assign} kwvar id annotations? typing? assign no expr_final~withelse {-> New expr.vardecl(kwvar, id, typing.type, assign, expr_final~withelse.expr, annotations)}
+       = kwvar id annotations? typing_o {-> New expr.vardecl(kwvar, id, typing_o.type, Null, Null, annotations)}
+       | {assign} kwvar id annotations? typing_o assign no expr_final~withelse {-> New expr.vardecl(kwvar, id, typing_o.type, assign, expr_final~withelse.expr, annotations)}
        ;
 
 assignment~withelse~nopar {-> expr}
-       = {attr} recv~nopar qualified? attrid assign expr_final~withelse {-> New expr.attr_assign(recv~nopar.expr, attrid, assign, expr_final~withelse.expr)}
-       | {call} recv~nopar qualified? id args assign expr_final~withelse {-> New expr.call_assign(recv~nopar.expr, id, args.exprs, assign,  expr_final~withelse.expr)}
+       = {attr} recv~nopar qualified_o attrid assign expr_final~withelse {-> New expr.attr_assign(recv~nopar.expr, attrid, assign, expr_final~withelse.expr)}
+       | {call} recv~nopar qid args assign expr_final~withelse {-> New expr.call_assign(recv~nopar.expr, qid.id, args.exprs, assign,  expr_final~withelse.expr)}
        | {bra} expr_atom~nopar braargs assign expr_final~withelse {-> New expr.bra_assign(expr_atom~nopar.expr, braargs.exprs, assign,  expr_final~withelse.expr)}
-       | {attr_re} recv~nopar qualified? attrid assign_op expr_final~withelse {-> New expr.attr_reassign(recv~nopar.expr, attrid, assign_op,  expr_final~withelse.expr)}
-       | {call_re} recv~nopar qualified? id args assign_op expr_final~withelse {-> New expr.call_reassign(recv~nopar.expr, id, args.exprs, assign_op,  expr_final~withelse.expr)}
+       | {attr_re} recv~nopar qualified_o attrid assign_op expr_final~withelse {-> New expr.attr_reassign(recv~nopar.expr, attrid, assign_op,  expr_final~withelse.expr)}
+       | {call_re} recv~nopar qid args assign_op expr_final~withelse {-> New expr.call_reassign(recv~nopar.expr, qid.id, args.exprs, assign_op,  expr_final~withelse.expr)}
        | {bra_re} expr_atom~nopar braargs assign_op expr_final~withelse {-> New expr.bra_reassign(expr_atom~nopar.expr, braargs.exprs, assign_op,  expr_final~withelse.expr)}
        ;
 assign_op
@@ -542,16 +546,16 @@ expr_minus~nopar~nobra {-> expr}
 expr_new~nopar~nobra {-> expr}
        = expr_atom~nopar~nobra {-> expr_atom~nopar~nobra.expr}
        | {new} kwnew no type~nobra_nopar args {-> New expr.new(kwnew, type~nobra_nopar.type, Null, args.exprs)}
-       | {isset_attr} kwisset recv~nopar~nobra qualified? attrid {-> New expr.isset_attr(kwisset, recv~nopar~nobra.expr, attrid)}
+       | {isset_attr} kwisset recv~nopar~nobra qualified_o attrid {-> New expr.isset_attr(kwisset, recv~nopar~nobra.expr, attrid)}
        ;
 
 expr_atom~nopar~nobra {-> expr}
-       = {attr} recv~nopar~nobra qualified? attrid {-> New expr.attr(recv~nopar~nobra.expr, attrid)}
-       | {call} recv~nopar~nobra qualified? id args {-> New expr.call(recv~nopar~nobra.expr, id, args.exprs)}
-       | {super} qualified? kwsuper args {-> New expr.super(qualified, kwsuper, args.exprs)}
+       = {attr} recv~nopar~nobra qualified_o attrid {-> New expr.attr(recv~nopar~nobra.expr, attrid)}
+       | {call} recv~nopar~nobra qid args {-> New expr.call(recv~nopar~nobra.expr, qid.id, args.exprs)}
+       | {super} qualified_o kwsuper args {-> New expr.super(qualified_o.qualified, kwsuper, args.exprs)}
        | {init} recv~nopar~nobra kwinit args {-> New expr.init(recv~nopar~nobra.expr, kwinit, args.exprs)}
 !nobra | {bra} expr_atom~nopar braargs {-> New expr.bra(expr_atom~nopar.expr, braargs.exprs)}
-       | {new} kwnew no type~nobra_nopar dot [n2]:no qualified? id args {-> New expr.new(kwnew, type~nobra_nopar.type, id, args.exprs)}
+       | {new} kwnew no type~nobra_nopar dot [n2]:no qid args {-> New expr.new(kwnew, type~nobra_nopar.type, qid.id, args.exprs)}
 // !nopar to unambiguise 'foo[5].bar' between '(foo[5]).bar' and 'foo([5].bar),
 !nobra!nopar   | {range} obra no expr [n2]:no dotdot [n3]:no [expr2]:expr_nobra [n4]:no cbra annotations_o {-> New expr.crange(obra, expr, expr2.expr, cbra, annotations_o.annotations)}
 !nobra!nopar   | {orange} obra no expr [n2]:no dotdot [n3]:no [expr2]:expr_nobra [n4]:no [cbra]:obra annotations_o {-> New expr.orange(obra, expr, expr2.expr, cbra, annotations_o.annotations)}
@@ -560,7 +564,8 @@ expr_atom~nopar~nobra {-> expr}
        | {true} kwtrue annotations_o {-> New expr.true(kwtrue, annotations_o.annotations)}
        | {false} kwfalse annotations_o {-> New expr.false(kwfalse, annotations_o.annotations)}
        | {null} kwnull annotations_o {-> New expr.null(kwnull, annotations_o.annotations)}
-       | {int} number annotations_o {-> New expr.int(number, annotations_o.annotations)}
+       | {int} number annotations_o {-> New expr.dec_int(number, annotations_o.annotations)}
+       | {hex_int} hex_number annotations_o {-> New expr.hex_int(hex_number, annotations_o.annotations)}
        | {float} float annotations_o {-> New expr.float(float, annotations_o.annotations)}
        | {char} char annotations_o {-> New expr.char(char, annotations_o.annotations)}
        | {string} string annotations_o {-> New expr.string(string, annotations_o.annotations)}
@@ -568,6 +573,7 @@ expr_atom~nopar~nobra {-> expr}
 !nopar | {par} opar no expr [n2]:no cpar annotations_o {-> New expr.par(opar, expr, cpar, annotations_o.annotations)}
         | {as_cast} expr_atom~nopar~nobra dot no kwas [n2]:no opar [n3]:no type [n4]:no cpar {-> New expr.as_cast(expr_atom~nopar~nobra.expr, kwas, opar, type, cpar)}
         | {as_notnull} expr_atom~nopar~nobra dot no kwas [n2]:no opar [n3]:no kwnot [n4]:no kwnull [n5]:no cpar {-> New expr.as_notnull(expr_atom~nopar~nobra.expr, kwas, opar, kwnot, kwnull, cpar)}
+        | {as_notnull2}expr_atom~nopar~nobra dot no kwas [n2]:no kwnot [n4]:no kwnull {-> New expr.as_notnull(expr_atom~nopar~nobra.expr, kwas, Null, kwnot, kwnull, Null)}
        ;
 
 superstring {-> expr} 
@@ -642,8 +648,8 @@ at_arg~nopar {-> at_arg}
 
 atid~forclass {-> atid}
        = {id}  id {-> New atid.id(id)}
-//!forclass    | {kwextern} qualified? kwextern {-> New atid.kwextern(kwextern)}
-//!forclass    | {kwintern} qualified? kwintern {-> New atid.kwintern(kwintern)}
+//!forclass    | {kwextern} kwextern {-> New atid.kwextern(kwextern)}
+//!forclass    | {kwintern} kwintern {-> New atid.kwintern(kwintern)}
 !forclass      | {kwreadable} kwreadable {-> New atid.kwreadable(kwreadable)}
 !forclass      | {kwwritable} kwwritable {-> New atid.kwwritable(kwwritable)}
        | {kwimport} kwimport {-> New atid.kwimport(kwimport)}
@@ -691,6 +697,16 @@ qualified
        = {cla} modquad* classquad {-> New qualified([modquad.id], classquad.classid)}
        | {mod} modquad+ {-> New qualified([modquad.id], Null)}
        ; 
+qualified_o {-> qualified?}
+       = qualified {-> qualified}
+       | {null} {-> Null}
+       ;
+qid {-> id}
+       = qualified? id {-> id}
+       ;
+qclassid {-> classid}
+       = qualified? classid {-> classid}
+       ;
 modquad {-> id}
        = id quad no {-> id};
 classquad {-> classid} 
@@ -754,6 +770,7 @@ propdef = {attr} doc? [readable]:able? [writable]:able? kwredef? visibility kwva
        | {meth} doc? kwredef? visibility methid signature
        | {deferred_meth} doc? kwredef? visibility kwmeth methid signature annotations?
        | {intern_meth} doc? kwredef? visibility kwmeth methid signature
+       | {intern_new} doc? kwredef? visibility kwnew methid? signature
        | {extern_meth} doc? kwredef? visibility kwmeth methid signature [extern]:string? extern_calls? extern_code_block?
        | {concrete_meth} doc? kwredef? visibility kwmeth methid signature annotations? [block]:expr?
        | {concrete_init} doc? kwredef? visibility kwinit methid? signature annotations? [block]:expr?
@@ -839,7 +856,8 @@ expr        = {block} expr* kwend?
        | {true} kwtrue annotations?
        | {false} kwfalse annotations?
        | {null} kwnull annotations?
-       | {int} number annotations?
+       | {dec_int} number annotations?
+       | {hex_int} hex_number annotations?
        | {float} float annotations?
        | {char} char annotations?
        | {string} string annotations?
@@ -848,8 +866,8 @@ expr        = {block} expr* kwend?
        | {end_string} [string]:end_string 
        | {superstring} [exprs]:expr* annotations?
        | {par} opar expr cpar annotations?
-        | {as_cast} expr kwas opar type cpar
-        | {as_notnull} expr kwas opar kwnot kwnull cpar
+        | {as_cast} expr kwas opar? type cpar?
+        | {as_notnull} expr kwas opar? kwnot kwnull cpar?
        | {isset_attr} kwisset expr [id]:attrid
        | {debug_type} kwdebug kwtype expr type
        ;