[pure-lang-svn] SF.net SVN: pure-lang:[539] pure/trunk
Status: Beta
Brought to you by:
agraef
From: <ag...@us...> - 2008-08-19 08:01:13
|
Revision: 539 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=539&view=rev Author: agraef Date: 2008-08-19 08:01:20 +0000 (Tue, 19 Aug 2008) Log Message: ----------- Renamed the 'def' keyword to 'const'. Modified Paths: -------------- pure/trunk/ChangeLog pure/trunk/etc/pure-mode.el.in pure/trunk/etc/pure.lang pure/trunk/etc/pure.vim pure/trunk/etc/pure.xml pure/trunk/examples/hello.pure pure/trunk/examples/libor/date.pure pure/trunk/interpreter.cc pure/trunk/lexer.ll pure/trunk/lib/math.pure pure/trunk/lib/prelude.pure pure/trunk/parser.yy pure/trunk/printer.cc pure/trunk/pure.cc pure/trunk/test/prelude.log pure/trunk/test/test013.log pure/trunk/test/test013.pure Modified: pure/trunk/ChangeLog =================================================================== --- pure/trunk/ChangeLog 2008-08-19 07:12:56 UTC (rev 538) +++ pure/trunk/ChangeLog 2008-08-19 08:01:20 UTC (rev 539) @@ -1,3 +1,11 @@ +2008-08-19 Albert Graef <Dr....@t-...> + + * parser.yy, lexer.ll, printer.cc, etc.: Renamed the 'def' keyword + to 'const', as originally proposed by Eddie Rucker. ('def' is + still a reserved keyword, since it's soon going to be used for + macro definitions.) Scripts and syntax highlighting files in the + distribution have been updated accordingly. + 2008-08-18 Albert Graef <Dr....@t-...> * interpreter.cc (codegen): Generate tail-recursive code for Modified: pure/trunk/etc/pure-mode.el.in =================================================================== --- pure/trunk/etc/pure-mode.el.in 2008-08-19 07:12:56 UTC (rev 538) +++ pure/trunk/etc/pure-mode.el.in 2008-08-19 08:01:20 UTC (rev 539) @@ -164,7 +164,7 @@ ; (list "\\<\\(catch\\|throw\\)\\>" 0 'font-lock-builtin-face) (list (concat "\\<\\(" - "def\\|extern\\|infix[lr]?\\|" + "const\\|def\\|extern\\|infix[lr]?\\|" "let\\|nullary\\|p\\(refix\\|ostfix\\)\\|" "using" "\\)\\>") @@ -178,7 +178,7 @@ (list "\\<\\(catch\\|throw\\)\\>" 0 'font-lock-builtin-face) (list (concat "\\<\\(" - "case\\|def\\|e\\(lse\\|nd\\|xtern\\)\\|i\\(f\\|nfix[lr]?\\)\\|" + "case\\|const\\|def\\|e\\(lse\\|nd\\|xtern\\)\\|i\\(f\\|nfix[lr]?\\)\\|" "let\\|nullary\\|o\\(f\\|therwise\\)\\|p\\(refix\\|ostfix\\)\\|" "then\\|using\\|w\\(hen\\|ith\\)" "\\)\\>") Modified: pure/trunk/etc/pure.lang =================================================================== --- pure/trunk/etc/pure.lang 2008-08-19 07:12:56 UTC (rev 538) +++ pure/trunk/etc/pure.lang 2008-08-19 08:01:20 UTC (rev 539) @@ -4,8 +4,8 @@ $DESCRIPTION=Pure # Pure keywords. -$KW_LIST(kwa)=infix infixl infixr prefix postfix nullary case def else end -extern if let of otherwise then using when with +$KW_LIST(kwa)=infix infixl infixr prefix postfix nullary case const def else +end extern if let of otherwise then using when with # These aren't really keywords but we want them to stick out anyway. $KW_LIST(kwb)=catch throw Modified: pure/trunk/etc/pure.vim =================================================================== --- pure/trunk/etc/pure.vim 2008-08-19 07:12:56 UTC (rev 538) +++ pure/trunk/etc/pure.vim 2008-08-19 08:01:20 UTC (rev 539) @@ -33,7 +33,7 @@ " keywords syn keyword pureKeyword infix infixl infixr prefix postfix nullary -syn keyword pureKeyword case def else end extern if let of otherwise then +syn keyword pureKeyword case const def else end extern if let of otherwise then syn keyword pureKeyword using when with syn keyword pureSpecial catch throw syn keyword pureType bigint bool char short int long double Modified: pure/trunk/etc/pure.xml =================================================================== --- pure/trunk/etc/pure.xml 2008-08-19 07:12:56 UTC (rev 538) +++ pure/trunk/etc/pure.xml 2008-08-19 08:01:20 UTC (rev 539) @@ -11,6 +11,7 @@ <item> end </item> </list> <list name="keywords"> + <item> const </item> <item> def </item> <item> else </item> <item> extern </item> Modified: pure/trunk/examples/hello.pure =================================================================== --- pure/trunk/examples/hello.pure 2008-08-19 07:12:56 UTC (rev 538) +++ pure/trunk/examples/hello.pure 2008-08-19 08:01:20 UTC (rev 539) @@ -47,11 +47,11 @@ // Pattern matching definition with 'let'. let x, y = square x, square (x+2); x; y; -// We also have constant definitions using 'def' in lieu of 'let'. These -// cannot be redefined and are substituted directly into other definitions. -// Try something like 'foo x = pi*x;' and then 'list foo' to see the -// difference. -def pi = 3.14159265358979; +// We also have constant definitions using 'const' in lieu of 'let'. These +// symbols cannot be redefined and are substituted directly into other +// definitions. Try something like 'foo x = pi*x;' and then 'list foo' to see +// the difference. +const pi = 3.14159265358979; /* Variations on a theme: The factorial. This illustrates various different ways to define a simple recursive function. */ Modified: pure/trunk/examples/libor/date.pure =================================================================== --- pure/trunk/examples/libor/date.pure 2008-08-19 07:12:56 UTC (rev 538) +++ pure/trunk/examples/libor/date.pure 2008-08-19 08:01:20 UTC (rev 539) @@ -12,18 +12,18 @@ // diytime = c_time (pointer 0); // some constants in whole days -def mdayposix = 1856305;// Mayan day for the posix epoch 1 Jan 1970 -def jdayposix = 2440588;// Julian day (since 1 Jan 4713 BC) for the posix epoch -def cycledays = 1872000;// end of cycle: total days in 13 Baktuns +const mdayposix = 1856305;// Mayan day for the posix epoch 1 Jan 1970 +const jdayposix = 2440588;// Julian day (since 1 Jan 4713 BC) for the posix epoch +const cycledays = 1872000;// end of cycle: total days in 13 Baktuns // some constants in whole seconds -def secsinday = 86400; // number of seconds in a day -def trueyear = 31556941;// current true year (divisible by 13) -def myyear = 31556943;// div by 2277, secsinday compatible, 365.2424 days -def gregyear = 31556952;// div by 40824, mean gregorian year, 365.2425 days -def lunarmonth = 2551443; // duration of the lunar synodic month -def fullmoon = 1213810200;// 18th June 2008, 17:30, full moon in posix seconds -def venussyn = 50450688;// duration of the Venus synodic cycle -def venusinf = 1187409600;// 18th August 2007, 4am Venus inferior conjunction +const secsinday = 86400; // number of seconds in a day +const trueyear = 31556941;// current true year (divisible by 13) +const myyear = 31556943;// div by 2277, secsinday compatible, 365.2424 days +const gregyear = 31556952;// div by 40824, mean gregorian year, 365.2425 days +const lunarmonth = 2551443; // duration of the lunar synodic month +const fullmoon = 1213810200;// 18th June 2008, 17:30, full moon in posix seconds +const venussyn = 50450688;// duration of the Venus synodic cycle +const venusinf = 1187409600;// 18th August 2007, 4am Venus inferior conjunction /******************************************************************************/ // first some functions generally useful in Pure: Modified: pure/trunk/interpreter.cc =================================================================== --- pure/trunk/interpreter.cc 2008-08-19 07:12:56 UTC (rev 538) +++ pure/trunk/interpreter.cc 2008-08-19 08:01:20 UTC (rev 539) @@ -1217,16 +1217,16 @@ last.clear(); pure_expr *e, *res = const_defn(r->lhs, r->rhs, e); if ((verbose&verbosity::defs) != 0) - cout << "def " << r->lhs << " = " << r->rhs << ";\n"; + cout << "const " << r->lhs << " = " << r->rhs << ";\n"; if (!res) { ostringstream msg; if (e) { msg << "unhandled exception '" << e << "' while evaluating '" - << "def " << r->lhs << " = " << r->rhs << "'"; + << "const " << r->lhs << " = " << r->rhs << "'"; pure_free(e); } else msg << "failed match while evaluating '" - << "def " << r->lhs << " = " << r->rhs << "'"; + << "const " << r->lhs << " = " << r->rhs << "'"; throw err(msg.str()); } delete r; Modified: pure/trunk/lexer.ll =================================================================== --- pure/trunk/lexer.ll 2008-08-19 07:12:56 UTC (rev 538) +++ pure/trunk/lexer.ll 2008-08-19 08:01:20 UTC (rev 539) @@ -131,9 +131,9 @@ now. */ static const char *commands[] = { - "cd", "clear", "def", "extern", "help", "infix", "infixl", "infixr", "let", - "list", "ls", "nullary", "override", "postfix", "prefix", "pwd", "quit", - "run", "save", "stats", "underride", "using", 0 + "cd", "clear", "const", "def", "extern", "help", "infix", "infixl", + "infixr", "let", "list", "ls", "nullary", "override", "postfix", "prefix", + "pwd", "quit", "run", "save", "stats", "underride", "using", 0 }; typedef map<string, symbol> symbol_map; @@ -531,7 +531,7 @@ << *jt->second.cval << ";"; sout << endl; } else - sout << "def " << sym.s << " = " << *jt->second.cval + sout << "const " << sym.s << " = " << *jt->second.cval << ";\n"; } else { if (sym.fix == nullary) @@ -819,6 +819,7 @@ prefix yylval->fix = prefix; return token::FIX; postfix yylval->fix = postfix; return token::FIX; nullary return token::NULLARY; +const return token::CONST; def return token::DEF; let return token::LET; case return token::CASE; Modified: pure/trunk/lib/math.pure =================================================================== --- pure/trunk/lib/math.pure 2008-08-19 07:12:56 UTC (rev 538) +++ pure/trunk/lib/math.pure 2008-08-19 08:01:20 UTC (rev 539) @@ -20,7 +20,7 @@ /* IEEE floating point infinities and NaNs. */ -def inf = 1.0e307 * 1.0e307; def nan = inf-inf; +const inf = 1.0e307 * 1.0e307; const nan = inf-inf; /* Random number generator. This uses the Mersenne twister, in order to avoid bad generators present in some C libraries. Returns pseudo random ints in @@ -48,7 +48,7 @@ /* Euler's number. */ -def e = exp 1.0; +const e = exp 1.0; /* Trigonometric functions. */ @@ -71,7 +71,7 @@ /* Ludolph's number. */ -def pi = 4.0*atan 1.0; +const pi = 4.0*atan 1.0; /* Hyperbolic functions. */ @@ -111,7 +111,7 @@ /* The imaginary unit. */ -def i = 0+:1; +const i = 0+:1; /* The following operations all work with both the rectangular and the polar representation, promoting real inputs to complex where appropriate. When Modified: pure/trunk/lib/prelude.pure =================================================================== --- pure/trunk/lib/prelude.pure 2008-08-19 07:12:56 UTC (rev 538) +++ pure/trunk/lib/prelude.pure 2008-08-19 08:01:20 UTC (rev 539) @@ -67,7 +67,7 @@ /* The truth values. These are just integers in Pure, but sometimes it's convenient to refer to them using these symbolic constants. */ -def false = 0; def true = 1; +const false, true = 0, 1; /* Pull in the primitives (arithmetic etc.) and the standard string functions. Note that the math and system modules are *not* included here, so you have Modified: pure/trunk/parser.yy =================================================================== --- pure/trunk/parser.yy 2008-08-19 07:12:56 UTC (rev 538) +++ pure/trunk/parser.yy 2008-08-19 08:01:20 UTC (rev 539) @@ -99,6 +99,7 @@ %token <fix> FIX "fixity" %token DEF "def" +%token CONST "const" %token LET "let" %token CASE "case" %token OF "of" @@ -276,7 +277,7 @@ { action(interp.exec($1), delete $1); } | LET simple_rule { action(interp.define($2), delete $2); } -| DEF simple_rule +| CONST simple_rule { action(interp.define_const($2), delete $2); } | rule { rulel *rl = 0; Modified: pure/trunk/printer.cc =================================================================== --- pure/trunk/printer.cc 2008-08-19 07:12:56 UTC (rev 538) +++ pure/trunk/printer.cc 2008-08-19 08:01:20 UTC (rev 539) @@ -432,7 +432,7 @@ break; } case env_info::cvar: - os << "def " << sym.s << " = " << *info.cval; + os << "const " << sym.s << " = " << *info.cval; break; case env_info::fvar: os << "let " << sym.s << " = " << *(pure_expr**)info.val; Modified: pure/trunk/pure.cc =================================================================== --- pure/trunk/pure.cc 2008-08-19 07:12:56 UTC (rev 538) +++ pure/trunk/pure.cc 2008-08-19 08:01:20 UTC (rev 539) @@ -54,9 +54,9 @@ #define LICENSE "This program is free software distributed under the GNU Public License\n(GPL V3 or later). Please see the COPYING file for details.\n" static const char *commands[] = { - "cd", "clear", "def", "extern", "help", "infix", "infixl", "infixr", "let", - "list", "ls", "nullary", "override", "postfix", "prefix", "pwd", "quit", - "run", "save", "stats", "underride", "using", 0 + "cd", "clear", "const", "def", "extern", "help", "infix", "infixl", + "infixr", "let", "list", "ls", "nullary", "override", "postfix", "prefix", + "pwd", "quit", "run", "save", "stats", "underride", "using", 0 }; /* Generator functions for command completion. */ Modified: pure/trunk/test/prelude.log =================================================================== --- pure/trunk/test/prelude.log 2008-08-19 07:12:56 UTC (rev 538) +++ pure/trunk/test/prelude.log 2008-08-19 08:01:20 UTC (rev 539) @@ -1,5 +1,4 @@ -def false = 0; -def true = 1; +const false,true = 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/test013.log =================================================================== --- pure/trunk/test/test013.log 2008-08-19 07:12:56 UTC (rev 538) +++ pure/trunk/test/test013.log 2008-08-19 08:01:20 UTC (rev 539) @@ -1,4 +1,4 @@ -def pi = 4*atan 1.0; +const pi = 4*atan 1.0; foo x/*0:1*/ = 3.14159265358979*x/*0:1*/; { rule #0: foo x = 3.14159265358979*x Modified: pure/trunk/test/test013.pure =================================================================== --- pure/trunk/test/test013.pure 2008-08-19 07:12:56 UTC (rev 538) +++ pure/trunk/test/test013.pure 2008-08-19 08:01:20 UTC (rev 539) @@ -2,7 +2,7 @@ // constant definition example extern double atan(double); -def pi = 4*atan 1.0; +const pi = 4*atan 1.0; foo x = pi*x; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |