[pure-lang-svn] SF.net SVN: pure-lang: [67] pure/trunk
Status: Beta
Brought to you by:
agraef
From: <ag...@us...> - 2008-05-08 22:00:39
|
Revision: 67 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=67&view=rev Author: agraef Date: 2008-05-08 15:00:36 -0700 (Thu, 08 May 2008) Log Message: ----------- Changed 'G' bigint suffix to 'L'. Modified Paths: -------------- pure/trunk/ChangeLog pure/trunk/examples/hello.pure pure/trunk/lexer.ll pure/trunk/printer.cc pure/trunk/pure.1 pure/trunk/test/test1.log pure/trunk/test/test8.log pure/trunk/test/test8.pure Modified: pure/trunk/ChangeLog =================================================================== --- pure/trunk/ChangeLog 2008-05-06 17:49:50 UTC (rev 66) +++ pure/trunk/ChangeLog 2008-05-08 22:00:36 UTC (rev 67) @@ -1,3 +1,10 @@ +2008-05-09 Albert Graef <Dr....@t-...> + + * lexer.ll, printer.cc, etc.: Change the "G" suffix to denote + bigints to "L" ("G" can too easily be mistaken for a digit; also, + Python uses the same "L" notation for bigints). Reported by Eddie + Rucker. + 2008-05-06 Albert Graef <Dr....@t-...> * lib/primitives.pure: Made the pow function work with all Modified: pure/trunk/examples/hello.pure =================================================================== --- pure/trunk/examples/hello.pure 2008-05-06 17:49:50 UTC (rev 66) +++ pure/trunk/examples/hello.pure 2008-05-08 22:00:36 UTC (rev 67) @@ -115,7 +115,7 @@ // constant stack space. It also uses bigints so that the arithmetically // correct values are computed for large n. -fib3 n = a when a, b = fibs (0G, 1G) n end +fib3 n = a when a, b = fibs (0L, 1L) n end with fibs (a, b) n = a, b if n<=0; = fibs (b, a+b) (n-1) otherwise; end; Modified: pure/trunk/lexer.ll =================================================================== --- pure/trunk/lexer.ll 2008-05-06 17:49:50 UTC (rev 66) +++ pure/trunk/lexer.ll 2008-05-08 22:00:36 UTC (rev 67) @@ -604,12 +604,12 @@ return token::BIGINT; } } -{int}G { +{int}L { mpz_t *z = (mpz_t*)malloc(sizeof(mpz_t)); mpz_init(*z); yytext[yyleng-1] = 0; mpz_set_str(*z, yytext, 0); - yytext[yyleng-1] = 'G'; + yytext[yyleng-1] = 'L'; yylval->zval = z; return token::BIGINT; } Modified: pure/trunk/printer.cc =================================================================== --- pure/trunk/printer.cc 2008-05-06 17:49:50 UTC (rev 66) +++ pure/trunk/printer.cc 2008-05-08 22:00:36 UTC (rev 67) @@ -202,7 +202,7 @@ return os << x.ival(); case EXPR::BIGINT: { char *s = mpz_get_str(NULL, 10, x.zval()); - os << s << "G"; free(s); + os << s << "L"; free(s); return os; } case EXPR::DBL: { @@ -439,7 +439,7 @@ return os << " state " << tr.st->s << endl; case EXPR::BIGINT: { char *s = mpz_get_str(NULL, 10, tr.z); - os << "\t" << s << "G"; + os << "\t" << s << "L"; print_ttag(os, tr.ttag); os << " state " << tr.st->s << endl; free(s); @@ -621,7 +621,7 @@ return os << x->data.i; case EXPR::BIGINT: { char *s = mpz_get_str(NULL, 10, x->data.z); - os << s << "G"; free(s); + os << s << "L"; free(s); return os; } case EXPR::DBL: { Modified: pure/trunk/pure.1 =================================================================== --- pure/trunk/pure.1 2008-05-06 17:49:50 UTC (rev 66) +++ pure/trunk/pure.1 2008-05-08 22:00:36 UTC (rev 67) @@ -193,13 +193,12 @@ syntax differs in some minor ways, as discussed in the following. First, there is a special notation for denoting bigints. Note that an integer constant that is too large to fit into a machine integer will be interpreted as a bigint -automatically. Moreover, an integer literal immediately followed by the -uppercase letter ``G'' (mnemonic: ``biG'' or ``GMP'' integer) will always be -interpreted as a bigint constant, even if it fits into a machine integer. This -``big G'' notation is also used when printing bigint constants. Second, -character escapes in Pure strings have a more flexible syntax borrowed from -the author's Q language, which provides notations to specify any Unicode -character. In particular, the notation +automatically. Moreover, as in Python an integer literal immediately followed +by the uppercase letter ``L'' will always be interpreted as a bigint constant, +even if it fits into a machine integer. This notation is also used when +printing bigint constants. Second, character escapes in Pure strings have a +more flexible syntax borrowed from the author's Q language, which provides +notations to specify any Unicode character. In particular, the notation .BR \e\fIn\fP , where \fIn\fP is an integer literal written in decimal (no prefix), hexadecimal (`0x' prefix) or octal (`0' prefix) notation, denotes the Unicode @@ -1052,7 +1051,7 @@ have to provide equations for both. This also applies to equations matching against constant values of these types; in particular, a small integer constant like `0' only matches machine integers, not bigints; for the latter -you'll have to use the ``big G'' notation `0G'. +you'll have to use the ``big L'' notation `0L'. .PP .B External C functions. The interpreter always takes your Modified: pure/trunk/test/test1.log =================================================================== --- pure/trunk/test/test1.log 2008-05-06 17:49:50 UTC (rev 66) +++ pure/trunk/test/test1.log 2008-05-08 22:00:36 UTC (rev 67) @@ -92,7 +92,7 @@ state 2: #1 #2 } fact 50; -30414093201713378043612608166064768844377641568960512000000000000G +30414093201713378043612608166064768844377641568960512000000000000L fib1 0 = 0; fib1 1 = 1; fib1 n/*0:1*/ = fib1 (n/*0:1*/-2)+fib1 (n/*0:1*/-1) if n/*0:1*/>1; Modified: pure/trunk/test/test8.log =================================================================== --- pure/trunk/test/test8.log 2008-05-06 17:49:50 UTC (rev 66) +++ pure/trunk/test/test8.log 2008-05-08 22:00:36 UTC (rev 67) @@ -1,7 +1,7 @@ Binomial n/*0:01*/ k/*0:1*/ = Binomial n/*0:01*/ (n/*0:01*/-k/*0:1*/) if n/*0:01*/-k/*0:1*/<k/*0:1*/; -Binomial n/*0:01*/ 0G = 1G; +Binomial n/*0:01*/ 0L = 1L; Binomial n/*0:01*/ 0 = 1; -Binomial n/*0:01*/ 1G = n/*0:01*/; +Binomial n/*0:01*/ 1L = n/*0:01*/; Binomial n/*0:01*/ 1 = n/*0:01*/; Binomial n/*0:01*/ k/*0:1*/ = Binomial nm2/*0:*/ (k/*1:1*/-2)+2*Binomial nm2/*0:*/ (k/*1:1*/-1)+Binomial nm2/*0:*/ k/*1:1*/ when nm2/*0:*/ = n/*0:01*/-2 { rule #0: nm2 = n-2 @@ -11,9 +11,9 @@ } end; { rule #0: Binomial n k = Binomial n (n-k) if n-k<k - rule #1: Binomial n 0G = 1G + rule #1: Binomial n 0L = 1L rule #2: Binomial n 0 = 1 - rule #3: Binomial n 1G = n + rule #3: Binomial n 1L = n rule #4: Binomial n 1 = n rule #5: Binomial n k = Binomial nm2 (k-2)+2*Binomial nm2 (k-1)+Binomial nm2 k when nm2 = n-2 end state 0: #0 #1 #2 #3 #4 #5 @@ -22,8 +22,8 @@ <var> state 2 0::int state 3 1::int state 4 - 0G::bigint state 5 - 1G::bigint state 6 + 0L::bigint state 5 + 1L::bigint state 6 state 2: #0 #5 state 3: #0 #2 #5 state 4: #0 #4 #5 @@ -32,5 +32,5 @@ } Binomial 5 2; 10 -Binomial 5G 2G; -10G +Binomial 5L 2L; +10L Modified: pure/trunk/test/test8.pure =================================================================== --- pure/trunk/test/test8.pure 2008-05-06 17:49:50 UTC (rev 66) +++ pure/trunk/test/test8.pure 2008-05-08 22:00:36 UTC (rev 67) @@ -1,7 +1,7 @@ Binomial n k = Binomial n (n-k) if n-k < k; -Binomial n 0G = 1G; +Binomial n 0L = 1L; Binomial n 0 = 1; -Binomial n 1G = n; +Binomial n 1L = n; Binomial n 1 = n; Binomial n k = Binomial nm2 (k-2) + @@ -10,4 +10,4 @@ when nm2 = n-2 end; Binomial 5 2; -Binomial 5G 2G; +Binomial 5L 2L; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |