@@ -0,0 +1,1814 @@
+package erjang.m.string;%0A%0Aimport java.math.BigInteger;%0Aimport java.util.regex.Matcher;%0Aimport java.util.regex.Pattern;%0A%0Aimport erjang.BIF;%0Aimport erjang.EAtom;%0Aimport erjang.EDouble;%0Aimport erjang.EInteger;%0Aimport erjang.ENative;%0Aimport erjang.EObject;%0Aimport erjang.ERT;%0Aimport erjang.ESeq;%0Aimport erjang.EString;%0Aimport erjang.ETuple2;%0A%0Apublic class Native extends ENative %7B%0A%0A%09public static EAtom am_no_float = EAtom.intern(%22no_float%22);%0A%09public static EAtom am_no_integer = EAtom.intern(%22no_integer%22);%0A%09public static EAtom am_error = EAtom.intern(%22error%22);%0A%09%0A%09static Pattern int_pattern = Pattern.compile(%22%5E((-%7C%5C%5C+)?(%5C%5Cd+)).*%22);%0A%09static Pattern float_pattern = Pattern.compile(%22%5E((-%7C%5C%5C+)?%5C%5Cd*%5C%5C.%5C%5Cd+(%5BeE%5D(-%7C%5C%5C+)?%5C%5Cd+)?).*%22);%0A%09%0A%09@BIF%0A%09public static ETuple2 to_integer(EObject val)%0A%09%7B%0A%09%09EString v = val.testString();%0A%09%09if (v == null) throw ERT.badarg(val);%0A%09%09%0A%09%09String s = v.stringValue();%0A%09%09Matcher m = int_pattern.matcher(s);%0A%09%09if (m.matches()) %7B%0A%09%09%09String ss = m.group(1);%0A%09%09%09EInteger intval = ERT.box_parse(ss);%0A%09%09%09ESeq rest;%0A%09%09%09if (ss.length() == s.length()) %7B%0A%09%09%09%09rest = ERT.NIL; %0A%09%09%09%7D else %7B%0A%09%09%09%09rest = new EString(s.substring(ss.length()));%0A%09%09%09%7D%0A%09%09%09return new ETuple2(intval, rest);%09%09%09%0A%09%09%7D else %7B%0A%09%09%09return new ETuple2(am_error, am_no_integer);%0A%09%09%7D%0A%09%7D%0A%09%0A%09@BIF%0A%09public static ETuple2 to_float(EObject val)%0A%09%7B%0A%09%09EString v = val.testString();%0A%09%09if (v == null) throw ERT.badarg(val);%0A%09%09%0A%09%09String s = v.stringValue();%0A%09%09Matcher m = float_pattern.matcher(s);%0A%09%09if (m.matches()) %7B%0A%09%09%09String ss = m.group(1);%0A%09%09%09EDouble floatval = ERT.box( Double.parseDouble(ss) );%0A%09%09%09ESeq rest;%0A%09%09%09if (ss.length() == s.length()) %7B%0A%09%09%09%09rest = ERT.NIL; %0A%09%09%09%7D else %7B%0A%09%09%09%09rest = new EString(s.substring(ss.length()));%0A%09%09%09%7D%0A%09%09%09return new ETuple2(floatval, rest);%09%09%09%0A%09%09%7D else %7B%0A%09%09%09return new ETuple2(am_error, am_no_float);%0A%09%09%7D%0A%09%7D%0A%09%0A%7D%0A

Add string:to_integer/1 and string:to_float/1 BIFs