[pure-lang-svn] SF.net SVN: pure-lang: [374] pure/trunk
Status: Beta
Brought to you by:
agraef
From: <ag...@us...> - 2008-07-03 00:19:38
|
Revision: 374 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=374&view=rev Author: agraef Date: 2008-07-02 17:19:47 -0700 (Wed, 02 Jul 2008) Log Message: ----------- Temporarily suppress verbose output for using clause. Modified Paths: -------------- pure/trunk/ChangeLog pure/trunk/interpreter.cc pure/trunk/test/prelude.log pure/trunk/test/test011.log pure/trunk/test/test014.log Modified: pure/trunk/ChangeLog =================================================================== --- pure/trunk/ChangeLog 2008-07-02 23:31:57 UTC (rev 373) +++ pure/trunk/ChangeLog 2008-07-03 00:19:47 UTC (rev 374) @@ -1,3 +1,9 @@ +2008-07-03 Albert Graef <Dr....@t-...> + + * interpreter.cc (run): Temporarily suppress verbose output for + using clause. This also makes the some of the test logs much + smaller. Reported by Jiri Spitz. + 2008-07-02 Albert Graef <Dr....@t-...> * lib/math.pure: Added rational numbers. Modified: pure/trunk/interpreter.cc =================================================================== --- pure/trunk/interpreter.cc 2008-07-02 23:31:57 UTC (rev 373) +++ pure/trunk/interpreter.cc 2008-07-03 00:19:47 UTC (rev 374) @@ -441,8 +441,14 @@ pure_expr* interpreter::run(const list<string> &sl, bool check) { + uint8_t s_verbose = verbose; + // Temporarily suppress verbose output for using clause. + compile(); + verbose = 0; for (list<string>::const_iterator s = sl.begin(); s != sl.end(); s++) run(*s, check); + compile(); + verbose = s_verbose; return result; } Modified: pure/trunk/test/prelude.log =================================================================== --- pure/trunk/test/prelude.log 2008-07-02 23:31:57 UTC (rev 373) +++ pure/trunk/test/prelude.log 2008-07-03 00:19:47 UTC (rev 374) @@ -1,355 +1,5 @@ def false = 0; def true = 1; -throw x/*0:1*/ = pure_throw x/*0:1*/; -assert p/*0:01*/ e/*0:1*/ = if p/*0:01*/ then 1 else throw e/*0:1*/; -x/*0:01*/===y/*0:1*/ = same x/*0:01*/ y/*0:1*/; -x/*0:01*/!==y/*0:1*/ = not same x/*0:01*/ y/*0:1*/; -intp x/*0:1*/ = case x/*0:1*/ of _/*0:*/::int = 1; _/*0:*/ = 0 { - rule #0: _::int = 1 - rule #1: _ = 0 - state 0: #0 #1 - <var> state 1 - <var>::int state 2 - state 1: #1 - state 2: #0 #1 -} end; -bigintp x/*0:1*/ = case x/*0:1*/ of _/*0:*/::bigint = 1; _/*0:*/ = 0 { - rule #0: _::bigint = 1 - rule #1: _ = 0 - state 0: #0 #1 - <var> state 1 - <var>::bigint state 2 - state 1: #1 - state 2: #0 #1 -} end; -doublep x/*0:1*/ = case x/*0:1*/ of _/*0:*/::double = 1; _/*0:*/ = 0 { - rule #0: _::double = 1 - rule #1: _ = 0 - state 0: #0 #1 - <var> state 1 - <var>::double state 2 - state 1: #1 - state 2: #0 #1 -} end; -stringp x/*0:1*/ = case x/*0:1*/ of _/*0:*/::string = 1; _/*0:*/ = 0 { - rule #0: _::string = 1 - rule #1: _ = 0 - state 0: #0 #1 - <var> state 1 - <var>::string state 2 - state 1: #1 - state 2: #0 #1 -} end; -pointerp x/*0:1*/ = case x/*0:1*/ of _/*0:*/ = 1; _/*0:*/ = 0 { - rule #0: _ = 1 - rule #1: _ = 0 - state 0: #0 #1 - <var> state 1 - <var> state 2 - state 1: #1 - state 2: #0 #1 -} end; -listp [] = 1; -listp (x/*0:101*/:xs/*0:11*/) = listp xs/*0:11*/; -listp _/*0:1*/ = 0; -listnp [] = 1; -listnp (x/*0:101*/:xs/*0:11*/) = 1; -listnp _/*0:1*/ = 0; -tuplep () = 1; -tuplep (x/*0:101*/,xs/*0:11*/) = 1; -tuplep _/*0:1*/ = 0; -int x/*0:1*/::int = x/*0:1*/; -int x/*0:1*/::bigint = pure_intval x/*0:1*/; -int x/*0:1*/::double = pure_intval x/*0:1*/; -int x/*0:1*/ = pure_intval x/*0:1*/; -bigint x/*0:1*/::bigint = x/*0:1*/; -bigint x/*0:1*/::int = pure_bigintval x/*0:1*/; -bigint x/*0:1*/::double = pure_bigintval x/*0:1*/; -bigint x/*0:1*/ = pure_bigintval x/*0:1*/; -double x/*0:1*/::double = x/*0:1*/; -double x/*0:1*/::int = pure_dblval x/*0:1*/; -double x/*0:1*/::bigint = pure_dblval x/*0:1*/; -pointer x/*0:1*/ = x/*0:1*/; -pointer x/*0:1*/::int = pure_pointerval x/*0:1*/; -pointer x/*0:1*/::bigint = pure_pointerval x/*0:1*/; -pointer x/*0:1*/::double = pure_pointerval x/*0:1*/; -pointer x/*0:1*/::string = pure_pointerval x/*0:1*/; --x/*0:1*/::int = -x/*0:1*/; -~x/*0:1*/::int = ~x/*0:1*/; -not x/*0:1*/::int = not x/*0:1*/; -x/*0:01*/::int<<y/*0:1*/::int = x/*0:01*/<<y/*0:1*/; -x/*0:01*/::int>>y/*0:1*/::int = x/*0:01*/>>y/*0:1*/; -x/*0:01*/::int+y/*0:1*/::int = x/*0:01*/+y/*0:1*/; -x/*0:01*/::int-y/*0:1*/::int = x/*0:01*/-y/*0:1*/; -x/*0:01*/::int*y/*0:1*/::int = x/*0:01*/*y/*0:1*/; -x/*0:01*/::int/y/*0:1*/::int = x/*0:01*//y/*0:1*/; -x/*0:01*/::int div y/*0:1*/::int = x/*0:01*/ div y/*0:1*/; -x/*0:01*/::int mod y/*0:1*/::int = x/*0:01*/ mod y/*0:1*/; -x/*0:01*/::int or y/*0:1*/::int = x/*0:01*/ or y/*0:1*/; -x/*0:01*/::int and y/*0:1*/::int = x/*0:01*/ and y/*0:1*/; -x/*0:01*/::int<y/*0:1*/::int = x/*0:01*/<y/*0:1*/; -x/*0:01*/::int>y/*0:1*/::int = x/*0:01*/>y/*0:1*/; -x/*0:01*/::int<=y/*0:1*/::int = x/*0:01*/<=y/*0:1*/; -x/*0:01*/::int>=y/*0:1*/::int = x/*0:01*/>=y/*0:1*/; -x/*0:01*/::int==y/*0:1*/::int = x/*0:01*/==y/*0:1*/; -x/*0:01*/::int!=y/*0:1*/::int = x/*0:01*/!=y/*0:1*/; --x/*0:1*/::double = -x/*0:1*/; -x/*0:01*/::double+y/*0:1*/::double = x/*0:01*/+y/*0:1*/; -x/*0:01*/::double-y/*0:1*/::double = x/*0:01*/-y/*0:1*/; -x/*0:01*/::double*y/*0:1*/::double = x/*0:01*/*y/*0:1*/; -x/*0:01*/::double/y/*0:1*/::double = x/*0:01*//y/*0:1*/; -x/*0:01*/::double<y/*0:1*/::double = x/*0:01*/<y/*0:1*/; -x/*0:01*/::double>y/*0:1*/::double = x/*0:01*/>y/*0:1*/; -x/*0:01*/::double<=y/*0:1*/::double = x/*0:01*/<=y/*0:1*/; -x/*0:01*/::double>=y/*0:1*/::double = x/*0:01*/>=y/*0:1*/; -x/*0:01*/::double==y/*0:1*/::double = x/*0:01*/==y/*0:1*/; -x/*0:01*/::double!=y/*0:1*/::double = x/*0:01*/!=y/*0:1*/; -x/*0:01*/::int+y/*0:1*/::double = x/*0:01*/+y/*0:1*/; -x/*0:01*/::int-y/*0:1*/::double = x/*0:01*/-y/*0:1*/; -x/*0:01*/::int*y/*0:1*/::double = x/*0:01*/*y/*0:1*/; -x/*0:01*/::int/y/*0:1*/::double = x/*0:01*//y/*0:1*/; -x/*0:01*/::int<y/*0:1*/::double = x/*0:01*/<y/*0:1*/; -x/*0:01*/::int>y/*0:1*/::double = x/*0:01*/>y/*0:1*/; -x/*0:01*/::int<=y/*0:1*/::double = x/*0:01*/<=y/*0:1*/; -x/*0:01*/::int>=y/*0:1*/::double = x/*0:01*/>=y/*0:1*/; -x/*0:01*/::int==y/*0:1*/::double = x/*0:01*/==y/*0:1*/; -x/*0:01*/::int!=y/*0:1*/::double = x/*0:01*/!=y/*0:1*/; -x/*0:01*/::double+y/*0:1*/::int = x/*0:01*/+y/*0:1*/; -x/*0:01*/::double-y/*0:1*/::int = x/*0:01*/-y/*0:1*/; -x/*0:01*/::double*y/*0:1*/::int = x/*0:01*/*y/*0:1*/; -x/*0:01*/::double/y/*0:1*/::int = x/*0:01*//y/*0:1*/; -x/*0:01*/::double<y/*0:1*/::int = x/*0:01*/<y/*0:1*/; -x/*0:01*/::double>y/*0:1*/::int = x/*0:01*/>y/*0:1*/; -x/*0:01*/::double<=y/*0:1*/::int = x/*0:01*/<=y/*0:1*/; -x/*0:01*/::double>=y/*0:1*/::int = x/*0:01*/>=y/*0:1*/; -x/*0:01*/::double==y/*0:1*/::int = x/*0:01*/==y/*0:1*/; -x/*0:01*/::double!=y/*0:1*/::int = x/*0:01*/!=y/*0:1*/; -x/*0:01*/::int&&y/*0:1*/::int = x/*0:01*/&&y/*0:1*/; -x/*0:01*/::int||y/*0:1*/::int = x/*0:01*/||y/*0:1*/; --x/*0:1*/::bigint = bigint_neg x/*0:1*/; -~x/*0:1*/::bigint = bigint_not x/*0:1*/; -not x/*0:1*/::bigint = not int x/*0:1*/; -x/*0:01*/::bigint<<y/*0:1*/::int = bigint_shl x/*0:01*/ y/*0:1*/ if y/*0:1*/>=0; -x/*0:01*/::bigint<<y/*0:1*/::int = bigint_shr x/*0:01*/ (-y/*0:1*/); -x/*0:01*/::bigint>>y/*0:1*/::int = bigint_shr x/*0:01*/ y/*0:1*/ if y/*0:1*/>=0; -x/*0:01*/::bigint>>y/*0:1*/::int = bigint_shl x/*0:01*/ (-y/*0:1*/); -x/*0:01*/::bigint+y/*0:1*/::bigint = bigint_add x/*0:01*/ y/*0:1*/; -x/*0:01*/::bigint-y/*0:1*/::bigint = bigint_sub x/*0:01*/ y/*0:1*/; -x/*0:01*/::bigint*y/*0:1*/::bigint = bigint_mul x/*0:01*/ y/*0:1*/; -x/*0:01*/::bigint/y/*0:1*/::bigint = double x/*0:01*//double y/*0:1*/; -x/*0:01*/::bigint div y/*0:1*/::bigint = bigint_div x/*0:01*/ y/*0:1*/; -x/*0:01*/::bigint mod y/*0:1*/::bigint = bigint_mod x/*0:01*/ y/*0:1*/; -x/*0:01*/::bigint or y/*0:1*/::bigint = bigint_or x/*0:01*/ y/*0:1*/; -x/*0:01*/::bigint and y/*0:1*/::bigint = bigint_and x/*0:01*/ y/*0:1*/; -x/*0:01*/::bigint<y/*0:1*/::bigint = bigint_cmp x/*0:01*/ y/*0:1*/<0; -x/*0:01*/::bigint>y/*0:1*/::bigint = bigint_cmp x/*0:01*/ y/*0:1*/>0; -x/*0:01*/::bigint<=y/*0:1*/::bigint = bigint_cmp x/*0:01*/ y/*0:1*/<=0; -x/*0:01*/::bigint>=y/*0:1*/::bigint = bigint_cmp x/*0:01*/ y/*0:1*/>=0; -x/*0:01*/::bigint==y/*0:1*/::bigint = bigint_cmp x/*0:01*/ y/*0:1*/==0; -x/*0:01*/::bigint!=y/*0:1*/::bigint = bigint_cmp x/*0:01*/ y/*0:1*/!=0; -x/*0:01*/::int+y/*0:1*/::bigint = bigint x/*0:01*/+y/*0:1*/; -x/*0:01*/::int-y/*0:1*/::bigint = bigint x/*0:01*/-y/*0:1*/; -x/*0:01*/::int*y/*0:1*/::bigint = bigint x/*0:01*/*y/*0:1*/; -x/*0:01*/::int/y/*0:1*/::bigint = double x/*0:01*//y/*0:1*/; -x/*0:01*/::int div y/*0:1*/::bigint = bigint x/*0:01*/ div y/*0:1*/; -x/*0:01*/::int mod y/*0:1*/::bigint = bigint x/*0:01*/ mod y/*0:1*/; -x/*0:01*/::int or y/*0:1*/::bigint = bigint x/*0:01*/ or y/*0:1*/; -x/*0:01*/::int and y/*0:1*/::bigint = bigint x/*0:01*/ and y/*0:1*/; -x/*0:01*/::int<y/*0:1*/::bigint = bigint x/*0:01*/<y/*0:1*/; -x/*0:01*/::int>y/*0:1*/::bigint = bigint x/*0:01*/>y/*0:1*/; -x/*0:01*/::int<=y/*0:1*/::bigint = bigint x/*0:01*/<=y/*0:1*/; -x/*0:01*/::int>=y/*0:1*/::bigint = bigint x/*0:01*/>=y/*0:1*/; -x/*0:01*/::int==y/*0:1*/::bigint = bigint x/*0:01*/==y/*0:1*/; -x/*0:01*/::int!=y/*0:1*/::bigint = bigint x/*0:01*/!=y/*0:1*/; -x/*0:01*/::bigint+y/*0:1*/::int = x/*0:01*/+bigint y/*0:1*/; -x/*0:01*/::bigint-y/*0:1*/::int = x/*0:01*/-bigint y/*0:1*/; -x/*0:01*/::bigint*y/*0:1*/::int = x/*0:01*/*bigint y/*0:1*/; -x/*0:01*/::bigint/y/*0:1*/::int = x/*0:01*//double y/*0:1*/; -x/*0:01*/::bigint div y/*0:1*/::int = x/*0:01*/ div bigint y/*0:1*/; -x/*0:01*/::bigint mod y/*0:1*/::int = x/*0:01*/ mod bigint y/*0:1*/; -x/*0:01*/::bigint or y/*0:1*/::int = x/*0:01*/ or bigint y/*0:1*/; -x/*0:01*/::bigint and y/*0:1*/::int = x/*0:01*/ and bigint y/*0:1*/; -x/*0:01*/::bigint<y/*0:1*/::int = x/*0:01*/<bigint y/*0:1*/; -x/*0:01*/::bigint>y/*0:1*/::int = x/*0:01*/>bigint y/*0:1*/; -x/*0:01*/::bigint<=y/*0:1*/::int = x/*0:01*/<=bigint y/*0:1*/; -x/*0:01*/::bigint>=y/*0:1*/::int = x/*0:01*/>=bigint y/*0:1*/; -x/*0:01*/::bigint==y/*0:1*/::int = x/*0:01*/==bigint y/*0:1*/; -x/*0:01*/::bigint!=y/*0:1*/::int = x/*0:01*/!=bigint y/*0:1*/; -x/*0:01*/::bigint+y/*0:1*/::double = double x/*0:01*/+y/*0:1*/; -x/*0:01*/::bigint-y/*0:1*/::double = double x/*0:01*/-y/*0:1*/; -x/*0:01*/::bigint*y/*0:1*/::double = double x/*0:01*/*y/*0:1*/; -x/*0:01*/::bigint/y/*0:1*/::double = double x/*0:01*//y/*0:1*/; -x/*0:01*/::bigint<y/*0:1*/::double = double x/*0:01*/<y/*0:1*/; -x/*0:01*/::bigint>y/*0:1*/::double = double x/*0:01*/>y/*0:1*/; -x/*0:01*/::bigint<=y/*0:1*/::double = double x/*0:01*/<=y/*0:1*/; -x/*0:01*/::bigint>=y/*0:1*/::double = double x/*0:01*/>=y/*0:1*/; -x/*0:01*/::bigint==y/*0:1*/::double = double x/*0:01*/==y/*0:1*/; -x/*0:01*/::bigint!=y/*0:1*/::double = double x/*0:01*/!=y/*0:1*/; -x/*0:01*/::double+y/*0:1*/::bigint = x/*0:01*/+double y/*0:1*/; -x/*0:01*/::double-y/*0:1*/::bigint = x/*0:01*/-double y/*0:1*/; -x/*0:01*/::double*y/*0:1*/::bigint = x/*0:01*/*double y/*0:1*/; -x/*0:01*/::double/y/*0:1*/::bigint = x/*0:01*//double y/*0:1*/; -x/*0:01*/::double<y/*0:1*/::bigint = x/*0:01*/<double y/*0:1*/; -x/*0:01*/::double>y/*0:1*/::bigint = x/*0:01*/>double y/*0:1*/; -x/*0:01*/::double<=y/*0:1*/::bigint = x/*0:01*/<=double y/*0:1*/; -x/*0:01*/::double>=y/*0:1*/::bigint = x/*0:01*/>=double y/*0:1*/; -x/*0:01*/::double==y/*0:1*/::bigint = x/*0:01*/==double y/*0:1*/; -x/*0:01*/::double!=y/*0:1*/::bigint = x/*0:01*/!=double y/*0:1*/; -gcd x/*0:01*/::bigint y/*0:1*/::bigint = bigint_gcd x/*0:01*/ y/*0:1*/; -lcm x/*0:01*/::bigint y/*0:1*/::bigint = bigint_lcm x/*0:01*/ y/*0:1*/; -gcd x/*0:01*/::int y/*0:1*/::bigint = bigint_gcd (bigint x/*0:01*/) y/*0:1*/; -gcd x/*0:01*/::bigint y/*0:1*/::int = bigint_gcd x/*0:01*/ (bigint y/*0:1*/); -gcd x/*0:01*/::int y/*0:1*/::int = int (bigint_gcd (bigint x/*0:01*/) (bigint y/*0:1*/)); -lcm x/*0:01*/::int y/*0:1*/::bigint = bigint_lcm (bigint x/*0:01*/) y/*0:1*/; -lcm x/*0:01*/::bigint y/*0:1*/::int = bigint_lcm x/*0:01*/ (bigint y/*0:1*/); -lcm x/*0:01*/::int y/*0:1*/::int = int (bigint_lcm (bigint x/*0:01*/) (bigint y/*0:1*/)); -pow x/*0:01*/::int y/*0:1*/::int = bigint_pow (bigint x/*0:01*/) y/*0:1*/ if y/*0:1*/>=0; -pow x/*0:01*/::bigint y/*0:1*/::bigint = bigint_pow x/*0:01*/ (int y/*0:1*/) if int y/*0:1*/>=0; -pow x/*0:01*/::double y/*0:1*/::double = c_pow x/*0:01*/ y/*0:1*/ if x/*0:01*/>=0||int y/*0:1*/==y/*0:1*/; -pow x/*0:01*/::int y/*0:1*/::bigint = bigint_pow (bigint x/*0:01*/) (int y/*0:1*/) if y/*0:1*/>=0; -pow x/*0:01*/::bigint y/*0:1*/::int = bigint_pow x/*0:01*/ y/*0:1*/ if y/*0:1*/>=0; -pow x/*0:01*/::double y/*0:1*/::int = c_pow x/*0:01*/ (double y/*0:1*/); -pow x/*0:01*/::double y/*0:1*/::bigint = c_pow x/*0:01*/ (double y/*0:1*/); -pow x/*0:01*/::int y/*0:1*/::double = c_pow (double x/*0:01*/) y/*0:1*/ if x/*0:01*/>=0||int y/*0:1*/==y/*0:1*/; -pow x/*0:01*/::bigint y/*0:1*/::double = c_pow (double x/*0:01*/) y/*0:1*/ if x/*0:01*/>=0||int y/*0:1*/==y/*0:1*/; -x/*0:01*/::double^y/*0:1*/::double = c_pow x/*0:01*/ y/*0:1*/ if x/*0:01*/>=0||int y/*0:1*/==y/*0:1*/; -x/*0:01*/::int^y/*0:1*/::int = c_pow (double x/*0:01*/) (double y/*0:1*/); -x/*0:01*/::bigint^y/*0:1*/::bigint = c_pow (double x/*0:01*/) (double y/*0:1*/); -x/*0:01*/::int^y/*0:1*/::bigint = c_pow (double x/*0:01*/) (double y/*0:1*/); -x/*0:01*/::bigint^y/*0:1*/::int = c_pow (double x/*0:01*/) (double y/*0:1*/); -x/*0:01*/::double^y/*0:1*/::int = c_pow x/*0:01*/ (double y/*0:1*/); -x/*0:01*/::double^y/*0:1*/::bigint = c_pow x/*0:01*/ (double y/*0:1*/); -x/*0:01*/::int^y/*0:1*/::double = c_pow (double x/*0:01*/) y/*0:1*/ if x/*0:01*/>=0||int y/*0:1*/==y/*0:1*/; -x/*0:01*/::bigint^y/*0:1*/::double = c_pow (double x/*0:01*/) y/*0:1*/ if x/*0:01*/>=0||int y/*0:1*/==y/*0:1*/; -x/*0:01*/::int^y/*0:1*/::double = double x/*0:01*/^y/*0:1*/; -x/*0:01*/::bigint^y/*0:1*/::double = double x/*0:01*/^y/*0:1*/; -null x/*0:1*/ = bigint x/*0:1*/==0; -x/*0:01*/-y/*0:1*/ = bigint x/*0:01*/-bigint y/*0:1*/; -x/*0:01*/+y/*0:1*/::int = pointer (bigint x/*0:01*/+y/*0:1*/); -x/*0:01*/+y/*0:1*/::bigint = pointer (bigint x/*0:01*/+y/*0:1*/); -x/*0:01*/<y/*0:1*/ = bigint x/*0:01*/<bigint y/*0:1*/; -x/*0:01*/>y/*0:1*/ = bigint x/*0:01*/>bigint y/*0:1*/; -x/*0:01*/<=y/*0:1*/ = bigint x/*0:01*/<=bigint y/*0:1*/; -x/*0:01*/>=y/*0:1*/ = bigint x/*0:01*/>=bigint y/*0:1*/; -x/*0:01*/==y/*0:1*/ = bigint x/*0:01*/==bigint y/*0:1*/; -x/*0:01*/!=y/*0:1*/ = bigint x/*0:01*/!=bigint y/*0:1*/; -get_byte x/*0:1*/ = pointer_get_byte x/*0:1*/; -get_int x/*0:1*/ = pointer_get_int x/*0:1*/; -get_double x/*0:1*/ = pointer_get_double x/*0:1*/; -get_string x/*0:1*/ = pointer_get_string x/*0:1*/; -get_pointer x/*0:1*/ = pointer_get_pointer x/*0:1*/; -put_byte x/*0:01*/ y/*0:1*/::int = pointer_put_byte x/*0:01*/ y/*0:1*/; -put_int x/*0:01*/ y/*0:1*/::int = pointer_put_int x/*0:01*/ y/*0:1*/; -put_double x/*0:01*/ y/*0:1*/::double = pointer_put_double x/*0:01*/ y/*0:1*/; -put_string x/*0:01*/ y/*0:1*/::string = pointer_put_string x/*0:01*/ y/*0:1*/; -put_pointer x/*0:01*/ y/*0:1*/::string = pointer_put_pointer x/*0:01*/ y/*0:1*/; -put_pointer x/*0:01*/ y/*0:1*/ = pointer_put_pointer x/*0:01*/ y/*0:1*/; -str x/*0:1*/ = cstring (pure_str x/*0:1*/); -chr n/*0:1*/::int = string_chr n/*0:1*/ if n/*0:1*/>0; -ord s/*0:1*/::string = string_ord s/*0:1*/ if #s/*0:1*/==1; -string s/*0:1*/ = pure_string s/*0:1*/; -cstring s/*0:1*/ = pure_cstring s/*0:1*/; -string_dup s/*0:1*/ = pure_string_dup s/*0:1*/; -cstring_dup s/*0:1*/ = pure_cstring_dup s/*0:1*/; -byte_string s/*0:1*/::string = pure_byte_string s/*0:1*/; -byte_cstring s/*0:1*/::string = pure_byte_cstring s/*0:1*/; -c/*0:01*/::string+n/*0:1*/::int = chr (ord c/*0:01*/+n/*0:1*/) if #c/*0:01*/==1; -c/*0:01*/::string-n/*0:1*/::int = chr (ord c/*0:01*/-n/*0:1*/) if #c/*0:01*/==1&&ord c/*0:01*/>=n/*0:1*/; -c/*0:01*/::string-d/*0:1*/::string = ord c/*0:01*/-ord d/*0:1*/ if #c/*0:01*/==1&&#d/*0:1*/==1; -null s/*0:1*/::string = string_null s/*0:1*/; -#s/*0:1*/::string = string_size s/*0:1*/; -s/*0:01*/::string!n/*0:1*/::int = string_char_at s/*0:01*/ n/*0:1*/ if n/*0:1*/>=0&&n/*0:1*/<#s/*0:01*/; -s/*0:01*/::string+t/*0:1*/::string = string_concat s/*0:01*/ t/*0:1*/; -chars s/*0:1*/::string = string_chars s/*0:1*/; -x/*0:01*/::string<y/*0:1*/::string = strcmp x/*0:01*/ y/*0:1*/<0; -x/*0:01*/::string>y/*0:1*/::string = strcmp x/*0:01*/ y/*0:1*/>0; -x/*0:01*/::string<=y/*0:1*/::string = strcmp x/*0:01*/ y/*0:1*/<=0; -x/*0:01*/::string>=y/*0:1*/::string = strcmp x/*0:01*/ y/*0:1*/>=0; -x/*0:01*/::string==y/*0:1*/::string = strcmp x/*0:01*/ y/*0:1*/==0; -x/*0:01*/::string!=y/*0:1*/::string = strcmp x/*0:01*/ y/*0:1*/!=0; -substr s/*0:001*/::string pos/*0:01*/::int size/*0:1*/::int = string_substr s/*0:001*/ (max/*0*/ 0 pos/*0:01*/) (max/*0*/ 0 size/*0:1*/) with max x/*0:01*/ y/*0:1*/ = if x/*0:01*/>=y/*0:1*/ then x/*0:01*/ else y/*0:1*/ { - rule #0: max x y = if x>=y then x else y - state 0: #0 - <var> state 1 - state 1: #0 - <var> state 2 - state 2: #0 -} end; -index s/*0:01*/::string u/*0:1*/::string = string_index s/*0:01*/ u/*0:1*/; -strcat xs/*0:1*/ = string_concat_list xs/*0:1*/ if listp xs/*0:1*/&&all stringp xs/*0:1*/; -join delim/*0:01*/::string [] = ""; -join delim/*0:01*/::string (x/*0:101*/::string:xs/*0:11*/) = x/*0:101*/+strcat (catmap (\x/*0:*/ -> [delim/*1:01*/+x/*0:*/] { - rule #0: x = [delim+x] - state 0: #0 - <var> state 1 - state 1: #0 -}) xs/*0:11*/) if listp xs/*0:11*/&&all stringp xs/*0:11*/; -split delim/*0:01*/::string s/*0:1*/::string = if null s/*1:1*/ then [] else split1/*0*/ delim/*1:01*/ s/*1:1*/ with split1 delim/*0:01*/ s/*0:1*/ = case index s/*0:1*/ delim/*0:01*/ of n/*0:*/ = take n/*0:*/ s/*1:1*/:split1/*2*/ delim/*1:01*/ (drop (n/*0:*/+m/*2:*/) s/*1:1*/) if n/*0:*/>=0; n/*0:*/ = [s/*1:1*/] { - rule #0: n = take n s:split1 delim (drop (n+m) s) if n>=0 - rule #1: n = [s] - state 0: #0 #1 - <var> state 1 - state 1: #0 #1 -} end { - rule #0: split1 delim s = case index s delim of n = take n s:split1 delim (drop (n+m) s) if n>=0; n = [s] end - state 0: #0 - <var> state 1 - state 1: #0 - <var> state 2 - state 2: #0 -} end when m/*0:*/ = #delim/*0:01*/ { - rule #0: m = #delim - state 0: #0 - <var> state 1 - state 1: #0 -} end if not null delim/*0:01*/; -list s/*0:1*/::string = chars s/*0:1*/; -tuple s/*0:1*/::string = tuple (chars s/*0:1*/); -reverse s/*0:1*/::string = strcat (reverse (chars s/*0:1*/)); -cat (s/*0:101*/::string:xs/*0:11*/) = cat (chars s/*0:101*/:xs/*0:11*/); -cycle n/*0:01*/::int "" = ""; -cycle n/*0:01*/::int s/*0:1*/::string = "" if n/*0:01*/<=0; -cycle n/*0:01*/::int s/*0:1*/::string = accum/*0*/ [] n/*1:01*/ with accum ys/*0:01*/ n/*0:1*/ = strcat ys/*0:01*/+take n/*0:1*/ s/*2:1*/ if n/*0:1*/<=m/*1:*/; accum ys/*0:01*/ n/*0:1*/ = accum/*1*/ (s/*2:1*/:ys/*0:01*/) (n/*0:1*/-m/*1:*/) { - rule #0: accum ys n = strcat ys+take n s if n<=m - rule #1: accum ys n = accum (s:ys) (n-m) - state 0: #0 #1 - <var> state 1 - state 1: #0 #1 - <var> state 2 - state 2: #0 #1 -} end when m/*0:*/::int = #s/*0:1*/ { - rule #0: m::int = #s - state 0: #0 - <var>::int state 1 - state 1: #0 -} end; -all p/*0:01*/ s/*0:1*/::string = all p/*0:01*/ (chars s/*0:1*/); -any p/*0:01*/ s/*0:1*/::string = any p/*0:01*/ (chars s/*0:1*/); -do f/*0:01*/ s/*0:1*/::string = do f/*0:01*/ (chars s/*0:1*/); -drop n/*0:01*/ s/*0:1*/::string = substr s/*0:1*/ n/*0:01*/ (#s/*0:1*/-n/*0:01*/); -dropwhile p/*0:01*/ s/*0:1*/::string = strcat (dropwhile p/*0:01*/ (chars s/*0:1*/)); -filter p/*0:01*/ s/*0:1*/::string = strcat (filter p/*0:01*/ (chars s/*0:1*/)); -foldl f/*0:001*/ a/*0:01*/ s/*0:1*/::string = foldl f/*0:001*/ a/*0:01*/ (chars s/*0:1*/); -foldl1 f/*0:01*/ s/*0:1*/::string = foldl1 f/*0:01*/ (chars s/*0:1*/); -foldr f/*0:001*/ a/*0:01*/ s/*0:1*/::string = foldr f/*0:001*/ a/*0:01*/ (chars s/*0:1*/); -foldr1 f/*0:01*/ s/*0:1*/::string = foldr1 f/*0:01*/ (chars s/*0:1*/); -head s/*0:1*/::string = s/*0:1*/!0 if not null s/*0:1*/; -init s/*0:1*/::string = substr s/*0:1*/ 0 (#s/*0:1*/-1) if not null s/*0:1*/; -last s/*0:1*/::string = s/*0:1*/!(#s/*0:1*/-1) if not null s/*0:1*/; -map f/*0:01*/ s/*0:1*/::string = map f/*0:01*/ (chars s/*0:1*/); -scanl f/*0:001*/ a/*0:01*/ s/*0:1*/::string = scanl f/*0:001*/ a/*0:01*/ (chars s/*0:1*/); -scanl1 f/*0:01*/ s/*0:1*/::string = scanl1 f/*0:01*/ (chars s/*0:1*/); -scanr f/*0:001*/ a/*0:01*/ s/*0:1*/::string = scanr f/*0:001*/ a/*0:01*/ (chars s/*0:1*/); -scanr1 f/*0:01*/ s/*0:1*/::string = scanr1 f/*0:01*/ (chars s/*0:1*/); -take n/*0:01*/ s/*0:1*/::string = substr s/*0:1*/ 0 n/*0:01*/; -takewhile p/*0:01*/ s/*0:1*/::string = strcat (takewhile p/*0:01*/ (chars s/*0:1*/)); -tail s/*0:1*/::string = substr s/*0:1*/ 1 (#s/*0:1*/-1) if not null s/*0:1*/; -zip s/*0:01*/::string t/*0:1*/::string = zip (chars s/*0:01*/) (chars t/*0:1*/); -zip3 s/*0:001*/::string t/*0:01*/::string u/*0:1*/::string = zip3 (chars s/*0:001*/) (chars t/*0:01*/) (chars u/*0:1*/); -zipwith f/*0:001*/ s/*0:01*/::string t/*0:1*/::string = zipwith f/*0:001*/ (chars s/*0:01*/) (chars t/*0:1*/); -zipwith3 f/*0:0001*/ s/*0:001*/::string t/*0:01*/::string u/*0:1*/::string = zipwith3 f/*0:0001*/ (chars s/*0:001*/) (chars t/*0:01*/) (chars u/*0:1*/); -dowith f/*0:001*/ s/*0:01*/::string t/*0:1*/::string = dowith f/*0:001*/ (chars s/*0:01*/) (chars t/*0:1*/); -dowith3 f/*0:0001*/ s/*0:001*/::string t/*0:01*/::string u/*0:1*/::string = dowith3 f/*0:0001*/ (chars s/*0:001*/) (chars t/*0:01*/) (chars u/*0:1*/); f/*0:01*/$x/*0:1*/ = f/*0:01*/ x/*0:1*/; (f/*0:001*/.g/*0:01*/) x/*0:1*/ = f/*0:001*/ (g/*0:01*/ x/*0:1*/); void _/*0:1*/ = (); Modified: pure/trunk/test/test011.log =================================================================== --- pure/trunk/test/test011.log 2008-07-02 23:31:57 UTC (rev 373) +++ pure/trunk/test/test011.log 2008-07-03 00:19:47 UTC (rev 374) @@ -1,2107 +1,3 @@ -pure_sys_vars; -errno = pure_errno; -set_errno val/*0:1*/::int = pure_set_errno val/*0:1*/; -fgets f/*0:1*/ = read_a_line/*1*/ f/*1:1*/ buf/*0:*/ "" when buf/*0:*/ = malloc 1024 { - rule #0: buf = malloc 1024 - state 0: #0 - <var> state 1 - state 1: #0 -} end with read_a_line f/*0:001*/ buf/*0:01*/ t/*0:1*/ = check/*1*/ s/*0:*/ when s/*0:*/ = c_fgets buf/*0:01*/ 1024 f/*0:001*/ { - rule #0: s = c_fgets buf 1024 f - state 0: #0 - <var> state 1 - state 1: #0 -} end with check s/*0:1*/::string = return/*1*/ (t/*1:1*/+s/*0:1*/) if done/*1*/ s/*0:1*/; check s/*0:1*/::string = read_a_line/*2*/ f/*1:001*/ buf/*1:01*/ (t/*1:1*/+s/*0:1*/); check s/*0:1*/ = return/*1*/ s/*0:1*/ if null t/*1:1*/; check s/*0:1*/ = return/*1*/ t/*1:1*/ { - rule #0: check s::string = return (t+s) if done s - rule #1: check s::string = read_a_line f buf (t+s) - rule #2: check s = return s if null t - rule #3: check s = return t - state 0: #0 #1 #2 #3 - <var> state 1 - <var>::string state 2 - state 1: #2 #3 - state 2: #0 #1 #2 #3 -}; return x/*0:1*/ = x/*1:1*/ when _/*0:*/ = free buf/*1:01*/ { - rule #0: _ = free buf - state 0: #0 - <var> state 1 - state 1: #0 -} end { - rule #0: return x = x when _ = free buf end - state 0: #0 - <var> state 1 - state 1: #0 -}; done s/*0:1*/::string = feof f/*1:001*/||ferror f/*1:001*/||not null s/*0:1*/&&last s/*0:1*/=="\n" { - rule #0: done s::string = feof f||ferror f||not null s&&last s=="\n" - state 0: #0 - <var>::string state 1 - state 1: #0 -} end { - rule #0: read_a_line f buf t = check s when s = c_fgets buf 1024 f end with check s::string = return (t+s) if done s; check s::string = read_a_line f buf (t+s); check s = return s if null t; check s = return t; return x = x when _ = free buf end; done s::string = feof f||ferror f||not null s&&last s=="\n" end - state 0: #0 - <var> state 1 - state 1: #0 - <var> state 2 - state 2: #0 - <var> state 3 - state 3: #0 -} end; -gets = if null s/*0:*/ then s/*0:*/ else if last s/*0:*/=="\n" then init s/*0:*/ else s/*0:*/ when s/*0:*/ = fgets stdin { - rule #0: s = fgets stdin - state 0: #0 - <var> state 1 - state 1: #0 -} end; -fget f/*0:1*/ = read_a_file/*1*/ f/*1:1*/ buf/*0:*/ "" when buf/*0:*/ = malloc 65536 { - rule #0: buf = malloc 65536 - state 0: #0 - <var> state 1 - state 1: #0 -} end with read_a_file f/*0:001*/ buf/*0:01*/ t/*0:1*/ = check/*1*/ s/*0:*/ when s/*0:*/ = c_fgets buf/*0:01*/ 65536 f/*0:001*/ { - rule #0: s = c_fgets buf 65536 f - state 0: #0 - <var> state 1 - state 1: #0 -} end with check s/*0:1*/::string = return/*1*/ (t/*1:1*/+s/*0:1*/) if feof f/*1:001*/||ferror f/*1:001*/; check s/*0:1*/::string = read_a_file/*2*/ f/*1:001*/ buf/*1:01*/ (t/*1:1*/+s/*0:1*/); check s/*0:1*/ = return/*1*/ s/*0:1*/ if null t/*1:1*/; check s/*0:1*/ = return/*1*/ t/*1:1*/ { - rule #0: check s::string = return (t+s) if feof f||ferror f - rule #1: check s::string = read_a_file f buf (t+s) - rule #2: check s = return s if null t - rule #3: check s = return t - state 0: #0 #1 #2 #3 - <var> state 1 - <var>::string state 2 - state 1: #2 #3 - state 2: #0 #1 #2 #3 -}; return x/*0:1*/ = x/*1:1*/ when _/*0:*/ = free buf/*1:01*/ { - rule #0: _ = free buf - state 0: #0 - <var> state 1 - state 1: #0 -} end { - rule #0: return x = x when _ = free buf end - state 0: #0 - <var> state 1 - state 1: #0 -} end { - rule #0: read_a_file f buf t = check s when s = c_fgets buf 65536 f end with check s::string = return (t+s) if feof f||ferror f; check s::string = read_a_file f buf (t+s); check s = return s if null t; check s = return t; return x = x when _ = free buf end end - state 0: #0 - <var> state 1 - state 1: #0 - <var> state 2 - state 2: #0 - <var> state 3 - state 3: #0 -} end; -printf format/*0:01*/::string args/*0:1*/ = fprintf stdout format/*0:01*/ args/*0:1*/; -fprintf fp/*0:001*/ format/*0:01*/::string args/*0:1*/ = count/*0:01*/ when args/*0:*/ = if tuplep args/*0:1*/ then list args/*0:1*/ else [args/*0:1*/]; count/*0:01*/,_/*0:1*/ = catch error_handler/*1*/ (foldl (do_fprintf/*2*/ fp/*2:001*/) (0,args/*1:*/)$printf_split_format format/*2:01*/) { - rule #0: count,_ = catch error_handler (foldl (do_fprintf fp) (0,args)$printf_split_format format) - state 0: #0 - <app> state 1 - state 1: #0 - <app> state 2 - state 2: #0 - , state 3 - state 3: #0 - <var> state 4 - state 4: #0 - <var> state 5 - state 5: #0 -} { - rule #0: args = if tuplep args then list args else [args] - state 0: #0 - <var> state 1 - state 1: #0 -} end with error_handler (printf_error res/*0:11*/::int) = res/*0:11*/,[]; error_handler x/*0:1*/ = throw x/*0:1*/ { - rule #0: error_handler (printf_error res::int) = res,[] - rule #1: error_handler x = throw x - state 0: #0 #1 - <var> state 1 - <app> state 2 - state 1: #1 - state 2: #0 #1 - <var> state 3 - printf_error state 5 - state 3: #1 - <var> state 4 - state 4: #1 - state 5: #0 #1 - <var> state 6 - <var>::int state 7 - state 6: #1 - state 7: #0 #1 -}; do_fprintf fp/*0:001*/ (count/*0:0101*/,arg/*0:01101*/:args/*0:0111*/) (printf_format_spec t/*0:101*/ s/*0:11*/) = count/*0:*/,args/*2:0111*/ when res/*0:*/ = case t/*0:101*/,arg/*0:01101*/ of "d",x/*0:1*/::int = pure_fprintf_int fp/*1:001*/ s/*1:11*/ x/*0:1*/; "d",x/*0:1*/::bigint = pure_fprintf_int fp/*1:001*/ s/*1:11*/ (int x/*0:1*/); "g",x/*0:1*/::double = pure_fprintf_double fp/*1:001*/ s/*1:11*/ x/*0:1*/; "s",x/*0:1*/::string = pure_fprintf_string fp/*1:001*/ s/*1:11*/ x/*0:1*/; "p",x/*0:1*/::string = pure_fprintf_pointer fp/*1:001*/ s/*1:11*/ x/*0:1*/; "p",x/*0:1*/ = pure_fprintf_pointer fp/*1:001*/ s/*1:11*/ x/*0:1*/; _/*0:*/ = throw (printf_value_error s/*1:11*/ arg/*1:01101*/) { - rule #0: "d",x::int = pure_fprintf_int fp s x - rule #1: "d",x::bigint = pure_fprintf_int fp s (int x) - rule #2: "g",x::double = pure_fprintf_double fp s x - rule #3: "s",x::string = pure_fprintf_string fp s x - rule #4: "p",x::string = pure_fprintf_pointer fp s x - rule #5: "p",x = pure_fprintf_pointer fp s x - rule #6: _ = throw (printf_value_error s arg) - state 0: #0 #1 #2 #3 #4 #5 #6 - <var> state 1 - <app> state 2 - state 1: #6 - state 2: #0 #1 #2 #3 #4 #5 #6 - <var> state 3 - <app> state 5 - state 3: #6 - <var> state 4 - state 4: #6 - state 5: #0 #1 #2 #3 #4 #5 #6 - <var> state 6 - , state 9 - state 6: #6 - <var> state 7 - state 7: #6 - <var> state 8 - state 8: #6 - state 9: #0 #1 #2 #3 #4 #5 #6 - <var> state 10 - "d"::string state 12 - "g"::string state 16 - "s"::string state 19 - "p"::string state 22 - state 10: #6 - <var> state 11 - state 11: #6 - state 12: #0 #1 #6 - <var> state 13 - <var>::int state 14 - <var>::bigint state 15 - state 13: #6 - state 14: #0 #6 - state 15: #1 #6 - state 16: #2 #6 - <var> state 17 - <var>::double state 18 - state 17: #6 - state 18: #2 #6 - state 19: #3 #6 - <var> state 20 - <var>::string state 21 - state 20: #6 - state 21: #3 #6 - state 22: #4 #5 #6 - <var> state 23 - <var>::string state 24 - <var> state 25 - state 23: #6 - state 24: #4 #6 - state 25: #5 #6 -} end; count/*0:*/ = if res/*0:*/>=0 then count/*1:0101*/+res/*0:*/ else throw printf_error res/*0:*/ { - rule #0: count = if res>=0 then count+res else throw printf_error res - state 0: #0 - <var> state 1 - state 1: #0 -} { - rule #0: res = case t,arg of "d",x::int = pure_fprintf_int fp s x; "d",x::bigint = pure_fprintf_int fp s (int x); "g",x::double = pure_fprintf_double fp s x; "s",x::string = pure_fprintf_string fp s x; "p",x::string = pure_fprintf_pointer fp s x; "p",x = pure_fprintf_pointer fp s x; _ = throw (printf_value_error s arg) end - state 0: #0 - <var> state 1 - state 1: #0 -} end; do_fprintf fp/*0:001*/ (count/*0:0101*/,args/*0:011*/) (printf_format_str s/*0:11*/) = count/*0:*/,args/*2:011*/ when res/*0:*/ = pure_fprintf fp/*0:001*/ s/*0:11*/; count/*0:*/ = if res/*0:*/>=0 then count/*1:0101*/+res/*0:*/ else throw printf_error res/*0:*/ { - rule #0: count = if res>=0 then count+res else throw printf_error res - state 0: #0 - <var> state 1 - state 1: #0 -} { - rule #0: res = pure_fprintf fp s - state 0: #0 - <var> state 1 - state 1: #0 -} end; do_fprintf fp/*0:001*/ (count/*0:0101*/,_/*0:011*/) _/*0:1*/ = throw printf_arg_error { - rule #0: do_fprintf fp (count,arg:args) (printf_format_spec t s) = count,args when res = case t,arg of "d",x::int = pure_fprintf_int fp s x; "d",x::bigint = pure_fprintf_int fp s (int x); "g",x::double = pure_fprintf_double fp s x; "s",x::string = pure_fprintf_string fp s x; "p",x::string = pure_fprintf_pointer fp s x; "p",x = pure_fprintf_pointer fp s x; _ = throw (printf_value_error s arg) end; count = if res>=0 then count+res else throw printf_error res end - rule #1: do_fprintf fp (count,args) (printf_format_str s) = count,args when res = pure_fprintf fp s; count = if res>=0 then count+res else throw printf_error res end - rule #2: do_fprintf fp (count,_) _ = throw printf_arg_error - state 0: #0 #1 #2 - <var> state 1 - state 1: #0 #1 #2 - <app> state 2 - state 2: #0 #1 #2 - <app> state 3 - state 3: #0 #1 #2 - , state 4 - state 4: #0 #1 #2 - <var> state 5 - state 5: #0 #1 #2 - <var> state 6 - <app> state 13 - state 6: #1 #2 - <var> state 7 - <app> state 8 - state 7: #2 - state 8: #1 #2 - <var> state 9 - printf_format_str state 11 - state 9: #2 - <var> state 10 - state 10: #2 - state 11: #1 #2 - <var> state 12 - state 12: #1 #2 - state 13: #0 #1 #2 - <var> state 14 - <app> state 22 - state 14: #1 #2 - <var> state 15 - state 15: #1 #2 - <var> state 16 - <app> state 17 - state 16: #2 - state 17: #1 #2 - <var> state 18 - printf_format_str state 20 - state 18: #2 - <var> state 19 - state 19: #2 - state 20: #1 #2 - <var> state 21 - state 21: #1 #2 - state 22: #0 #1 #2 - <var> state 23 - : state 32 - state 23: #1 #2 - <var> state 24 - state 24: #1 #2 - <var> state 25 - state 25: #1 #2 - <var> state 26 - <app> state 27 - state 26: #2 - state 27: #1 #2 - <var> state 28 - printf_format_str state 30 - state 28: #2 - <var> state 29 - state 29: #2 - state 30: #1 #2 - <var> state 31 - state 31: #1 #2 - state 32: #0 #1 #2 - <var> state 33 - state 33: #0 #1 #2 - <var> state 34 - state 34: #0 #1 #2 - <var> state 35 - <app> state 36 - state 35: #2 - state 36: #0 #1 #2 - <var> state 37 - <app> state 39 - printf_format_str state 46 - state 37: #2 - <var> state 38 - state 38: #2 - state 39: #0 #2 - <var> state 40 - printf_format_spec state 43 - state 40: #2 - <var> state 41 - state 41: #2 - <var> state 42 - state 42: #2 - state 43: #0 #2 - <var> state 44 - state 44: #0 #2 - <var> state 45 - state 45: #0 #2 - state 46: #1 #2 - <var> state 47 - state 47: #1 #2 -} end; -printf_split_format format/*0:1*/ = regexg analyze/*0*/ "(%[-#0 ]?[0-9]*([.][0-9]*)?[diouxXeEfgGsp])|(%)|([^%]|%%)+" REG_EXTENDED format/*0:1*/ 0 with analyze info/*0:1*/ = if p/*1:01*/>=0 then printf_format_spec (format_type/*4*/ (last u/*2:1*/)) u/*2:1*/ else if q/*0:01*/>=0 then throw (printf_format_error q/*0:01*/) else printf_format_str u/*2:1*/ when _/*0:01*/,u/*0:1*/ = reg 0 info/*0:1*/; p/*0:01*/,_/*0:1*/ = reg 1 info/*1:1*/; q/*0:01*/,_/*0:1*/ = reg 3 info/*2:1*/ { - rule #0: q,_ = reg 3 info - state 0: #0 - <app> state 1 - state 1: #0 - <app> state 2 - state 2: #0 - , state 3 - state 3: #0 - <var> state 4 - state 4: #0 - <var> state 5 - state 5: #0 -} { - rule #0: p,_ = reg 1 info - state 0: #0 - <app> state 1 - state 1: #0 - <app> state 2 - state 2: #0 - , state 3 - state 3: #0 - <var> state 4 - state 4: #0 - <var> state 5 - state 5: #0 -} { - rule #0: _,u = reg 0 info - state 0: #0 - <app> state 1 - state 1: #0 - <app> state 2 - state 2: #0 - , state 3 - state 3: #0 - <var> state 4 - state 4: #0 - <var> state 5 - state 5: #0 -} end { - rule #0: analyze info = if p>=0 then printf_format_spec (format_type (last u)) u else if q>=0 then throw (printf_format_error q) else printf_format_str u when _,u = reg 0 info; p,_ = reg 1 info; q,_ = reg 3 info end - state 0: #0 - <var> state 1 - state 1: #0 -}; format_type x/*0:1*/ = if index "diouxX" x/*0:1*/>=0 then "d" else if index "eEfgG" x/*0:1*/>=0 then "g" else x/*0:1*/ { - rule #0: format_type x = if index "diouxX" x>=0 then "d" else if index "eEfgG" x>=0 then "g" else x - state 0: #0 - <var> state 1 - state 1: #0 -} end; -sprintf format/*0:01*/::string args/*0:1*/ = s/*0:01*/ when args/*0:*/ = if tuplep args/*0:1*/ then list args/*0:1*/ else [args/*0:1*/]; s/*0:01*/,_/*0:1*/ = catch error_handler/*1*/ (foldl do_sprintf/*2*/ ("",args/*1:*/)$printf_split_format format/*2:01*/) { - rule #0: s,_ = catch error_handler (foldl do_sprintf ("",args)$printf_split_format format) - state 0: #0 - <app> state 1 - state 1: #0 - <app> state 2 - state 2: #0 - , state 3 - state 3: #0 - <var> state 4 - state 4: #0 - <var> state 5 - state 5: #0 -} { - rule #0: args = if tuplep args then list args else [args] - state 0: #0 - <var> state 1 - state 1: #0 -} end with error_handler (printf_error res/*0:11*/::int) = pointer 0,[]; error_handler x/*0:1*/ = throw x/*0:1*/ { - rule #0: error_handler (printf_error res::int) = pointer 0,[] - rule #1: error_handler x = throw x - state 0: #0 #1 - <var> state 1 - <app> state 2 - state 1: #1 - state 2: #0 #1 - <var> state 3 - printf_error state 5 - state 3: #1 - <var> state 4 - state 4: #1 - state 5: #0 #1 - <var> state 6 - <var>::int state 7 - state 6: #1 - state 7: #0 #1 -}; do_sprintf (u/*0:0101*/,arg/*0:01101*/:args/*0:0111*/) (printf_format_spec t/*0:101*/ s/*0:11*/) = u/*0:*/,args/*4:0111*/ when size/*0:*/ = case t/*0:101*/,arg/*0:01101*/ of "s",x/*0:1*/::string = #s/*1:11*/+#x/*0:1*/+1000; _/*0:*/ = 64 { - rule #0: "s",x::string = #s+#x+1000 - rule #1: _ = 64 - state 0: #0 #1 - <var> state 1 - <app> state 2 - state 1: #1 - state 2: #0 #1 - <var> state 3 - <app> state 5 - state 3: #1 - <var> state 4 - state 4: #1 - state 5: #0 #1 - <var> state 6 - , state 9 - state 6: #1 - <var> state 7 - state 7: #1 - <var> state 8 - state 8: #1 - state 9: #0 #1 - <var> state 10 - "s"::string state 12 - state 10: #1 - <var> state 11 - state 11: #1 - state 12: #0 #1 - <var> state 13 - <var>::string state 14 - state 13: #1 - state 14: #0 #1 -} end; buf/*0:*/ = check_buf/*2*/ (malloc size/*0:*/); res/*0:*/ = case t/*2:101*/,arg/*2:01101*/ of "d",x/*0:1*/::int = pure_snprintf_int buf/*1:*/ size/*2:*/ s/*3:11*/ x/*0:1*/; "d",x/*0:1*/::bigint = pure_snprintf_int buf/*1:*/ size/*2:*/ s/*3:11*/ (int x/*0:1*/); "g",x/*0:1*/::double = pure_snprintf_double buf/*1:*/ size/*2:*/ s/*3:11*/ x/*0:1*/; "s",x/*0:1*/::string = pure_snprintf_string buf/*1:*/ size/*2:*/ s/*3:11*/ x/*0:1*/; "p",x/*0:1*/::string = pure_snprintf_pointer buf/*1:*/ size/*2:*/ s/*3:11*/ x/*0:1*/; "p",x/*0:1*/ = pure_snprintf_pointer buf/*1:*/ size/*2:*/ s/*3:11*/ x/*0:1*/; _/*0:*/ = throw (printf_value_error s/*4:11*/ arg/*4:01101*/) when _/*0:*/ = free buf/*1:*/ { - rule #0: _ = free buf - state 0: #0 - <var> state 1 - state 1: #0 -} end { - rule #0: "d",x::int = pure_snprintf_int buf size s x - rule #1: "d",x::bigint = pure_snprintf_int buf size s (int x) - rule #2: "g",x::double = pure_snprintf_double buf size s x - rule #3: "s",x::string = pure_snprintf_string buf size s x - rule #4: "p",x::string = pure_snprintf_pointer buf size s x - rule #5: "p",x = pure_snprintf_pointer buf size s x - rule #6: _ = throw (printf_value_error s arg) when _ = free buf end - state 0: #0 #1 #2 #3 #4 #5 #6 - <var> state 1 - <app> state 2 - state 1: #6 - state 2: #0 #1 #2 #3 #4 #5 #6 - <var> state 3 - <app> state 5 - state 3: #6 - <var> state 4 - state 4: #6 - state 5: #0 #1 #2 #3 #4 #5 #6 - <var> state 6 - , state 9 - state 6: #6 - <var> state 7 - state 7: #6 - <var> state 8 - state 8: #6 - state 9: #0 #1 #2 #3 #4 #5 #6 - <var> state 10 - "d"::string state 12 - "g"::string state 16 - "s"::string state 19 - "p"::string state 22 - state 10: #6 - <var> state 11 - state 11: #6 - state 12: #0 #1 #6 - <var> state 13 - <var>::int state 14 - <var>::bigint state 15 - state 13: #6 - state 14: #0 #6 - state 15: #1 #6 - state 16: #2 #6 - <var> state 17 - <var>::double state 18 - state 17: #6 - state 18: #2 #6 - state 19: #3 #6 - <var> state 20 - <var>::string state 21 - state 20: #6 - state 21: #3 #6 - state 22: #4 #5 #6 - <var> state 23 - <var>::string state 24 - <var> state 25 - state 23: #6 - state 24: #4 #6 - state 25: #5 #6 -} end; u/*0:*/ = if res/*0:*/>=0 then u/*3:0101*/+cstring buf/*1:*/ else throw printf_error res/*1:*/ when _/*0:*/ = free buf/*1:*/ { - rule #0: _ = free buf - state 0: #0 - <var> state 1 - state 1: #0 -} end { - rule #0: u = if res>=0 then u+cstring buf else throw printf_error res when _ = free buf end - state 0: #0 - <var> state 1 - state 1: #0 -} { - rule #0: res = case t,arg of "d",x::int = pure_snprintf_int buf size s x; "d",x::bigint = pure_snprintf_int buf size s (int x); "g",x::double = pure_snprintf_double buf size s x; "s",x::string = pure_snprintf_string buf size s x; "p",x::string = pure_snprintf_pointer buf size s x; "p",x = pure_snprintf_pointer buf size s x; _ = throw (printf_value_error s arg) when _ = free buf end end - state 0: #0 - <var> state 1 - state 1: #0 -} { - rule #0: buf = check_buf (malloc size) - state 0: #0 - <var> state 1 - state 1: #0 -} { - rule #0: size = case t,arg of "s",x::string = #s+#x+1000; _ = 64 end - state 0: #0 - <var> state 1 - state 1: #0 -} end; do_sprintf (u/*0:0101*/,args/*0:011*/) (printf_format_str s/*0:11*/) = u/*0:*/,args/*4:011*/ when size/*0:*/ = #s/*0:11*/+1000; buf/*0:*/ = check_buf/*2*/ (malloc size/*0:*/); res/*0:*/ = pure_snprintf buf/*0:*/ size/*1:*/ s/*2:11*/; u/*0:*/ = if res/*0:*/>=0 then u/*3:0101*/+cstring buf/*1:*/ else throw printf_error res/*1:*/ when _/*0:*/ = free buf/*1:*/ { - rule #0: _ = free buf - state 0: #0 - <var> state 1 - state 1: #0 -} end { - rule #0: u = if res>=0 then u+cstring buf else throw printf_error res when _ = free buf end - state 0: #0 - <var> state 1 - state 1: #0 -} { - rule #0: res = pure_snprintf buf size s - state 0: #0 - <var> state 1 - state 1: #0 -} { - rule #0: buf = check_buf (malloc size) - state 0: #0 - <var> state 1 - state 1: #0 -} { - rule #0: size = #s+1000 - state 0: #0 - <var> state 1 - state 1: #0 -} end; do_sprintf (u/*0:0101*/,_/*0:011*/) _/*0:1*/ = throw printf_arg_error { - rule #0: do_sprintf (u,arg:args) (printf_format_spec t s) = u,args when size = case t,arg of "s",x::string = #s+#x+1000; _ = 64 end; buf = check_buf (malloc size); res = case t,arg of "d",x::int = pure_snprintf_int buf size s x; "d",x::bigint = pure_snprintf_int buf size s (int x); "g",x::double = pure_snprintf_double buf size s x; "s",x::string = pure_snprintf_string buf size s x; "p",x::string = pure_snprintf_pointer buf size s x; "p",x = pure_snprintf_pointer buf size s x; _ = throw (printf_value_error s arg) when _ = free buf end end; u = if res>=0 then u+cstring buf else throw printf_error res when _ = free buf end end - rule #1: do_sprintf (u,args) (printf_format_str s) = u,args when size = #s+1000; buf = check_buf (malloc size); res = pure_snprintf buf size s; u = if res>=0 then u+cstring buf else throw printf_error res when _ = free buf end end - rule #2: do_sprintf (u,_) _ = throw printf_arg_error - state 0: #0 #1 #2 - <app> state 1 - state 1: #0 #1 #2 - <app> state 2 - state 2: #0 #1 #2 - , state 3 - state 3: #0 #1 #2 - <var> state 4 - state 4: #0 #1 #2 - <var> state 5 - <app> state 12 - state 5: #1 #2 - <var> state 6 - <app> state 7 - state 6: #2 - state 7: #1 #2 - <var> state 8 - printf_format_str state 10 - state 8: #2 - <var> state 9 - state 9: #2 - state 10: #1 #2 - <var> state 11 - state 11: #1 #2 - state 12: #0 #1 #2 - <var> state 13 - <app> state 21 - state 13: #1 #2 - <var> state 14 - state 14: #1 #2 - <var> state 15 - <app> state 16 - state 15: #2 - state 16: #1 #2 - <var> state 17 - printf_format_str state 19 - state 17: #2 - <var> state 18 - state 18: #2 - state 19: #1 #2 - <var> state 20 - state 20: #1 #2 - state 21: #0 #1 #2 - <var> state 22 - : state 31 - state 22: #1 #2 - <var> state 23 - state 23: #1 #2 - <var> state 24 - state 24: #1 #2 - <var> state 25 - <app> state 26 - state 25: #2 - state 26: #1 #2 - <var> state 27 - printf_format_str state 29 - state 27: #2 - <var> state 28 - state 28: #2 - state 29: #1 #2 - <var> state 30 - state 30: #1 #2 - state 31: #0 #1 #2 - <var> state 32 - state 32: #0 #1 #2 - <var> state 33 - state 33: #0 #1 #2 - <var> state 34 - <app> state 35 - state 34: #2 - state 35: #0 #1 #2 - <var> state 36 - <app> state 38 - printf_format_str state 45 - state 36: #2 - <var> state 37 - state 37: #2 - state 38: #0 #2 - <var> state 39 - printf_format_spec state 42 - state 39: #2 - <var> state 40 - state 40: #2 - <var> state 41 - state 41: #2 - state 42: #0 #2 - <var> state 43 - state 43: #0 #2 - <var> state 44 - state 44: #0 #2 - state 45: #1 #2 - <var> state 46 - state 46: #1 #2 -}; check_buf buf/*0:1*/ = throw printf_malloc_error if null buf/*0:1*/; check_buf buf/*0:1*/ = buf/*0:1*/ { - rule #0: check_buf buf = throw printf_malloc_error if null buf - rule #1: check_buf buf = buf - state 0: #0 #1 - <var> state 1 - state 1: #0 #1 -} end; -scanf format/*0:1*/::string = fscanf stdin format/*0:1*/; -fscanf fp/*0:01*/ format/*0:1*/::string = tuple$reverse ret/*0:1*/ when _/*0:01*/,ret/*0:1*/ = catch error_handler/*0*/ (foldl (do_fscanf/*1*/ fp/*1:01*/) (0,[])$scanf_split_format format/*1:1*/) { - rule #0: _,ret = catch error_handler (foldl (do_fscanf fp) (0,[])$scanf_split_format format) - state 0: #0 - <app> state 1 - state 1: #0 - <app> state 2 - state 2: #0 - , state 3 - state 3: #0 - <var> state 4 - state 4: #0 - <var> state 5 - state 5: #0 -} end with error_handler (scanf_error ret/*0:11*/) = throw (scanf_error (tuple$reverse ret/*0:11*/)); error_handler x/*0:1*/ = throw x/*0:1*/ { - rule #0: error_handler (scanf_error ret) = throw (scanf_error (tuple$reverse ret)) - rule #1: error_handler x = throw x - state 0: #0 #1 - <var> state 1 - <app> state 2 - state 1: #1 - state 2: #0 #1 - <var> state 3 - scanf_error state 5 - state 3: #1 - <var> state 4 - state 4: #1 - state 5: #0 #1 - <var> state 6 - state 6: #0 #1 -}; check_buf buf/*0:1*/ = throw scanf_malloc_error if null buf/*0:1*/; check_buf buf/*0:1*/ = buf/*0:1*/ { - rule #0: check_buf buf = throw scanf_malloc_error if null buf - rule #1: check_buf buf = buf - state 0: #0 #1 - <var> state 1 - state 1: #0 #1 -}; do_fscanf fp/*0:001*/ (nread/*0:0101*/,ret/*0:011*/) (scanf_format_spec t/*0:101*/ s/*0:11*/) = nread/*7:0101*/+res/*3:*/,ret/*0:*/ when size/*0:01*/,s/*0:1*/ = if t/*0:101*/=="s" then guestimate/*1*/ s/*0:11*/ else 16,s/*0:11*/; buf/*0:*/ = check_buf/*2*/ (calloc size/*0:01*/ 1); res/*0:*/ = case t/*2:101*/ of "n" = pure_fscanf_int fp/*3:001*/ s/*2:1*/ buf/*1:*/; "d" = pure_fscanf_int fp/*3:001*/ s/*2:1*/ buf/*1:*/; "g" = pure_fscanf_double fp/*3:001*/ s/*2:1*/ buf/*1:*/; "s" = pure_fscanf_string fp/*3:001*/ s/*2:1*/ buf/*1:*/; "p" = pure_fscanf_pointer fp/*3:001*/ s/*2:1*/ buf/*1:*/; _/*0:*/ = throw (this_cant_happen ret/*3:011*/) { - rule #0: "n" = pure_fscanf_int fp s buf - rule #1: "d" = pure_fscanf_int fp s buf - rule #2: "g" = pure_fscanf_double fp s buf - rule #3: "s" = pure_fscanf_string fp s buf - rule #4: "p" = pure_fscanf_pointer fp s buf - rule #5: _ = throw (this_cant_happen ret) - state 0: #0 #1 #2 #3 #4 #5 - <var> state 1 - "n"::string state 2 - "d"::string state 3 - "g"::string state 4 - "s"::string state 5 - "p"::string state 6 - state 1: #5 - state 2: #0 #5 - state 3: #1 #5 - state 4: #2 #5 - state 5: #3 #5 - state 6: #4 #5 -} end; res/*0:*/ = if res/*0:*/>=0 then res/*0:*/ else throw (scanf_error ret/*4:011*/) when _/*0:*/ = free buf/*1:*/ { - rule #0: _ = free buf - state 0: #0 - <var> state 1 - state 1: #0 -} end; val/*0:*/ = case t/*4:101*/ of "n" = nread/*5:0101*/+get_int buf/*3:*/; "d" = get_int buf/*3:*/; "g" = get_double buf/*3:*/; "s" = cstring buf/*3:*/; "p" = get_pointer buf/*3:*/; _/*0:*/ = throw (this_cant_happen ret/*5:011*/) { - rule #0: "n" = nread+get_int buf - rule #1: "d" = get_int buf - rule #2: "g" = get_double buf - rule #3: "s" = cstring buf - rule #4: "p" = get_pointer buf - rule #5: _ = throw (this_cant_happen ret) - state 0: #0 #1 #2 #3 #4 #5 - <var> state 1 - "n"::string state 2 - "d"::string state 3 - "g"::string state 4 - "s"::string state 5 - "p"::string state 6 - state 1: #5 - state 2: #0 #5 - state 3: #1 #5 - state 4: #2 #5 - state 5: #3 #5 - state 6: #4 #5 -} end; _/*0:*/ = if t/*5:101*/=="s" then () else free buf/*3:*/; ret/*0:*/ = val/*1:*/:ret/*6:011*/ { - rule #0: ret = val:ret - state 0: #0 - <var> state 1 - state 1: #0 -} { - rule #0: _ = if t=="s" then () else free buf - state 0: #0 - <var> state 1 - state 1: #0 -} { - rule #0: val = case t of "n" = nread+get_int buf; "d" = get_int buf; "g" = get_double buf; "s" = cstring buf; "p" = get_pointer buf; _ = throw (this_cant_happen ret) end - state 0: #0 - <var> state 1 - state 1: #0 -} { - rule #0: res = if res>=0 then res else throw (scanf_error ret) when _ = free buf end - state 0: #0 - <var> state 1 - state 1: #0 -} { - rule #0: res = case t of "n" = pure_fscanf_int fp s buf; "d" = pure_fscanf_int fp s buf; "g" = pure_fscanf_double fp s buf; "s" = pure_fscanf_string fp s buf; "p" = pure_fscanf_pointer fp s buf; _ = throw (this_cant_happen ret) end - state 0: #0 - <var> state 1 - state 1: #0 -} { - rule #0: buf = check_buf (calloc size 1) - state 0: #0 - <var> state 1 - state 1: #0 -} { - rule #0: size,s = if t=="s" then guestimate s else 16,s - state 0: #0 - <app> state 1 - state 1: #0 - <app> state 2 - state 2: #0 - , state 3 - state 3: #0 - <var> state 4 - state 4: #0 - <var> state 5 - state 5: #0 -} end; do_fscanf fp/*0:001*/ (nread/*0:0101*/,ret/*0:011*/) (scanf_format_str s/*0:11*/) = nread/*2:0101*/+res/*1:*/,ret/*0:*/ when res/*0:*/ = pure_fscanf fp/*0:001*/ s/*0:11*/; ret/*0:*/ = if res/*0:*/>=0 then ret/*1:011*/ else throw (scanf_error ret/*1:011*/) { - rule #0: ret = if res>=0 then ret else throw (scanf_error ret) - state 0: #0 - <var> state 1 - state 1: #0 -} { - rule #0: res = pure_fscanf fp s - state 0: #0 - <var> state 1 - state 1: #0 -} end; do_fscanf _/*0:001*/ (_/*0:0101*/,ret/*0:011*/) _/*0:1*/ = throw (this_cant_happen ret/*0:011*/) { - rule #0: do_fscanf fp (nread,ret) (scanf_format_spec t s) = nread+res,ret when size,s = if t=="s" then guestimate s else 16,s; buf = check_buf (calloc size 1); res = case t of "n" = pure_fscanf_int fp s buf; "d" = pure_fscanf_int fp s buf; "g" = pure_fscanf_double fp s buf; "s" = pure_fscanf_string fp s buf; "p" = pure_fscanf_pointer fp s buf; _ = throw (this_cant_happen ret) end; res = if res>=0 then res else throw (scanf_error ret) when _ = free buf end; val = case t of "n" = nread+get_int buf; "d" = get_int buf; "g" = get_double buf; "s" = cstring buf; "p" = get_pointer buf; _ = throw (this_cant_happen ret) end; _ = if t=="s" then () else free buf; ret = val:ret end - rule #1: do_fscanf fp (nread,ret) (scanf_format_str s) = nread+res,ret when res = pure_fscanf fp s; ret = if res>=0 then ret else throw (scanf_error ret) end - rule #2: do_fscanf _ (_,ret) _ = throw (this_cant_happen ret) - state 0: #0 #1 #2 - <var> state 1 - state 1: #0 #1 #2 - <app> state 2 - state 2: #0 #1 #2 - <app> state 3 - state 3: #0 #1 #2 - , state 4 - state 4: #0 #1 #2 - <var> state 5 - state 5: #0 #1 #2 - <var> state 6 - state 6: #0 #1 #2 - <var> state 7 - <app> state 8 - state 7: #2 - state 8: #0 #1 #2 - <var> state 9 - <app> state 11 - scanf_format_str state 18 - state 9: #2 - <var> state 10 - state 10: #2 - state 11: #0 #2 - <var> state 12 - scanf_format_spec state 15 - state 12: #2 - <var> state 13 - state 13: #2 - <var> state 14 - state 14: #2 - state 15: #0 #2 - <var> state 16 - state 16: #0 #2 - <var> state 17 - state 17: #0 #2 - state 18: #1 #2 - <var> state 19 - state 19: #1 #2 -}; guestimate format/*0:1*/ = n/*0:01*/,format/*0:1*/ when 1,0,_/*0:1101*/,1,s/*0:1111*/ = regex "^%([0-9]*)" REG_EXTENDED format/*0:1*/ 0; n/*0:01*/,format/*0:1*/ = if null s/*0:1111*/ then 1025,"%1024"+tail format/*1:1*/ else eval s/*0:1111*/+1,format/*1:1*/ { - rule #0: n,format = if null s then 1025,"%1024"+tail format else eval s+1,format - state 0: #0 - <app> state 1 - state 1: #0 - <app> state 2 - state 2: #0 - , state 3 - state 3: #0 - <var> state 4 - state 4: #0 - <var> state 5 - state 5: #0 -} { - rule #0: 1,0,_,1,s = regex "^%([0-9]*)" REG_EXTENDED format 0 - state 0: #0 - <app> state 1 - state 1: #0 - <app> state 2 - state 2: #0 - , state 3 - state 3: #0 - 1::int state 4 - state 4: #0 - <app> state 5 - state 5: #0 - <app> state 6 - state 6: #0 - , state 7 - state 7: #0 - 0::int state 8 - state 8: #0 - <app> state 9 - state 9: #0 - <app> state 10 - state 10: #0 - , state 11 - state 11: #0 - <var> state 12 - state 12: #0 - <app> state 13 - state 13: #0 - <app> state 14 - state 14: #0 - , state 15 - state 15: #0 - 1::int state 16 - state 16: #0 - <var> state 17 - state 17: #0 -} end { - rule #0: guestimate format = n,format when 1,0,_,1,s = regex "^%([0-9]*)" REG_EXTENDED format 0; n,format = if null s then 1025,"%1024"+tail format else eval s+1,format end - state 0: #0 - <var> state 1 - state 1: #0 -} end; -scanf_split_format format/*0:1*/ = regexg analyze/*0*/ "(%[*]?[0-9]*([cdiouxXneEfgsp]|\\[\\^?\\]?[^]]+\\]))|(%)|([^%]|%%)+" REG_EXTENDED format/*0:1*/ 0 with analyze info/*0:1*/ = if p/*1:01*/>=0&&u/*2:1*/!1!="*" then scanf_format_spec t/*0:*/ (kludge/*5*/ t/*0:*/ u/*3:1*/) when t/*0:*/ = format_type/*4*/ (last u/*2:1*/) { - rule #0: t = format_type (last u) - state 0: #0 - <var> state 1 - state 1: #0 -} end else if q/*0:01*/>=0 then throw (scanf_format_error q/*0:01*/) else scanf_format_str u/*2:1*/ when _/*0:01*/,u/*0:1*/ = reg 0 info/*0:1*/; p/*0:01*/,_/*0:1*/ = reg 1 info/*1:1*/; q/*0:01*/,_/*0:1*/ = reg 3 info/*2:1*/ { - rule #0: q,_ = reg 3 info - state 0: #0 - <app> state 1 - state 1: #0 - <app> state 2 - state 2: #0 - , state 3 - state 3: #0 - <var> state 4 - state 4: #0 - <var> state 5 - state 5: #0 -} { - rule #0: p,_ = reg 1 info - state 0: #0 - <app> state 1 - state 1: #0 - <app> state 2 - state 2: #0 - , state 3 - state 3: #0 - <var> state 4 - state 4: #0 - <var> state 5 - state 5: #0 -} { - rule #0: _,u = reg 0 info - state 0: #0 - <app> state 1 - state 1: #0 - <app> state 2 - state 2: #0 - , state 3 - state 3: #0 - <var> state 4 - state 4: #0 - <var> state 5 - state 5: #0 -} end { - rule #0: analyze info = if p>=0&&u!1!="*" then scanf_format_spec t (kludge t u) when t = format_type (last u) end else if q>=0 then throw (scanf_format_error q) else scanf_format_str u when _,u = reg 0 info; p,_ = reg 1 info; q,_ = reg 3 info end - state 0: #0 - <var> state 1 - state 1: #0 -}; format_type x/*0:1*/ = if x/*0:1*/=="n" then "n" else if index "diouxX" x/*0:1*/>=0 then "d" else if index "eEfg" x/*0:1*/>=0 then "g" else if x/*0:1*/=="]"||x/*0:1*/=="c" then "s" else x/*0:1*/ { - rule #0: format_type x = if x=="n" then "n" else if index "diouxX" x>=0 then "d" else if index "eEfg" x>=0 then "g" else if x=="]"||x=="c" then "s" else x - state 0: #0 - <var> state 1 - state 1: #0 -}; kludge "g" u/*0:1*/ = init u/*0:1*/+"l"+last u/*0:1*/; kludge _/*0:01*/ u/*0:1*/ = u/*0:1*/ { - rule #0: kludge "g" u = init u+"l"+last u - rule #1: kludge _ u = u - state 0: #0 #1 - <var> state 1 - "g"::string state 3 - state 1: #1 - <var> state 2 - state 2: #1 - state 3: #0 #1 - <var> state 4 - state 4: #0 #1 -} end; -sscanf s/*0:01*/::string format/*0:1*/::string = tuple$reverse ret/*0:11*/ when _/*0:01*/,_/*0:101*/,ret/*0:11*/ = catch error_handler/*0*/ (foldl do_sscanf/*1*/ (s/*1:01*/,0,[])$scanf_split_format format/*1:1*/) { - rule #0: _,_,ret = catch error_handler (foldl do_sscanf (s,0,[])$scanf_split_format format) - state 0: #0 - <app> state 1 - state 1: #0 - <app> state 2 - state 2: #0 - , state 3 - state 3: #0 - <var> state 4 - state 4: #0 - <app> state 5 - state 5: #0 - <app> state 6 - state 6: #0 - , state 7 - state 7: #0 - <var> state 8 - state 8: #0 - <var> state 9 - state 9: #0 -} end with error_handler (scanf_error ret/*0:11*/) = throw (scanf_error (tuple$reverse ret/*0:11*/)); error_handler x/*0:1*/ = throw x/*0:1*/ { - rule #0: error_handler (scanf_error ret) = throw (scanf_error (tuple$reverse ret)) - rule #1: error_handler x = throw x - state 0: #0 #1 - <var> state 1 - <app> state 2 - state 1: #1 - state 2: #0 #1 - <var> state 3 - scanf_error state 5 - state 3: #1 - <var> state 4 - state 4: #1 - state 5: #0 #1 - <var> state 6 - state 6: #0 #1 -}; check_buf buf/*0:1*/ = throw scanf_malloc_error if null buf/*0:1*/; check_buf buf/*0:1*/ = buf/*0:1*/ { - rule #0: check_buf buf = throw scanf_malloc_error if null buf - rule #1: check_buf buf = buf - state 0: #0 #1 - <var> state 1 - state 1: #0 #1 -}; guestimate format/*0:1*/ = n/*0:01*/,format/*0:1*/ when 1,0,_/*0:1101*/,1,s/*0:1111*/ = regex "^%([0-9]*)" REG_EXTENDED format/*0:1*/ 0; n/*0:01*/,format/*0:1*/ = if null s/*0:1111*/ then 1025,"%1024"+tail format/*1:1*/ else eval s/*0:1111*/+1,format/*1:1*/ { - rule #0: n,format = if null s then 1025,"%1024"+tail format else eval s+1,format - state 0: #0 - <app> state 1 - state 1: #0 - <app> state 2 - state 2: #0 - , state 3 - state 3: #0 - <var> state 4 - state 4: #0 - <var> state 5 - state 5: #0 -} { - rule #0: 1,0,_,1,s = regex "^%([0-9]*)" REG_EXTENDED format 0 - state 0: #0 - <app> state 1 - state 1: #0 - <app> state 2 - state 2: #0 - , state 3 - state 3: #0 - 1::int state 4 - state 4: #0 - <app> state 5 - state 5: #0 - <app> state 6 - state 6: #0 - , state 7 - state 7: #0 - 0::int state 8 - state 8: #0 - <app> state 9 - state 9: #0 - <app> state 10 - state 10: #0 - , state 11 - state 11: #0 - <var> state 12 - state 12: #0 - <app> state 13 - state 13: #0 - <app> state 14 - state 14: #0 - , state 15 - state 15: #0 - 1::int state 16 - state 16: #0 - <var> state 17 - state 17: #0 -} end { - rule #0: guestimate format = n,format when 1,0,_,1,s = regex "^%([0-9]*)" REG_EXTENDED format 0; n,format = if null s then 1025,"%1024"+tail format else eval s+1,format end - state 0: #0 - <var> state 1 - state 1: #0 -}; do_sscanf (u/*0:0101*/,nread/*0:01101*/,ret/*0:0111*/) (scanf_format_spec t/*0:101*/ s/*0:11*/) = u/*0:*/,nread/*8:01101*/+res/*4:*/,ret/*1:*/ when size/*0:01*/,s/*0:1*/ = if t/*0:101*/=="s" then guestimate/*1*/ s/*0:11*/ else 16,s/*0:11*/; buf/*0:*/ = check_buf/*2*/ (calloc size/*0:01*/ 1); res/*0:*/ = case t/*2:101*/ of "n" = pure_sscanf_int u/*3:0101*/ s/*2:1*/ buf/*1:*/; "d" = pure_sscanf_int u/*3:0101*/ s/*2:1*/ buf/*1:*/; "g" = pure_sscanf_double u/*3:0101*/ s/*2:1*/ buf/*1:*/; "s" = pure_sscanf_string u/*3:0101*/ s/*2:1*/ buf/*1:*/; "p" = pure_sscanf_pointer u/*3:0101*/ s/*2:1*/ buf/*1:*/; _/*0:*/ = throw (this_cant_happen ret/*3:0111*/) { - rule #0: "n" = pure_sscanf_int u s buf - rule #1: "d" = pure_sscanf_int u s buf - rule #2: "g" = pure_sscanf_double u s buf - rule #3: "s" = pure_sscanf_string u s buf - rule #4: "p" = pure_sscanf_pointer u s buf - rule #5: _ = throw (this_cant_happen ret) - state 0: #0 #1 #2 #3 #4 #5 - <var> state 1 - "n"::string state 2 - "d"::string state 3 - "g"::string state 4 - "s"::string state 5 - "p"::string state 6 - state 1: #5 - state 2: #0 #5 - state 3: #1 #5 - state 4: #2 #5 - state 5: #3 #5 - state 6: #4 #5 -} end; res/*0:*/ = if res/*0:*/>=0 then res/*0:*/ else throw (scanf_error ret/*4:0111*/) when _/*0:*/ = free buf/*1:*/ { - rule #0: _ = free buf - state 0: #0 - <var> state 1 - state 1: #0 -} end; val/*0:*/ = case t/*4:101*/ of "n" = nread/*5:01101*/+get_int buf/*3:*/; "d" = get_int buf/*3:*/; "g" = get_double buf/*3:*/; "s" = cstring buf/*3:*/; "p" = get_pointer buf/*3:*/; _/*0:*/ = throw (this_cant_happen ret/*5:0111*/) { - rule #0: "n" = nread+get_int buf - rule #1: "d" = get_int buf - rule #2: "g" = get_double buf - rule #3: "s" = cstring buf - rule #4: "p" = get_pointer buf - rule #5: _ = throw (this_cant_happen ret) - state 0: #0 #1 #2 #3 #4 #5 - <var> state 1 - "n"::string state 2 - "d"::string state 3 - "g"::string state 4 - "s"::string state 5 - "p"::string state 6 - state 1: #5 - state 2: #0 #5 - state 3: #1 #5 - state 4: #2 #5 - state 5: #3 #5 - state 6: #4 #5 -} end; _/*0:*/ = if t/*5:101*/=="s" then () else free buf/*3:*/; ret/*0:*/ = val/*1:*/:ret/*6:0111*/; u/*0:*/ = drop res/*3:*/ u/*7:0101*/ { - rule #0: u = drop res u - state 0: #0 - <var> state 1 - state 1: #0 -} { - rule #0: ret = val:ret - state 0: #0 - <var> state 1 - state 1: #0 -} { - rule #0: _ = if t=="s" then () else free buf - state 0: #0 - <var> state 1 - state 1: #0 -} { - rule #0: val = case t of "n" = nread+get_int buf; "d" = get_int buf; "g" = get_double buf; "s" = cstring buf; "p" = get_pointer buf; _ = throw (this_cant_happen ret) end - state 0: #0 - <var> state 1 - state 1: #0 -} { - rule #0: res = if res>=0 then res else throw (scanf_error ret) when _ = free buf end - state 0: #0 - <var> state 1 - state 1: #0 -} { - rule #0: res = case t of "n" = pure_sscanf_int u s buf; "d" = pure_sscanf_int u s buf; "g" = pure_sscanf_double u s buf; "s" = pure_sscanf_string u s buf; "p" = pure_sscanf_pointer u s buf; _ = throw (this_cant_happen ret) end - state 0: #0 - <var> state 1 - state 1: #0 -} { - rule #0: buf = check_buf (calloc size 1) - state 0: #0 - <var> state 1 - state 1: #0 -} { - rule #0: size,s = if t=="s" then guestimate s else 16,s - state 0: #0 - <app> state 1 - state 1: #0 - <app> state 2 - state 2: #0 - , state 3 - state 3: #0 - <var> state 4 - state 4: #0 - <var> state 5 - state 5: #0 -} end; do_sscanf (u/*0:0101*/,nread/*0:01101*/,ret/*0:0111*/) (scanf_format_str s/*0:11*/) = u/*0:*/,nread/*3:01101*/+res/*2:*/,ret/*1:*/ when res/*0:*/ = pure_sscanf u/*0:0101*/ s/*0:11*/; ret/*0:*/ = if res/*0:*/>=0 then ret/*1:0111*/ else throw (scanf_error ret/*1:0111*/); u/*0:*/ = drop res/*1:*/ u/*2:0101*/ { - rule #0: u = drop res u - state 0: #0 - <var> state 1 - state 1: #0 -} { - rule #0: ret = if res>=0 then ret else throw (scanf_error ret) - state 0: #0 - <var> state 1 - state 1: #0 -} { - rule #0: res = pure_sscanf u s - state 0: #0 - <var> state 1 - state 1: #0 -} end; do_sscanf (_/*0:0101*/,_/*0:01101*/,ret/*0:0111*/) _/*0:1*/ = throw (this_cant_happen ret/*0:0111*/) { - rule #0: do_sscanf (u,nread,ret) (scanf_format_spec t s) = u,nread+res,ret when size,s = if t=="s" then guestimate s else 16,s; buf = check_buf (calloc size 1); res = case t of "n" = pure_sscanf_int u s buf; "d" = pure_sscanf_int u s buf; "g" = pure_sscanf_double u s buf; "s" = pure_sscanf_string u s buf; "p" = pure_sscanf_pointer u s buf; _ = throw (this_cant_happen ret) end; res = if res>=0 then res else throw (scan... [truncated message content] |