From commit at keithp.com Sun Nov 7 22:01:54 2004 From: commit at keithp.com (Bart Massey) Date: Sun Nov 7 22:01:58 2004 Subject: [Commit] nickle ChangeLog,1.91,1.92 Message-ID: Committed by: bart Update of /local/src/CVS/nickle In directory home.keithp.com:/tmp/cvs-serv4255 Modified Files: ChangeLog Log Message: Failed to commit the ChangeLog long ago. Oops. Index: ChangeLog =================================================================== RCS file: /local/src/CVS/nickle/ChangeLog,v retrieving revision 1.91 retrieving revision 1.92 diff -u -d -r1.91 -r1.92 --- ChangeLog 20 Oct 2004 06:17:55 -0000 1.91 +++ ChangeLog 8 Nov 2004 06:01:51 -0000 1.92 @@ -27,6 +27,12 @@ * value.c: (ShiftL), (ShiftR): Optimize shifts of small ints by small ints +2004-10-01 Bart Massey + + * compile.c: + Compiler dumped core when trying to create a variable of + incomplete structure type. + 2004-09-22 Bart Massey * gram.y: From commit at keithp.com Sun Nov 7 22:06:47 2004 From: commit at keithp.com (Bart Massey) Date: Sun Nov 7 22:06:51 2004 Subject: [Commit] nickle ChangeLog,1.92,1.93 string.5c,1.9,1.10 Message-ID: Committed by: bart Update of /local/src/CVS/nickle In directory home.keithp.com:/tmp/cvs-serv4325 Modified Files: ChangeLog string.5c Log Message: * string.5c: Add wordsplit() function. Index: ChangeLog =================================================================== RCS file: /local/src/CVS/nickle/ChangeLog,v retrieving revision 1.92 retrieving revision 1.93 diff -u -d -r1.92 -r1.93 --- ChangeLog 8 Nov 2004 06:01:51 -0000 1.92 +++ ChangeLog 8 Nov 2004 06:06:44 -0000 1.93 @@ -1,3 +1,8 @@ +2004-11-7 Bart Massey + + * string.5c: + Add wordsplit() function. + 2004-10-19 Keith Packard * lex.l: Index: string.5c =================================================================== RCS file: /local/src/CVS/nickle/string.5c,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- string.5c 8 Jun 2004 09:30:54 -0000 1.9 +++ string.5c 8 Nov 2004 06:06:44 -0000 1.10 @@ -51,6 +51,9 @@ return ss; } + + + public string chomp(string s) /* * Trim whitespace from begining and end of 's' @@ -74,6 +77,29 @@ return index(String::new(c), s) >= 0; } + public string[*] wordsplit(string s, string sep) + /* + * Split 's' at boundaries consisting of sequences of + * 'sep' characters, returning an array of the resulting + * pieces + */ + { + string[...] ss = {}; + int i = 0; + while(i < length(s)) { + while (i < length(s) && inchars(s[i], sep)) + i++; + int j = i; + while (j < length(s) && !inchars(s[j], sep)) + j++; + if (i == j) + break; + ss[dim(ss)] = substr(s, i, j - i); + i = j; + } + return ss; + } + public typedef struct { string oq, cq, qq; } quote_context; From commit at keithp.com Sun Nov 7 22:28:41 2004 From: commit at keithp.com (Bart Massey) Date: Sun Nov 7 22:28:45 2004 Subject: [Commit] nickle ChangeLog,1.93,1.94 string.5c,1.10,1.11 Message-ID: Committed by: bart Update of /local/src/CVS/nickle In directory home.keithp.com:/tmp/cvs-serv4879 Modified Files: ChangeLog string.5c Log Message: * string.5c: Add shiftn(), shift(), chump() functions. Index: ChangeLog =================================================================== RCS file: /local/src/CVS/nickle/ChangeLog,v retrieving revision 1.93 retrieving revision 1.94 diff -u -d -r1.93 -r1.94 --- ChangeLog 8 Nov 2004 06:06:44 -0000 1.93 +++ ChangeLog 8 Nov 2004 06:28:38 -0000 1.94 @@ -1,6 +1,11 @@ 2004-11-7 Bart Massey * string.5c: + Add shiftn(), shift(), chump() functions. + +2004-11-7 Bart Massey + + * string.5c: Add wordsplit() function. 2004-10-19 Keith Packard Index: string.5c =================================================================== RCS file: /local/src/CVS/nickle/string.5c,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- string.5c 8 Nov 2004 06:06:44 -0000 1.10 +++ string.5c 8 Nov 2004 06:28:38 -0000 1.11 @@ -52,7 +52,39 @@ } + void shiftn(&(poly[...]) array, int n) + /* + * Shift a growable array n elements: left is positive + */ + { + int f = dim(array); + for (int i = 0; i < f - n; i++) + array[i] = array[i + n]; + if (n < 0) + for (int i = 0; i < -n; i++) + make_uninit(&array[i]); + if (n > 0) + setdim(array, f - n); + } + + void shift(&(poly[...]) array) + /* + * Shift a growable array one element to the left + */ + { + shiftn(&array, 1); + } + string chump(string s) + /* + * Return s with any trailing newlines removed + */ + { + int n = length(s); + while(n > 0 && s[n - 1] == '\n') + --n; + return substr(s, 0, n); + } public string chomp(string s) /* From commit at keithp.com Sun Nov 7 22:32:13 2004 From: commit at keithp.com (Bart Massey) Date: Sun Nov 7 22:32:16 2004 Subject: [Commit] nickle string.5c,1.11,1.12 Message-ID: Committed by: bart Update of /local/src/CVS/nickle In directory home.keithp.com:/tmp/cvs-serv4949 Modified Files: string.5c Log Message: Forgot "public" in previous checkin. Index: string.5c =================================================================== RCS file: /local/src/CVS/nickle/string.5c,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- string.5c 8 Nov 2004 06:28:38 -0000 1.11 +++ string.5c 8 Nov 2004 06:32:10 -0000 1.12 @@ -52,7 +52,7 @@ } - void shiftn(&(poly[...]) array, int n) + public void shiftn(&(poly[...]) array, int n) /* * Shift a growable array n elements: left is positive */ @@ -67,7 +67,7 @@ setdim(array, f - n); } - void shift(&(poly[...]) array) + public void shift(&(poly[...]) array) /* * Shift a growable array one element to the left */ @@ -75,7 +75,7 @@ shiftn(&array, 1); } - string chump(string s) + public string chump(string s) /* * Return s with any trailing newlines removed */ From commit at keithp.com Mon Nov 8 00:53:27 2004 From: commit at keithp.com (Bart Massey) Date: Mon Nov 8 00:53:30 2004 Subject: [Commit] nickle ChangeLog,1.94,1.95 string.5c,1.12,1.13 Message-ID: Committed by: bart Update of /local/src/CVS/nickle In directory home.keithp.com:/tmp/cvs-serv8060 Modified Files: ChangeLog string.5c Log Message: * string.5c: inchars() had the arguments to index() backward. Index: ChangeLog =================================================================== RCS file: /local/src/CVS/nickle/ChangeLog,v retrieving revision 1.94 retrieving revision 1.95 diff -u -d -r1.94 -r1.95 --- ChangeLog 8 Nov 2004 06:28:38 -0000 1.94 +++ ChangeLog 8 Nov 2004 08:53:24 -0000 1.95 @@ -1,3 +1,8 @@ +2004-11-8 Bart Massey + + * string.5c: + inchars() had the arguments to index() backward. + 2004-11-7 Bart Massey * string.5c: Index: string.5c =================================================================== RCS file: /local/src/CVS/nickle/string.5c,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- string.5c 8 Nov 2004 06:32:10 -0000 1.12 +++ string.5c 8 Nov 2004 08:53:24 -0000 1.13 @@ -106,7 +106,7 @@ * Return whether 'c' is in 's' */ { - return index(String::new(c), s) >= 0; + return index(s, String::new(c)) >= 0; } public string[*] wordsplit(string s, string sep) From commit at keithp.com Mon Nov 15 11:31:43 2004 From: commit at keithp.com (Keith Packard) Date: Mon Nov 15 11:31:52 2004 Subject: [Commit] nickle ChangeLog,1.95,1.96 Message-ID: Committed by: keithp Update of /local/src/CVS/nickle In directory home.keithp.com:/tmp/cvs-serv25488 Modified Files: ChangeLog Log Message: 2004-11-15 Keith Packard * examples/Makefile.am: * examples/apsp.5c: * examples/comb.5c: * examples/cribbage.5c: * examples/erat.5c: * examples/google-puzzle.5c: * examples/initializer.5c: * examples/is-prime.5c: * examples/kaiser.5c: * examples/menace2.5c: Add licensing information to some of the examples Index: ChangeLog =================================================================== RCS file: /local/src/CVS/nickle/ChangeLog,v retrieving revision 1.95 retrieving revision 1.96 diff -u -d -r1.95 -r1.96 --- ChangeLog 8 Nov 2004 08:53:24 -0000 1.95 +++ ChangeLog 15 Nov 2004 19:31:40 -0000 1.96 @@ -1,3 +1,17 @@ +2004-11-15 Keith Packard + + * examples/Makefile.am: + * examples/apsp.5c: + * examples/comb.5c: + * examples/cribbage.5c: + * examples/erat.5c: + * examples/google-puzzle.5c: + * examples/initializer.5c: + * examples/is-prime.5c: + * examples/kaiser.5c: + * examples/menace2.5c: + Add licensing information to some of the examples + 2004-11-8 Bart Massey * string.5c: From commit at keithp.com Mon Nov 15 11:31:44 2004 From: commit at keithp.com (Keith Packard) Date: Mon Nov 15 11:31:52 2004 Subject: [Commit] nickle/examples Makefile.am, 1.2, 1.3 apsp.5c, 1.2, 1.3 comb.5c, 1.3, 1.4 cribbage.5c, 1.1, 1.2 erat.5c, 1.1, 1.2 google-puzzle.5c, 1.4, 1.5 initializer.5c, 1.1, 1.2 is-prime.5c, 1.2, 1.3 kaiser.5c, 1.4, 1.5 menace2.5c, 1.7, 1.8 Message-ID: Committed by: keithp Update of /local/src/CVS/nickle/examples In directory home.keithp.com:/tmp/cvs-serv25488/examples Modified Files: Makefile.am apsp.5c comb.5c cribbage.5c erat.5c google-puzzle.5c initializer.5c is-prime.5c kaiser.5c menace2.5c Log Message: 2004-11-15 Keith Packard * examples/Makefile.am: * examples/apsp.5c: * examples/comb.5c: * examples/cribbage.5c: * examples/erat.5c: * examples/google-puzzle.5c: * examples/initializer.5c: * examples/is-prime.5c: * examples/kaiser.5c: * examples/menace2.5c: Add licensing information to some of the examples Index: Makefile.am =================================================================== RCS file: /local/src/CVS/nickle/examples/Makefile.am,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- Makefile.am 29 Jul 2004 00:23:32 -0000 1.2 +++ Makefile.am 15 Nov 2004 19:31:41 -0000 1.3 @@ -27,6 +27,6 @@ exampledir=$(pkgdatadir)/examples -example_DATA=$(NICKLEFILES) +example_DATA=$(NICKLEFILES) COPYING EXTRA_DIST=$(NICKLEFILES) Index: apsp.5c =================================================================== RCS file: /local/src/CVS/nickle/examples/apsp.5c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- apsp.5c 22 Aug 2004 23:45:32 -0000 1.2 +++ apsp.5c 15 Nov 2004 19:31:41 -0000 1.3 @@ -2,7 +2,9 @@ * All-Pairs Shortest Path Computation * using Floyd-Warshall O(n**3) method * CLR 2nd ed p. 632 - * Bart Massey 2004/06 + * Copyright © 2004 Bart Massey. + * All Rights Reserved. See the file COPYING in this directory + * for licensing information. */ namespace APSP { public typedef real distance; Index: comb.5c =================================================================== RCS file: /local/src/CVS/nickle/examples/comb.5c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- comb.5c 8 Apr 2001 19:51:49 -0000 1.3 +++ comb.5c 15 Nov 2004 19:31:41 -0000 1.4 @@ -1,6 +1,8 @@ /* * Basic combinatorics - * Bart Massey 1995..2001 + * Copyright © 1995-2001 Bart Massey. + * All Rights Reserved. See the file COPYING in this directory + * for licensing information. */ namespace Comb { Index: cribbage.5c =================================================================== RCS file: /local/src/CVS/nickle/examples/cribbage.5c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- cribbage.5c 12 Apr 2001 08:23:11 -0000 1.1 +++ cribbage.5c 15 Nov 2004 19:31:41 -0000 1.2 @@ -1,7 +1,10 @@ /* * Cribbage scoring aid * Counts only runs and 15s - * Bart Massey (1997?) + * + * Copyright © 1997 Bart Massey. + * All Rights Reserved. See the file COPYING in this directory + * for licensing information. */ namespace Cribbage { Index: erat.5c =================================================================== RCS file: /local/src/CVS/nickle/examples/erat.5c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- erat.5c 16 Sep 2002 06:54:28 -0000 1.1 +++ erat.5c 15 Nov 2004 19:31:41 -0000 1.2 @@ -1,3 +1,8 @@ +/* + * Copyright © 2002 Bart Massey. + * All Rights Reserved. See the file COPYING in this directory + * for licensing information. + */ bool[*] make_sieve(int size) { bool[size] sieve = {true ...}; for (int k = 2; k < size; k++) { Index: google-puzzle.5c =================================================================== RCS file: /local/src/CVS/nickle/examples/google-puzzle.5c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- google-puzzle.5c 17 Sep 2004 08:05:16 -0000 1.4 +++ google-puzzle.5c 15 Nov 2004 19:31:41 -0000 1.5 @@ -6,6 +6,11 @@ # Uses Miller-Rabin to check candidates drawn # from the first 10K digits of e as printed at # http://sources.wikipedia.org/wiki/E_to_10%2C000_places +# +# Copyright © 2004 Bart Massey. +# All Rights Reserved. See the file COPYING in this directory +# for licensing information. +# import String; Index: initializer.5c =================================================================== RCS file: /local/src/CVS/nickle/examples/initializer.5c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- initializer.5c 6 Apr 2001 00:27:08 -0000 1.1 +++ initializer.5c 15 Nov 2004 19:31:41 -0000 1.2 @@ -1,5 +1,9 @@ /* * An example of initializers and scoping rules + * + * Copyright © 2001 Keith Packard + * All Rights Reserved. See the file COPYING in this directory + * for licensing information. */ continuation c; Index: is-prime.5c =================================================================== RCS file: /local/src/CVS/nickle/examples/is-prime.5c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- is-prime.5c 16 Sep 2002 23:49:19 -0000 1.2 +++ is-prime.5c 15 Nov 2004 19:31:41 -0000 1.3 @@ -3,6 +3,10 @@ * Agrawal, Kayal, and Saxena's * deterministic polytime primality test * + * Copyright © 2002 Bart Massey. + * All Rights Reserved. See the file COPYING in this directory + * for licensing information. + * * Bart Massey 2002/8/16 */ Index: kaiser.5c =================================================================== RCS file: /local/src/CVS/nickle/examples/kaiser.5c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- kaiser.5c 22 Mar 2001 04:28:56 -0000 1.4 +++ kaiser.5c 15 Nov 2004 19:31:41 -0000 1.5 @@ -1,6 +1,9 @@ /* * Kaiser Window digital filter - * Keith Packard 2001 + * + * Copyright © 2001, Keith Packard + * All Rights Reserved. See the file COPYING in this directory + * for licensing information. */ real function i0(real x) Index: menace2.5c =================================================================== RCS file: /local/src/CVS/nickle/examples/menace2.5c,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- menace2.5c 26 May 2004 08:11:10 -0000 1.7 +++ menace2.5c 15 Nov 2004 19:31:41 -0000 1.8 @@ -8,6 +8,11 @@ * MENACE2 is a simulation of this system in Nickle. * http://www.cs.pdx.edu/~bart/cs541-fall2001/homework/3-learn.html * + * + * Copyright © 2001 Bart Massey. + * All Rights Reserved. See the file COPYING in this directory + * for licensing information. + * * Bart Massey 2001/11/21 */ From commit at keithp.com Mon Nov 15 11:32:46 2004 From: commit at keithp.com (Keith Packard) Date: Mon Nov 15 11:32:50 2004 Subject: [Commit] nickle ChangeLog,1.96,1.97 compile.c,1.159,1.160 Message-ID: Committed by: keithp Update of /local/src/CVS/nickle In directory home.keithp.com:/tmp/cvs-serv25619 Modified Files: ChangeLog compile.c Log Message: 2004-11-15 Keith Packard * compile.c: (CompileImplicitInit): Implicitly initialize resizable arrays to zero-length array. Index: ChangeLog =================================================================== RCS file: /local/src/CVS/nickle/ChangeLog,v retrieving revision 1.96 retrieving revision 1.97 diff -u -d -r1.96 -r1.97 --- ChangeLog 15 Nov 2004 19:31:40 -0000 1.96 +++ ChangeLog 15 Nov 2004 19:32:43 -0000 1.97 @@ -1,5 +1,10 @@ 2004-11-15 Keith Packard + * compile.c: (CompileImplicitInit): + Implicitly initialize resizable arrays to zero-length array. + +2004-11-15 Keith Packard + * examples/Makefile.am: * examples/apsp.5c: * examples/comb.5c: Index: compile.c =================================================================== RCS file: /local/src/CVS/nickle/compile.c,v retrieving revision 1.159 retrieving revision 1.160 diff -u -d -r1.159 -r1.160 --- compile.c 1 Oct 2004 19:58:54 -0000 1.159 +++ compile.c 15 Nov 2004 19:32:43 -0000 1.160 @@ -1884,26 +1884,33 @@ switch (type->base.tag) { case type_array: - if (type->array.dimensions && type->array.dimensions->tree.left) + if (type->array.dimensions) { - sub = type->array.type; - init = CompileImplicitInit (sub); - if (init) + if (type->array.resizable) { - dim = CompileCountDeclDimensions (type->array.dimensions); - while (--dim >= 0) + init = NewExprTree (ANONINIT, 0, 0); + } + else if (type->array.dimensions->tree.left) + { + sub = type->array.type; + init = CompileImplicitInit (sub); + if (init) { - init = NewExprTree (ARRAY, - NewExprTree (COMMA, - init, - NewExprTree (COMMA, - NewExprTree (DOTDOTDOT, 0, 0), - 0)), - 0); + dim = CompileCountDeclDimensions (type->array.dimensions); + while (--dim >= 0) + { + init = NewExprTree (ARRAY, + NewExprTree (COMMA, + init, + NewExprTree (COMMA, + NewExprTree (DOTDOTDOT, 0, 0), + 0)), + 0); + } } + else + init = NewExprTree (ANONINIT, 0, 0); } - else - init = NewExprTree (ANONINIT, 0, 0); } break; case type_hash: From commit at keithp.com Mon Nov 15 12:16:39 2004 From: commit at keithp.com (Keith Packard) Date: Mon Nov 15 12:16:47 2004 Subject: [Commit] nickle ChangeLog,1.98,1.99 Message-ID: Committed by: keithp Update of /local/src/CVS/nickle In directory home.keithp.com:/tmp/cvs-serv27707 Modified Files: ChangeLog Log Message: 2004-11-15 Keith Packard * examples/COPYING: * examples/Makefile.am: * examples/miller-rabin.5c: * examples/mutextest.5c: * examples/numbers.5c: * examples/polynomial.5c: * examples/prime.5c: * examples/randtest.5c: * examples/restart.5c: * examples/roman.5c: * examples/rsa-demo.5c: * examples/rsa.5c: * examples/shortpaths.5c: * examples/skiplisttest.5c: * examples/smlng/COPYING: * examples/smlng/Makefile.am: * examples/smlng/context.5c: * examples/smlng/generate.5c: * examples/smlng/parse.5c: * examples/smlng/test.5c: * examples/turtle/COPYING: * examples/turtle/Makefile.am: * examples/turtle/snowflake.5c: * examples/turtle/snowflake.tex: * examples/turtle/turtle.5c: Add a bunch of copyright and license information Index: ChangeLog =================================================================== RCS file: /local/src/CVS/nickle/ChangeLog,v retrieving revision 1.98 retrieving revision 1.99 diff -u -d -r1.98 -r1.99 --- ChangeLog 15 Nov 2004 19:58:39 -0000 1.98 +++ ChangeLog 15 Nov 2004 20:16:36 -0000 1.99 @@ -1,5 +1,34 @@ 2004-11-15 Keith Packard + * examples/COPYING: + * examples/Makefile.am: + * examples/miller-rabin.5c: + * examples/mutextest.5c: + * examples/numbers.5c: + * examples/polynomial.5c: + * examples/prime.5c: + * examples/randtest.5c: + * examples/restart.5c: + * examples/roman.5c: + * examples/rsa-demo.5c: + * examples/rsa.5c: + * examples/shortpaths.5c: + * examples/skiplisttest.5c: + * examples/smlng/COPYING: + * examples/smlng/Makefile.am: + * examples/smlng/context.5c: + * examples/smlng/generate.5c: + * examples/smlng/parse.5c: + * examples/smlng/test.5c: + * examples/turtle/COPYING: + * examples/turtle/Makefile.am: + * examples/turtle/snowflake.5c: + * examples/turtle/snowflake.tex: + * examples/turtle/turtle.5c: + Add a bunch of copyright and license information + +2004-11-15 Keith Packard + * lex.l: Lost **= somehow. From commit at keithp.com Mon Nov 15 12:16:41 2004 From: commit at keithp.com (Keith Packard) Date: Mon Nov 15 12:16:50 2004 Subject: [Commit] nickle/examples/smlng COPYING, NONE, 1.1 Makefile.am, 1.1, 1.2 context.5c, 1.6, 1.7 generate.5c, 1.1, 1.2 parse.5c, 1.8, 1.9 test.5c, 1.2, 1.3 Message-ID: Committed by: keithp Update of /local/src/CVS/nickle/examples/smlng In directory home.keithp.com:/tmp/cvs-serv27707/examples/smlng Modified Files: Makefile.am context.5c generate.5c parse.5c test.5c Added Files: COPYING Log Message: 2004-11-15 Keith Packard * examples/COPYING: * examples/Makefile.am: * examples/miller-rabin.5c: * examples/mutextest.5c: * examples/numbers.5c: * examples/polynomial.5c: * examples/prime.5c: * examples/randtest.5c: * examples/restart.5c: * examples/roman.5c: * examples/rsa-demo.5c: * examples/rsa.5c: * examples/shortpaths.5c: * examples/skiplisttest.5c: * examples/smlng/COPYING: * examples/smlng/Makefile.am: * examples/smlng/context.5c: * examples/smlng/generate.5c: * examples/smlng/parse.5c: * examples/smlng/test.5c: * examples/turtle/COPYING: * examples/turtle/Makefile.am: * examples/turtle/snowflake.5c: * examples/turtle/snowflake.tex: * examples/turtle/turtle.5c: Add a bunch of copyright and license information --- NEW FILE: COPYING --- (This appears to be a binary file; contents omitted.) Index: Makefile.am =================================================================== RCS file: /local/src/CVS/nickle/examples/smlng/Makefile.am,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- Makefile.am 26 May 2004 08:01:42 -0000 1.1 +++ Makefile.am 15 Nov 2004 20:16:37 -0000 1.2 @@ -1,3 +1,10 @@ +# +# SGML-like parser +# +# Copyright © 2001 Keith Packard and Carl Worth +# All Rights Reserved. See the file COPYING in this directory +# for licensing information. +# NICKLEFILES=\ context.5c \ generate.5c \ @@ -6,10 +13,10 @@ exampledir=$(pkgdatadir)/examples/smlng -example_DATA=$(NICKLEFILES) +example_DATA=$(NICKLEFILES) COPYING TESTS_ENVIRONMENT=NICKLESTART=$(top_srcdir)/builtin.5c NICKLEPATH=$(top_srcdir):$(top_srcdir)/$(subdir) $(top_builddir)/nickle < $(top_srcdir)/$(subdir)/data.sgml > /dev/null TESTS=test.5c -EXTRA_DIST=$(NICKLEFILES) data.sgml +EXTRA_DIST=$(NICKLEFILES) data.sgml COPYING Index: context.5c =================================================================== RCS file: /local/src/CVS/nickle/examples/smlng/context.5c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- context.5c 27 Jul 2002 04:53:15 -0000 1.6 +++ context.5c 15 Nov 2004 20:16:37 -0000 1.7 @@ -1,3 +1,9 @@ +/* + * Copyright © 2001 Keith Packard and Carl Worth + * All Rights Reserved. See the file COPYING in this directory + * for licensing information. + */ + int style_b = 1; int style_em = 2; int style_i = 4; Index: generate.5c =================================================================== RCS file: /local/src/CVS/nickle/examples/smlng/generate.5c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- generate.5c 27 Jul 2001 08:01:59 -0000 1.1 +++ generate.5c 15 Nov 2004 20:16:37 -0000 1.2 @@ -1,3 +1,9 @@ +/* + * Copyright © 2001 Keith Packard and Carl Worth + * All Rights Reserved. See the file COPYING in this directory + * for licensing information. + */ + int function iswhite (int c) { switch (c) { Index: parse.5c =================================================================== RCS file: /local/src/CVS/nickle/examples/smlng/parse.5c,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- parse.5c 26 May 2004 08:01:42 -0000 1.8 +++ parse.5c 15 Nov 2004 20:16:37 -0000 1.9 @@ -1,5 +1,9 @@ /* * Parse simple sgml-style grammar + * + * Copyright © 2001 Keith Packard and Carl Worth + * All Rights Reserved. See the file COPYING in this directory + * for licensing information. */ library "context.5c" Index: test.5c =================================================================== RCS file: /local/src/CVS/nickle/examples/smlng/test.5c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- test.5c 26 May 2004 08:01:42 -0000 1.2 +++ test.5c 15 Nov 2004 20:16:37 -0000 1.3 @@ -1,3 +1,9 @@ +/* + * Copyright © 2001 Keith Packard and Carl Worth + * All Rights Reserved. See the file COPYING in this directory + * for licensing information. + */ + library "parse.5c" *Parse::element e = Parse::get(stdin); From commit at keithp.com Mon Nov 15 12:16:41 2004 From: commit at keithp.com (Keith Packard) Date: Mon Nov 15 12:16:54 2004 Subject: [Commit] nickle/examples/turtle COPYING, NONE, 1.1 Makefile.am, 1.1, 1.2 snowflake.5c, 1.4, 1.5 snowflake.tex, 1.1, 1.2 turtle.5c, 1.1, 1.2 Message-ID: Committed by: keithp Update of /local/src/CVS/nickle/examples/turtle In directory home.keithp.com:/tmp/cvs-serv27707/examples/turtle Modified Files: Makefile.am snowflake.5c snowflake.tex turtle.5c Added Files: COPYING Log Message: 2004-11-15 Keith Packard * examples/COPYING: * examples/Makefile.am: * examples/miller-rabin.5c: * examples/mutextest.5c: * examples/numbers.5c: * examples/polynomial.5c: * examples/prime.5c: * examples/randtest.5c: * examples/restart.5c: * examples/roman.5c: * examples/rsa-demo.5c: * examples/rsa.5c: * examples/shortpaths.5c: * examples/skiplisttest.5c: * examples/smlng/COPYING: * examples/smlng/Makefile.am: * examples/smlng/context.5c: * examples/smlng/generate.5c: * examples/smlng/parse.5c: * examples/smlng/test.5c: * examples/turtle/COPYING: * examples/turtle/Makefile.am: * examples/turtle/snowflake.5c: * examples/turtle/snowflake.tex: * examples/turtle/turtle.5c: Add a bunch of copyright and license information --- NEW FILE: COPYING --- (This appears to be a binary file; contents omitted.) Index: Makefile.am =================================================================== RCS file: /local/src/CVS/nickle/examples/turtle/Makefile.am,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- Makefile.am 26 May 2004 08:01:42 -0000 1.1 +++ Makefile.am 15 Nov 2004 20:16:37 -0000 1.2 @@ -1,12 +1,19 @@ +# +# Draw "snowflake" fractal +# +# Copyright © 2001 Bart Massey. +# All Rights Reserved. See the file COPYING in this directory +# for licensing information. + NICKLEFILES=\ snowflake.5c \ turtle.5c exampledir=$(pkgdatadir)/examples/turtle -example_DATA=$(NICKLEFILES) snowflake.tex +example_DATA=$(NICKLEFILES) snowflake.tex COPYING -EXTRA_DIST=$(example_DATA) +EXTRA_DIST=$(example_DATA) COPYING TESTS_ENVIRONMENT=NICKLESTART=$(top_srcdir)/builtin.5c NICKLEPATH=$(top_srcdir):$(top_srcdir)/$(subdir) $(top_builddir)/nickle TESTS=snowflake.5c Index: snowflake.5c =================================================================== RCS file: /local/src/CVS/nickle/examples/turtle/snowflake.5c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- snowflake.5c 26 May 2004 08:11:10 -0000 1.4 +++ snowflake.5c 15 Nov 2004 20:16:38 -0000 1.5 @@ -1,5 +1,9 @@ # von Koch / Snowflake curves # Bart 2001/05/28 +# +# Copyright © 2001 Bart Massey. +# All Rights Reserved. See the file COPYING in this directory +# for licensing information. # usage: ./snowflake.5c # where is the curve width in inches Index: snowflake.tex =================================================================== RCS file: /local/src/CVS/nickle/examples/turtle/snowflake.tex,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- snowflake.tex 29 May 2001 02:56:32 -0000 1.1 +++ snowflake.tex 15 Nov 2004 20:16:38 -0000 1.2 @@ -1,3 +1,7 @@ +%% Copyright © 2001 Bart Massey. +%% All Rights Reserved. See the file COPYING in this directory +%% for licensing information. + \documentclass{article} \usepackage{epic,eepic} \begin{document} Index: turtle.5c =================================================================== RCS file: /local/src/CVS/nickle/examples/turtle/turtle.5c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- turtle.5c 29 May 2001 02:56:32 -0000 1.1 +++ turtle.5c 15 Nov 2004 20:16:38 -0000 1.2 @@ -1,6 +1,10 @@ /* * Turtle Graphics for LaTeX eepic * Bart 2001/05/28 + * + * Copyright © 2001 Bart Massey. + * All Rights Reserved. See the file COPYING in this directory + * for licensing information. */ namespace Turtle { From commit at keithp.com Mon Nov 15 12:16:41 2004 From: commit at keithp.com (Keith Packard) Date: Mon Nov 15 12:16:59 2004 Subject: [Commit] nickle/examples COPYING, NONE, 1.1 Makefile.am, 1.3, 1.4 miller-rabin.5c, 1.5, 1.6 mutextest.5c, 1.8, 1.9 numbers.5c, 1.2, 1.3 polynomial.5c, 1.1, 1.2 prime.5c, 1.9, 1.10 randtest.5c, 1.4, 1.5 restart.5c, 1.2, 1.3 roman.5c, 1.7, 1.8 rsa-demo.5c, 1.3, 1.4 rsa.5c, 1.2, 1.3 shortpaths.5c, 1.1, 1.2 skiplisttest.5c, 1.1, 1.2 Message-ID: Committed by: keithp Update of /local/src/CVS/nickle/examples In directory home.keithp.com:/tmp/cvs-serv27707/examples Modified Files: Makefile.am miller-rabin.5c mutextest.5c numbers.5c polynomial.5c prime.5c randtest.5c restart.5c roman.5c rsa-demo.5c rsa.5c shortpaths.5c skiplisttest.5c Added Files: COPYING Log Message: 2004-11-15 Keith Packard * examples/COPYING: * examples/Makefile.am: * examples/miller-rabin.5c: * examples/mutextest.5c: * examples/numbers.5c: * examples/polynomial.5c: * examples/prime.5c: * examples/randtest.5c: * examples/restart.5c: * examples/roman.5c: * examples/rsa-demo.5c: * examples/rsa.5c: * examples/shortpaths.5c: * examples/skiplisttest.5c: * examples/smlng/COPYING: * examples/smlng/Makefile.am: * examples/smlng/context.5c: * examples/smlng/generate.5c: * examples/smlng/parse.5c: * examples/smlng/test.5c: * examples/turtle/COPYING: * examples/turtle/Makefile.am: * examples/turtle/snowflake.5c: * examples/turtle/snowflake.tex: * examples/turtle/turtle.5c: Add a bunch of copyright and license information --- NEW FILE: COPYING --- (This appears to be a binary file; contents omitted.) Index: Makefile.am =================================================================== RCS file: /local/src/CVS/nickle/examples/Makefile.am,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- Makefile.am 15 Nov 2004 19:31:41 -0000 1.3 +++ Makefile.am 15 Nov 2004 20:16:37 -0000 1.4 @@ -29,4 +29,4 @@ example_DATA=$(NICKLEFILES) COPYING -EXTRA_DIST=$(NICKLEFILES) +EXTRA_DIST=$(NICKLEFILES) COPYING Index: miller-rabin.5c =================================================================== RCS file: /local/src/CVS/nickle/examples/miller-rabin.5c,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- miller-rabin.5c 16 Sep 2002 23:49:19 -0000 1.5 +++ miller-rabin.5c 15 Nov 2004 20:16:37 -0000 1.6 @@ -7,6 +7,10 @@ * (failure probability 1/2**d) * primebits(n,d): returns a random n-bit number k where !composite(k,d) * + * Copyright © 1999 Bart Massey. + * All Rights Reserved. See the file COPYING in this directory + * for licensing information. + * * Bart Massey 1999/1 */ Index: mutextest.5c =================================================================== RCS file: /local/src/CVS/nickle/examples/mutextest.5c,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- mutextest.5c 29 Jul 2004 00:23:32 -0000 1.8 +++ mutextest.5c 15 Nov 2004 20:16:37 -0000 1.9 @@ -1,7 +1,10 @@ /* * Let a potentially large number of threads wait * for a mutex. - * Keith Packard 2001 + * + * Copyright © 2001 Keith Packard + * All Rights Reserved. See the file COPYING in this directory + * for licensing information. */ import Mutex; Index: numbers.5c =================================================================== RCS file: /local/src/CVS/nickle/examples/numbers.5c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- numbers.5c 19 May 2001 16:25:05 -0000 1.2 +++ numbers.5c 15 Nov 2004 20:16:37 -0000 1.3 @@ -1,5 +1,10 @@ /* * Some number-theoretic algorithms + * + * Copyright © 1999 Bart Massey. + * All Rights Reserved. See the file COPYING in this directory + * for licensing information. + * * Bart Massey 1999/1 * * bigpowmod(b,e,m): returns (b**e) mod m Index: polynomial.5c =================================================================== RCS file: /local/src/CVS/nickle/examples/polynomial.5c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- polynomial.5c 19 Aug 2002 01:02:55 -0000 1.1 +++ polynomial.5c 15 Nov 2004 20:16:37 -0000 1.2 @@ -1,3 +1,11 @@ +/* + * Arithmetic on polynomials with (integer) coefficients + * + * Copyright © 2002 Bart Massey. + * All Rights Reserved. See the file COPYING in this directory + * for licensing information. + */ + namespace Polynomial { /* Index: prime.5c =================================================================== RCS file: /local/src/CVS/nickle/examples/prime.5c,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- prime.5c 4 Aug 2002 20:08:48 -0000 1.9 +++ prime.5c 15 Nov 2004 20:16:37 -0000 1.10 @@ -1,6 +1,10 @@ /* * factor(): Return an array of factors of a number - * Keith Packard 2001 + * + * Copyright © 2001 Keith Packard. + * All Rights Reserved. See the file COPYING in this directory + * for licensing information. + * * Very inefficient, but demonstrates the use of disjoint unions * and dynamic arrays. */ Index: randtest.5c =================================================================== RCS file: /local/src/CVS/nickle/examples/randtest.5c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- randtest.5c 26 May 2004 08:01:42 -0000 1.4 +++ randtest.5c 15 Nov 2004 20:16:37 -0000 1.5 @@ -1,5 +1,10 @@ /* * Check the PRNG for a balanced low bit + * + * Copyright © 2001 Bart Massey. + * All Rights Reserved. See the file COPYING in this directory + * for licensing information. + * * Bart 2001/3 */ Index: restart.5c =================================================================== RCS file: /local/src/CVS/nickle/examples/restart.5c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- restart.5c 25 Jul 2002 18:15:48 -0000 1.2 +++ restart.5c 15 Nov 2004 20:16:37 -0000 1.3 @@ -3,6 +3,10 @@ * restart execution after correcting * an exceptional condition. * + * Copyright © 2001 Bart Massey. + * All Rights Reserved. See the file COPYING in this directory + * for licensing information. + * * Bart 2001/06/03 */ Index: roman.5c =================================================================== RCS file: /local/src/CVS/nickle/examples/roman.5c,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- roman.5c 27 Jul 2002 04:53:15 -0000 1.7 +++ roman.5c 15 Nov 2004 20:16:37 -0000 1.8 @@ -1,6 +1,10 @@ /* * Convert integer to string of roman numerals - * Keith Packard 2001 + * + * Copyright © 2001 Keith Packard + * All Rights Reserved. See the file COPYING in this directory + * for licensing information. + * * A classic, plus a good illustration of some * of the structuring, typing, and nesting * capabilities of the language. Index: rsa-demo.5c =================================================================== RCS file: /local/src/CVS/nickle/examples/rsa-demo.5c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- rsa-demo.5c 16 Sep 2002 23:49:19 -0000 1.3 +++ rsa-demo.5c 15 Nov 2004 20:16:37 -0000 1.4 @@ -1,5 +1,10 @@ /* * Demo of RSA implementation + * + * Copyright © 2001 Bart Massey. + * All Rights Reserved. See the file COPYING in this directory + * for licensing information. + * * Bart 2001/03 */ Index: rsa.5c =================================================================== RCS file: /local/src/CVS/nickle/examples/rsa.5c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- rsa.5c 26 May 2004 08:01:42 -0000 1.2 +++ rsa.5c 15 Nov 2004 20:16:37 -0000 1.3 @@ -1,5 +1,10 @@ /* * RSA cryptosystem + * + * Copyright © 2001 Bart Massey. + * All Rights Reserved. See the file COPYING in this directory + * for licensing information. + * * Bart Massey 1999/1 * * Must first load numbers.5c Index: shortpaths.5c =================================================================== RCS file: /local/src/CVS/nickle/examples/shortpaths.5c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- shortpaths.5c 23 Jun 2004 09:00:46 -0000 1.1 +++ shortpaths.5c 15 Nov 2004 20:16:37 -0000 1.2 @@ -1,3 +1,11 @@ +/* + * Floyd-Warshall all-pairs shortest-path algorithm. + * + * Copyright © 2004 Bart Massey. + * All Rights Reserved. See the file COPYING in this directory + * for licensing information. + */ + autoimport APSP; autoimport PRNG; autoload SVG; Index: skiplisttest.5c =================================================================== RCS file: /local/src/CVS/nickle/examples/skiplisttest.5c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- skiplisttest.5c 29 Jul 2004 00:23:32 -0000 1.1 +++ skiplisttest.5c 15 Nov 2004 20:16:37 -0000 1.2 @@ -1,3 +1,12 @@ +/* $Header$ */ +/* + * Test skiplist implementation + * + * Copyright © 2004 Keith Packard and Bart Massey. + * All Rights Reserved. See the file COPYING in this directory + * for licensing information. + */ + autoload Skiplist; int gt_count = "hi"; From commit at keithp.com Thu Nov 18 22:53:08 2004 From: commit at keithp.com (Keith Packard) Date: Thu Nov 18 22:53:12 2004 Subject: [Commit] nickle/examples sort.5c,1.2,1.3 Message-ID: Committed by: keithp Update of /local/src/CVS/nickle/examples In directory home.keithp.com:/tmp/cvs-serv5258/examples Modified Files: sort.5c Log Message: 2004-11-18 Keith Packard * examples/sort.5c: Change copyright symbol encoding from Latin-1 to UTF-8 * execute.c: (ThreadArray), (ThreadArrayInd): Catch negative array dimensions. Bug discovered by James LaMar Index: sort.5c =================================================================== RCS file: /local/src/CVS/nickle/examples/sort.5c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- sort.5c 12 Apr 2003 00:04:10 -0000 1.2 +++ sort.5c 19 Nov 2004 06:53:05 -0000 1.3 @@ -1,6 +1,6 @@ /* $Header$ * - * Copyright © 2002 Keith Packard and Bart Massey. + * Copyright © 2002 Keith Packard and Bart Massey. * All Rights Reserved. See the file COPYING in this directory * for licensing information. */ From commit at keithp.com Thu Nov 18 22:53:08 2004 From: commit at keithp.com (Keith Packard) Date: Thu Nov 18 22:53:14 2004 Subject: [Commit] nickle ChangeLog,1.99,1.100 execute.c,1.92,1.93 Message-ID: Committed by: keithp Update of /local/src/CVS/nickle In directory home.keithp.com:/tmp/cvs-serv5258 Modified Files: ChangeLog execute.c Log Message: 2004-11-18 Keith Packard * examples/sort.5c: Change copyright symbol encoding from Latin-1 to UTF-8 * execute.c: (ThreadArray), (ThreadArrayInd): Catch negative array dimensions. Bug discovered by James LaMar Index: ChangeLog =================================================================== RCS file: /local/src/CVS/nickle/ChangeLog,v retrieving revision 1.99 retrieving revision 1.100 diff -u -d -r1.99 -r1.100 --- ChangeLog 15 Nov 2004 20:16:36 -0000 1.99 +++ ChangeLog 19 Nov 2004 06:53:05 -0000 1.100 @@ -1,3 +1,11 @@ +2004-11-18 Keith Packard + + * examples/sort.5c: + Change copyright symbol encoding from Latin-1 to UTF-8 + * execute.c: (ThreadArray), (ThreadArrayInd): + Catch negative array dimensions. + Bug discovered by James LaMar + 2004-11-15 Keith Packard * examples/COPYING: Index: execute.c =================================================================== RCS file: /local/src/CVS/nickle/execute.c,v retrieving revision 1.92 retrieving revision 1.93 diff -u -d -r1.92 -r1.93 --- execute.c 7 Jul 2004 07:32:47 -0000 1.92 +++ execute.c 19 Nov 2004 06:53:05 -0000 1.93 @@ -324,7 +324,12 @@ dims = AllocateTemp (ndim * sizeof (int)); for (i = 0; i < ndim; i++) { - dims[i] = IntPart (Stack(i), "Invalid array dimension"); + Value d = Stack(i); + dims[i] = IntPart (d, "Invalid array dimension"); + if (dims[i] < 0) + RaiseStandardException (exception_invalid_argument, + "Negative array dimension", + 2, NewInt (0), d); if (aborting) RETURN (0); } @@ -343,7 +348,12 @@ dims = AllocateTemp (ndim * sizeof (int)); for (i = 0; i < ndim; i++) { - dims[i] = IntPart (ArrayValueGet(a, i), "Invalid array dimension"); + Value d = ArrayValueGet(a, i); + dims[i] = IntPart (d, "Invalid array dimension"); + if (dims[i] < 0) + RaiseStandardException (exception_invalid_argument, + "Negative array dimension", + 2, NewInt (0), d); if (aborting) RETURN (0); } From commit at keithp.com Mon Nov 22 21:02:10 2004 From: commit at keithp.com (Bart Massey) Date: Mon Nov 22 21:02:16 2004 Subject: [Commit] nickle ChangeLog,1.100,1.101 builtin-toplevel.c,1.27,1.28 Message-ID: Committed by: bart Update of /local/src/CVS/nickle In directory home.keithp.com:/tmp/cvs-serv22282 Modified Files: ChangeLog builtin-toplevel.c Log Message: * builtin-toplevel.5c: Change dims() to return dimensions in order consistent with array defns, setdims(), etc. Bug discovered by Jeremy Greenwald. Index: ChangeLog =================================================================== RCS file: /local/src/CVS/nickle/ChangeLog,v retrieving revision 1.100 retrieving revision 1.101 diff -u -d -r1.100 -r1.101 --- ChangeLog 19 Nov 2004 06:53:05 -0000 1.100 +++ ChangeLog 23 Nov 2004 05:02:07 -0000 1.101 @@ -1,3 +1,10 @@ +2004-11-22 Bart Massey + + * builtin-toplevel.5c: + Change dims() to return dimensions in order + consistent with array defns, setdims(), etc. + Bug discovered by Jeremy Greenwald. + 2004-11-18 Keith Packard * examples/sort.5c: Index: builtin-toplevel.c =================================================================== RCS file: /local/src/CVS/nickle/builtin-toplevel.c,v retrieving revision 1.27 retrieving revision 1.28 diff -u -d -r1.27 -r1.28 --- builtin-toplevel.c 22 Jul 2004 19:42:06 -0000 1.27 +++ builtin-toplevel.c 23 Nov 2004 05:02:07 -0000 1.28 @@ -450,9 +450,9 @@ int ndim = av->array.ndim; ret = NewArray(True, False, typePrim[rep_int], 1, &ndim); - for (i = 0; i < av->array.ndim; i++) { + for (i = 0; i < ndim; i++) { Value d = NewInt(ArrayLimits(&av->array)[i]); - ArrayValueSet(&ret->array, i, d); + ArrayValueSet(&ret->array, ndim - i - 1, d); } RETURN (ret); } From commit at keithp.com Sun Nov 28 22:37:09 2004 From: commit at keithp.com (Keith Packard) Date: Sun Nov 28 22:37:15 2004 Subject: [Commit] papers/mint_2004 - New directory,NONE,NONE Message-ID: Committed by: keithp Update of /local/src/CVS/papers/mint_2004 In directory home.keithp.com:/tmp/cvs-serv20616/mint_2004 Log Message: Directory /local/src/CVS/papers/mint_2004 added to the repository --- NEW FILE: - New directory --- From commit at keithp.com Sun Nov 28 22:40:11 2004 From: commit at keithp.com (Keith Packard) Date: Sun Nov 28 22:40:22 2004 Subject: [Commit] papers/mint_2004 Makefile, NONE, 1.1 abstract.tex, NONE, 1.1 lola.tex, NONE, 1.1 mint.tex, NONE, 1.1 nickle.tex, NONE, 1.1 outline, NONE, 1.1 Message-ID: Committed by: keithp Update of /local/src/CVS/papers/mint_2004 In directory home.keithp.com:/tmp/cvs-serv20762 Added Files: Makefile abstract.tex lola.tex mint.tex nickle.tex outline Log Message: Add mint paper --- NEW FILE: Makefile --- .SUFFIXES: .tex .dvi .aux .eps .fig .dia .ps .pdf .bib .bbl TOP=mint TEXFILES=$(TOP).tex \ abstract.tex \ lola.tex \ nickle.tex all: $(TOP).ps $(TOP).pdf $(TOP).www/$(TOP).html .PHONY: subdirs subdirs: #subdirs: # @${MAKE} -C figures ${MAKECMDGOALS} # @${MAKE} -C examples ${MAKECMDGOALS} FIGFILES:=$(wildcard *.fig) EPSFILES:=$(wildcard *.eps) EPSFILES+=$(FIGFILES:.fig=.eps) PDFFILES=$(EPSFILES:.eps=.pdf) .fig.eps: fig2dev -L eps $< >$@ .fig.pdf: fig2dev -L pdf $< >$@ .eps.pdf: epstopdf $< $(TOP).ps: $(TOP).dvi dvips -t letter -o $(TOP).ps $(TOP) $(TOP).dvi: $(TEXFILES) $(EPSFILES) subdirs latex $(TOP) || true bibtex $(TOP) || true latex $(TOP) || true latex $(TOP) $(TOP).pdf: $(TEXFILES) $(PDFFILES) pdflatex $(TOP) || true bibtex $(TOP) || true pdflatex $(TOP) || true pdflatex $(TOP) $(TOP).www/$(TOP).html: $(TOP).www $(TEXFILES) latex2html -white -dir $(TOP).www -split 0 -no_navigation $(TOP).tex $(TOP).www: mkdir -p $@ clean: subdirs rm -f *.aux *.dvi *.log rm -f $(TOP).ps $(TOP).pdf $(TOP).bbl $(TOP).blg rm -rf $(TOP).www --- NEW FILE: abstract.tex --- \abstract The Nickle programming language extends C-like syntax and semantics to accomodate modern programming techniques and styles. As such, it is a nice language for implementing automated language recognizers. In addition, its syntax presents some unique challenges to automatic language recognition. The MINT translator is a tool for producing automatic translators from a wide variety of target languages to parse trees in the form of abstract syntax trees. These translators have broad application beyond the Nickle environment. To achieve this goal, the MINT architecture has been factored in a fashion developed some time ago by the authors. This split is used to allow the generated translator to operate in a wide range of languages. MINT has already proven to be a useful tool, and work is underway to extend it to a production-quality application. --- NEW FILE: lola.tex --- \section{Lola and Flo: Language independent LL parser generation} Lola was an LL parser generator written in 1987 in the Kalypso dialect of lisp (a research language focusing on functional lisp programming). As with MINT, the output of the parser generator was a language independent data structure which could drive parser frameworks in multiple languages. Parsers for the Lola output were written in C, Pascal and Kalypso. \begin{figure} \begin{verbatim} ; ; this grammar recognises integer ; expressions involving +,-,*,/ and unary - ; ( (lines (expr "PRINT" \n lines) (\n lines) () ) (expr (term + term "ADD") (term - term "SUBTRACT") (term) ) (term (fact * fact "MULTIPLY") (fact / fact "DIVIDE") (fact) ) (fact (|(| expr |)|) (int "PUSH") (- fact "NEGATE") ) (int ("CLEAR" "ADD-DIGIT" digit digits) ) (digits ("ADD-DIGIT" digit digits) () ) (digit (|0|) (|1|) (|2|) (|3|) (|4|) (|5|) (|6|) (|7|) (|8|) (|9|) ) ) \end{verbatim} \caption{A sample Lola grammar}\label{fig-lola-grammar} \end{figure} The Flo tool was a grammar-to-grammar transformation tool to factor left common sub-expressions out of a grammar to permit more compact and easier to understand representations of LL(1) languages. It was also written in Kalypso. Grammars are represented in lisp s-expressions as see in Figure~\ref{fig-lola-grammar}, eliminating the need for a custom grammar parser and permitting easier grammar-to-grammar transformation tool development. Semantic attributes were attached to the grammar in the form of special tokens in the right side of each grammar production. The parser would then perform the semantic operation when the action appeared on the top of the stack. The ability to analyse grammars and systematically catch language design and grammar errors long before sample language sentences were applied to the parser provided a higher degree of confidence in the correctness of the resulting parsing application. The ability to produce parsers in one of many languages encouraged the use of this higher level tool in place of ad-hoc parsers on several occasions. \subsection{Configuration Languages with Lola} Lola and Flo were first used to produce an ANSI X3.64 character terminal implementation in Pascal. Using a parser generator allows the development of an implementation artifact much closer in syntax and style to the ANSI specification than the traditional maze of twisty low level language code. Formal testing of this implementation demonstrated that it would correctly parse the standard ASCII control sequences. The lack of parsing correctness in many existing adhoc ANSI X3.64 implementations reinforces the use of higher level parsing tools in such designs. As the parser itself was written in a fairly low-level language (Pascal), performance of the resulting implementation easily met the performance requirements. >From that point forward, Lola and Flo were used together to produce parsers for a variety of domain-specific languages supporting application configuration and customization. These implementations were characterized by: \begin{itemize} \item Incomplete and changing specifications. Not only were the elements of the configuration constantly changing as the specification for the application was adjusted with reference to the ongoing implementation, but the syntax of the language changed as whole new classes of configuration information were incorporated into the system. \item Unknown parsability. The configuration requirements for some pieces of the system were provided by developers ignorant of the limitations of a context free grammar. \item Target platform under development. With the final execution location of the parser still in the hardware design phase, having many existing parser implementations provide for unit testing during initial development. \item Lexer also under constant development. Without an automatic lexer generator, the hand-crafted lexer turned out to be a significant development effort. Using an existing simplistic tokenizing lexer allowed grammar changes to be tested in advance of lexer reimplementation. \end{itemize} With the grammar validated by the automatic parser generator, the possiblity for parser errors due to changes in the input language was greatly reduced. This allowed changes to be rolled into the system late in the development process. \subsection{Parser Implementation Languages} With parsers available in several languages, LL language grammars could be rapidly tested in the command-line environment provided by Kalypso and only when working properly would they be transferred to a parser written in the target execution language. Not only did this reduce development time of the parser by speeding the turn-around from change to test, it also provide a built-in lexer in the form of the lisp s-expression recognition code. In the case of the X3.64 parser, a Kalypso lexer was built enabling end-to-end regression testing against the final Pascal implementation. \subsection{Limitations of Lola and Flo} Lola and Flo were designed for LL languages. This domain restriction was acceptable for the tasks it was originally designed for in 1987, but as a general purpose parser generator, the restriction is onerous today. An LL parser requires significantly less table space and processing than the typical LR or even LALR parser, something occasionally relevant on the machines common in that era. As can be seen in the example grammar above, even the Flo tool which could factor common left sub-expressions wasn't sufficient to present grammars in their most natural form (cf the awkward int/digits productions). Also, the semantic action mechanism is as context-free as the grammar itself, requiring the parser track significant language state on its own, in particular it does not provide a mechanism for producing a parse tree. Probably the most significant limitation for these tools today is that the implementation language, Kalypso, has been effectively retired from general use, making further development and improvement problematic. --- NEW FILE: mint.tex --- \documentclass{article} \title{MINT Is A Nickle Translator\\ Generating Cross-Lingual Recognizers } \author{Emma Kuo \and James LaMar \and Bart Massey\\ Portland State University \and Keith Packard\\ Hewlett-Packard Company} \begin{document} \maketitle \input{abstract} \input{lola} \input{nickle} \end{document} --- NEW FILE: nickle.tex --- \section{The Nickle Programming Language} --- NEW FILE: outline --- Bart's draft of 2004/11/20 18:05 PDT MINT Is a Nickle Translator: Generating Cross-Lingual Recognizers (alphabetical?) Emma Kuo, James LaMar, Bart Massey, Keith Packard Portland State University Abstract The Nickle programming language extends C-like syntax and semantics to accomodate modern programming techniques and styles. As such, it is a nice language for implementing automated language recognizers. In addition, its syntax presents some unique challenges to automatic language recognition. The MINT translator is a tool for producing automatic translators from a wide variety of target languages to parse trees in the form of abstract syntax trees. These translators have broad application beyond the Nickle environment. To achieve this goal, the MINT architecture has been factored in a fashion developed some time ago by the authors. This split is used to allow the generated translator to operate in a wide range of languages. MINT has already proven to be a useful tool, and work is underway to extend it to a production-quality application. + Recognizer Generators [Bart] + Parser generators + Why + RD, LL(1), LL(K), LALR(1), LR(1), etc: brief descriptions and example systems + Limitations + want lexing separated + validation/expressivity tradeoffs + Lexer generators + Lex, FLEX, etc + Interfacing to Parser Generators + Parse Tree and AST construction + Tree construction + Semantic actions + Problem summary + An early solution: LOLA/FLO [Keith] + Generate LL(1) parse tables in kalypso + Kalypso + FLO + Applications + Build parser in any target language + Problems with LOLA/FLO + Kalypso is dead + No lexer generator (??) + Even with FLO, restrictive language + Connecting ASTs to grammar across FLO + Nickle [Keith] + Introduction to Nickle + Nickle's translator is hard + Places where modified C grammar is painful + Places where connecting syntax and semantics is painful + Nickle is good for translator generation + Types, GC, nice initializer syntax, interactivity, etc. + Limitations of Nickle-based translators + Nickle is not a popular language + Nickle lexers/parsers would be slooow... + Hard to use Nickle lexers/parsers from other langs + MINT [James, Emma] + Design + LOLA/FLO-style split between generator + lexer and between generator + parser [fig] + Lexer and parser isolated in libraries + Generates Canonical LR(1) parsers + Produces ASTs + Implementation + Code base + Bootstrapping + Achieving goals + Translators in MINT [James, Emma] + Target language examples + regexp + BNF + Nickle subset + Backend language examples + Nickle + C (?) + Future Work [Bart] + Expand generator functionality + Bootstrap Nickle compiler + Conclusions [Bart] From commit at keithp.com Sun Nov 28 23:58:19 2004 From: commit at keithp.com (Keith Packard) Date: Sun Nov 28 23:58:31 2004 Subject: [Commit] papers/mint_2004 ChangeLog, NONE, 1.1 Makefile, 1.1, 1.2 abstract.tex, 1.1, 1.2 bib.bib, NONE, 1.1 lola.tex, 1.1, 1.2 mint.tex, 1.1, 1.2 nickle.tex, 1.1, 1.2 Message-ID: Committed by: keithp Update of /local/src/CVS/papers/mint_2004 In directory home.keithp.com:/tmp/cvs-serv21834 Modified Files: Makefile abstract.tex lola.tex mint.tex nickle.tex Added Files: ChangeLog bib.bib Log Message: 2004-11-28 Keith Packard * abstract.tex: Add {} to shut tex up. * Makefile: * mint.tex: * bib.bib: Add biblio entries * lola.tex: Grammar check a bit * nickle.tex: Add all text --- NEW FILE: ChangeLog --- 2004-11-28 Keith Packard * abstract.tex: Add {} to shut tex up. * Makefile: * mint.tex: * bib.bib: Add biblio entries * lola.tex: Grammar check a bit * nickle.tex: Add all text Index: Makefile =================================================================== RCS file: /local/src/CVS/papers/mint_2004/Makefile,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- Makefile 29 Nov 2004 06:40:09 -0000 1.1 +++ Makefile 29 Nov 2004 07:58:15 -0000 1.2 @@ -12,7 +12,6 @@ .PHONY: subdirs subdirs: -#subdirs: # @${MAKE} -C figures ${MAKECMDGOALS} # @${MAKE} -C examples ${MAKECMDGOALS} Index: abstract.tex =================================================================== RCS file: /local/src/CVS/papers/mint_2004/abstract.tex,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- abstract.tex 29 Nov 2004 06:40:09 -0000 1.1 +++ abstract.tex 29 Nov 2004 07:58:15 -0000 1.2 @@ -1,4 +1,4 @@ -\abstract +\abstract{} The Nickle programming language extends C-like syntax and semantics to accomodate modern programming techniques and styles. As such, it is a nice language for implementing --- NEW FILE: bib.bib --- @inproceedings{nickle:2001, title = "{Nickle: Language Principles and Pragmatics}", author = "Bart Massey and Keith Packard", booktitle = "FREENIX Track, 2001 Usenix Annual Technical Conference", month = "June", year = 2001, organization = "USENIX", address = "Boston, MA", url = "\url{http://www.usenix.org/publications/library/proceedings/usenix01/freenix01/massey.html}", } Index: lola.tex =================================================================== RCS file: /local/src/CVS/papers/mint_2004/lola.tex,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- lola.tex 29 Nov 2004 06:40:09 -0000 1.1 +++ lola.tex 29 Nov 2004 07:58:15 -0000 1.2 @@ -7,35 +7,37 @@ Parsers for the Lola output were written in C, Pascal and Kalypso. \begin{figure} +\footnotesize \begin{verbatim} ; ; this grammar recognises integer ; expressions involving +,-,*,/ and unary - ; ( -(lines (expr "PRINT" \n lines) - (\n lines) - () - ) -(expr (term + term "ADD") - (term - term "SUBTRACT") - (term) - ) -(term (fact * fact "MULTIPLY") - (fact / fact "DIVIDE") - (fact) - ) -(fact (|(| expr |)|) - (int "PUSH") - (- fact "NEGATE") - ) -(int ("CLEAR" "ADD-DIGIT" digit digits) - ) -(digits ("ADD-DIGIT" digit digits) - () - ) -(digit (|0|) (|1|) (|2|) (|3|) (|4|) (|5|) (|6|) (|7|) (|8|) (|9|) - ) +(lines (expr "PRINT" \n lines) + (\n lines) + () + ) +(expr (term + term "ADD") + (term - term "SUBTRACT") + (term) + ) +(term (fact * fact "MULTIPLY") + (fact / fact "DIVIDE") + (fact) + ) +(fact (|(| expr |)|) + (int "PUSH") + (- fact "NEGATE") + ) +(int ("CLEAR" "ADD-DIGIT" digit digits) + ) +(digits ("ADD-DIGIT" digit digits) + () + ) +(digit (|0|) (|1|) (|2|) (|3|) (|4|) + (|5|) (|6|) (|7|) (|8|) (|9|) + ) ) \end{verbatim} \caption{A sample Lola grammar}\label{fig-lola-grammar} @@ -44,7 +46,7 @@ The Flo tool was a grammar-to-grammar transformation tool to factor left common sub-expressions out of a grammar to permit more compact and easier to understand representations of LL(1) languages. It was also written in -Kalypso. Grammars are represented in lisp s-expressions as see in +Kalypso. Grammars are represented in lisp s-expressions as in Figure~\ref{fig-lola-grammar}, eliminating the need for a custom grammar parser and permitting easier grammar-to-grammar transformation tool development. Index: mint.tex =================================================================== RCS file: /local/src/CVS/papers/mint_2004/mint.tex,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- mint.tex 29 Nov 2004 06:40:09 -0000 1.1 +++ mint.tex 29 Nov 2004 07:58:15 -0000 1.2 @@ -1,5 +1,5 @@ -\documentclass{article} -\title{MINT Is A Nickle Translator\\ +\documentclass[twocolumn,12pt]{article} +\title{MINT Is A Nickle Translator:\\ Generating Cross-Lingual Recognizers } \author{Emma Kuo \and James LaMar \and Bart Massey\\ @@ -11,5 +11,7 @@ \input{abstract} \input{lola} \input{nickle} +\bibliography{bib} +\bibliographystyle{plain} \end{document} Index: nickle.tex =================================================================== RCS file: /local/src/CVS/papers/mint_2004/nickle.tex,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- nickle.tex 29 Nov 2004 06:40:09 -0000 1.1 +++ nickle.tex 29 Nov 2004 07:58:15 -0000 1.2 @@ -1,2 +1,140 @@ \section{The Nickle Programming Language} +The Nickle Programming Language\cite{nickle:2001} was developed as a C-like +procedural imperative language with strong types and several useful notions +adopted from the functional programming community. Originally targetted +twenty years ago as an algorithmic prototyping language, it has become more +generally useful as computer performance has increased over the last two +decades. + +\subsection{Polite Types} + +The Nickle type system provides both ``polite'' static typechecking along +with full dynamic typechecking. The rule for the compile-time checker is to +never reject a correct program. For example, the division operator `/', +when given integer operands, returns integer results only when the divisor +is evenly divisible by the dividend, otherwise it returns a ratioanl +result. The function: +\begin{verbatim} + int f (int a, int b) { return a / b; } +\end{verbatim} +is acceptable to the static typechecking system because it may produce an +integer result. Dynamic typechecking is inserted into the generated code to +check to make sure the result is of the right type at run-time. + +\subsection{Structured Values} + +Nickle includes an array of composite data types, from arrays and hash +tables to records and tagged unions. These behave much like their C +bretheren, with the exception of arrays which are first-class objects in +Nickle, unlike C. Assignment and function parameter passing is done by +value. + +Any non-recursive value within Nickle can be represented within the +compilation environment as a constant or initializer. This means that large +data structures can be generated entirely in-place and used in a dynamic +context, without resorting to intermediate variables. +\begin{verbatim} + h = (int [string]) { "hello" => 1, "world" => 2 } +\end{verbatim} +produces a hash table with the two given elements. A new hash table is +constructed each time the constant expression is evaluated. + +\subsection{Other Language Features} + +Nickle provides for namespaces which are similar to Java modules. This +provides a reasonably usable module mechanism with minimal overhead. +Standard libraries present their functionality entirely within a namespace +permitting brief names without cluttering the space for application names. + +The numeric system in Nickle provides three representations: + +\begin{enumerate} +\item Arbitrary precision integers +\item Arbitrary precision rationals +\item Arbitrary mantissa-length floats with arbitrary precision exponents +\end{enumerate} + +The semantics of all operators is well defined by the language specification +in all cases and is constant across all Nickle implementations. Rationals +are normally presented with `{' and `}' surrounding the repeating part of +the decimal expansion. Floating point numbers default to 256 bits of +mantissa, providing sufficient accuracy for iterative development +of numeric algorithms. + +From the functional programming community, Nickle inherits first-class +functions, closures and continuations. Nickle exposes continuations +throught the C-like setjmp/longjmp API which has proven a comprehensible +mechanism to programmers transitioning from purely imperative languages. + +A thread API is included to permit the development of parallel algorithms. +This includes threads, mutexes, semaphores and a fixed priority scheduler. + +\subsection{Well Defined Behaviour} + +Every operator in Nickle has a well defined behaviour; there are no +``implemenetation defined'' sections in the specification. Expressions in +Nickle are always evaluated left-to-right. Integers and rational values are +arbitrary precision, avoiding machine word size dependencies. Floating +point numbers have user-defined mantissa size and arbitrary precision +exponents, permitting precise numeric computations. These guarantees provide +a consistent and straightforward interpretation for Nickle programs in all +implementations. + +\subsection{The Nickle Grammar} + +With a sometimes painful adoption of C syntax, Nickle has stretched the +capabilities of existing parser generators significantly. There remain in +the current LALR grammar four reduce/reduce conflicts and one shift/reduce +conflict. The reduce/reduce conflicts are ``resolved'' by ensuring that the +more common expressions are accepted while the unusual ones rejected. +Obviously it would be nice if this artificial syntax restriction were +removed. + +The YACC-based tools provide only for synthesized attributes and Nickle +uses inherited attributes at some points in the parse. To work around this, +a kludge was inserted into the actions to store inherited attributes inside +the existing value stack using ``$0'' and ``$-2'' as positional values. + +Printing a function value produces a text representation of the function, so +the compiler must retain the entire parse tree. With YACC tools, a +hand-constructed tree is used. Each time the language syntax changes, this +code must be modified to match. + +\subsection{Using Nickle for Parser Generation} + +The choice of implementation language for any project is generally quite +important. Selecting the right language reduces the semantic gap between +problem and program representation. Contrarywise, the wrong language can +cause the programmer to spend large amounts of time in low level bookkeeping +algorithms and other semantic impedence matching code. + +As parser generation involves complex data structures and manipulations on +large sets of objects, a language which provides reasonable typechecking +along with automatic storage management seems like a good fit. As with Lola +and Flo above, the ability to interact with the parser immediately reduces +the time needed to verify changes in the grammar. + +All of these make Nickle a good choice for a parser generator implementation. + +\subsection{Using Nickle for Parsing} + +Given a Nickle-based parser generator, one possible result would be to force +developers to also use Nickle for the resulting parser. Such a B\&D approach +would not serve the developers well: + +\begin{enumerate} +\item Nickle is not a widely used language. As such, few developers would +be able to develop parsers. +\item Nickle is not a high performance language. With strictly defined +semantics and arbitrary precision numerics, the typical Nickle program runs +tens of times slower than equivalent C or Java code. A parser in Nickle +would probably not perform acceptably in most environments. +\item Parsers are often embedded in other applications. Attempting to +access a Nickle function from an existing application places significant +demands on the application developer. +\end{enumerate} + +Hence, while a good language for producing a parser generator, it would +behoove the designers to consider permitting other languages for the +final parser implementation. From commit at keithp.com Mon Nov 29 06:50:00 2004 From: commit at keithp.com (James LaMar) Date: Mon Nov 29 06:50:14 2004 Subject: [Commit] mint/doc - New directory,NONE,NONE Message-ID: Committed by: jlamar Update of /local/src/CVS/mint/doc In directory home.keithp.com:/tmp/cvs-serv27043/doc Log Message: Directory /local/src/CVS/mint/doc added to the repository --- NEW FILE: - New directory --- From commit at keithp.com Mon Nov 29 06:51:37 2004 From: commit at keithp.com (James LaMar) Date: Mon Nov 29 06:51:43 2004 Subject: [Commit] mint/grammars - New directory,NONE,NONE Message-ID: Committed by: jlamar Update of /local/src/CVS/mint/grammars In directory home.keithp.com:/tmp/cvs-serv27122/grammars Log Message: Directory /local/src/CVS/mint/grammars added to the repository --- NEW FILE: - New directory --- From commit at keithp.com Mon Nov 29 06:52:12 2004 From: commit at keithp.com (James LaMar) Date: Mon Nov 29 06:52:17 2004 Subject: [Commit] mint/src - New directory,NONE,NONE Message-ID: Committed by: jlamar Update of /local/src/CVS/mint/src In directory home.keithp.com:/tmp/cvs-serv27196/src Log Message: Directory /local/src/CVS/mint/src added to the repository --- NEW FILE: - New directory --- From commit at keithp.com Mon Nov 29 06:52:28 2004 From: commit at keithp.com (James LaMar) Date: Mon Nov 29 06:52:34 2004 Subject: [Commit] mint/src/generator_tables - New directory,NONE,NONE Message-ID: Committed by: jlamar Update of /local/src/CVS/mint/src/generator_tables In directory home.keithp.com:/tmp/cvs-serv27249/generator_tables Log Message: Directory /local/src/CVS/mint/src/generator_tables added to the repository --- NEW FILE: - New directory --- From commit at keithp.com Mon Nov 29 06:53:30 2004 From: commit at keithp.com (James LaMar) Date: Mon Nov 29 06:53:44 2004 Subject: [Commit] mint/grammars expgram.mnt, NONE, 1.1 nickle.mnt, NONE, 1.1 regram.mnt, NONE, 1.1 Message-ID: Committed by: jlamar Update of /local/src/CVS/mint/grammars In directory home.keithp.com:/tmp/cvs-serv27318/grammars Added Files: expgram.mnt nickle.mnt regram.mnt Log Message: Initial version. --- NEW FILE: expgram.mnt --- # # Mint test grammar # # The canonical expression grammar # # # Token section # tokens: token plus /\+/ token mult /\*/ token rparen /\(/ token lparen /\)/ token id /[A-Za-z0-9]/ skip whitespace /[ ]/ # # Operator precedence # precedence: left plus left mult # # Rules # rules: rule (E : plusexpr) -> (E : op1) plus (E : op2) rule (E : multexpr) -> (E : op1) mult (E : op2) rule (E : id) -> id rule (E : parenexpr) -> lparen (E : sub) rparen --- NEW FILE: nickle.mnt --- # # A small test grammar for a programming language # (A subset of nickle) # tokens: token typedef /typedef/ token return /return/ token if /if/ token for /for/ token while /while/ token semicolon /;/ token colon /:/ token union /union/ token struct /struct/ token true /true/ token false /false/ token int /[0-9][0-9]*|-[0-9][0-9]*/ token real /[0-9]*\.[0-9]/ token string /"[^"]*"/ token assign /=/ token equal /==/ token notequal /!=/ token greaterthan />/ token lessthan /=/ token lequal /<=/ token plus /\+/ token minus /-/ token star /\*/ token slash /\// token doubleslash /\/\// token lparen /\(/ token rparen /\)/ token lbrace /\[/ token rbrace /\]/ token dot /\./ token lbrack /\{/ token rbrack /\}/ token id /[a-zA-Z_][a-zA-Z0-9_]*/ token ampersand /&/ skip whitespace /[ ]/ precedence: right assign left equal notequal greaterthan lessthan gequal lequal left plus minus left star slash doubleslash left lbrace left ampersand left dot left id int rules: rule (stmt_list : empty) -> rule (stmt_list : list) -> (stmt : head) (stmt_list : tail) rule (stmt : expr) -> (expr : expr) semicolon rule (stmt : typedef) -> typedef (type : type) (id : name) rule (stmt : funcdecl) -> (type : return_type) (id : name) lparen (formal_list : formals) rparen (stmt : body) rule (stmt : block) -> lbrack (stmt_list : stmts) rbrack rule (stmt : return) -> return (expr : op1) semicolon rule (stmt : if) -> if lparen (expr : condition) rparen (stmt : body) rule (stmt : for) -> for lparen (expr : initializer) semicolon (expr : condition) semicolon (expr : iteration) rparen (stmt : body) rule (stmt : while) -> while lparen (expr : condition) rparen (stmt : body) rule (vardecl : var) -> (type : type) (id : id) rule (vardecl_list : empty) -> rule (vardecl_list : list) -> (vardecl : head) semicolon (vardecl_list : tail) rule (type : id) -> id rule (type : struct) -> struct lbrace (vardecl_list : vardecls) rbrace rule (type : union) -> union lbrace (vardecl_list : vardecls) rbrace rule (type : array) -> (type : type) lbrace star rbrace rule (formal_list : empty) -> rule (formal_list : single) -> (vardecl : head) rule (formal_list : list) -> (vardecl : head) comma (formal_list : tail) rule (expr : assign) -> (expr : op1) assign (expr : op2) rule (expr : lessthanexpr) -> (expr : op1) lessthan (expr : op2) rule (expr : greaterthanexpr) -> (expr : op1) greaterthan (expr : op2) rule (expr : gequalexpr) -> (expr : op1) gequal (expr : op2) rule (expr : lequalexpr) -> (expr : op1) lequal (expr : op2) rule (expr : equalexpr) -> (expr : op1) equal (expr : op2) rule (expr : notequalexpr) -> (expr : op1) notequal (expr : op2) rule (expr : plusexpr) -> (expr : op1) plus (expr : op2) rule (expr : minusexpr) -> (expr : op1) minus (expr : op2) rule (expr : multexpr) -> (expr : op1) star (expr : op2) rule (expr : divexpr) -> (expr : op1) slash (expr : op2) rule (expr : idivexpr) -> (expr : op1) doubleslash (expr : op2) rule (expr : parenexpr) -> lparen (expr : op1) rparen rule (expr : id) -> id rule (expr : int) -> int rule (expr : string) -> string rule (expr : arrayderef) -> (expr : array) lbrace (expr : index) rbrace rule (expr : refderef) -> ampersand (expr : ref) rule (expr : structderef) -> (expr : structure) dot (id : field) rule (expr : callexpr) -> (id : name) lparen (param_list : param) rparen rule (expr : vardeclexpr) -> (vardecl : vardecl) rule (param_list : empty) -> rule (param_list : single) -> (expr : head) rule (param_list : list) -> (expr : head) comma (param_list : tail) --- NEW FILE: regram.mnt --- # # Regular expression grammar # tokens: token star /\*/ token pipe /\|/ token lparen /\(/ token rparen /\)/ token invlbrace /\[^/ [setlexer = cclass] token lbrace /\[/ [setlexer = cclass] token rbrace (cclass) /\]/ [setlexer = default] token qmark /\?/ token dash (cclass) /-/ token esc (cclass default) /\\./ token lit (cclass default) /./ precedence: left invlbrace lbrace rbrace lit esc lparen rparen left star qmark left cat left pipe rules: rule (E : alt) -> (E : op1) pipe (E : op2) rule (E : cat) -> (E : op1) (E : op2) [precedence = cat] rule (E : closure) -> (E : op) star rule (E : qmark) -> (E : op) qmark rule (E : paren) -> lparen (E : op) rparen rule (E : cclass ) -> lbrace (cc_data : ranges) rbrace rule (E : invcclass ) -> invlbrace (cc_data : ranges) rbrace rule (E : literal) -> (literal : val) rule (cc_data : cc_list_empty) -> rule (cc_data : cc_list) -> (cc_elt : head) (cc_list : tail) rule (cc_elt : single) -> (literal : val) rule (cc_elt : range) -> (literal : min) dash (literal : max) rule (literal : literal) -> (lit : val) rule (literal : esclit) -> (esc : val) From commit at keithp.com Mon Nov 29 06:53:32 2004 From: commit at keithp.com (James LaMar) Date: Mon Nov 29 06:53:48 2004 Subject: [Commit] mint/src/generator_tables bnftbl.mtl, NONE, 1.1 bnftbl.mtp, NONE, 1.1 retbl.mtl, NONE, 1.1 retbl.mtp, NONE, 1.1 Message-ID: Committed by: jlamar Update of /local/src/CVS/mint/src/generator_tables In directory home.keithp.com:/tmp/cvs-serv27318/src/generator_tables Added Files: bnftbl.mtl bnftbl.mtp retbl.mtl retbl.mtp Log Message: Initial version. --- NEW FILE: bnftbl.mtl --- b lexer c states 84 b lexer_state c final 1 k 0 b final_state v "WHITESPACE" v normal v skip v remain c transitions 26 b lexer_transition v 1 v 9 v 9 b lexer_transition v 2 v 10 v 10 [...2217 lines suppressed...] v 26 v 65 v 90 b lexer_transition v 27 v 95 v 95 b lexer_transition v 28 v 97 v 122 b lexer_state c final 1 k 0 b final_state v "TOKENS" v normal v return_token v remain c transitions 0 --- NEW FILE: bnftbl.mtp --- b parse_table v 9 c action_table_entries 150 b table_entry k "RIGHT" k 21 b action v reduction v "nonassoc" v "precdecl" v 2 c fields_mapping 1 k 1 v "tokens" v none b table_entry k "RULE" k 64 b action [...1603 lines suppressed...] b table_entry k "lex_option" k 71 v 62 b table_entry k "option_list" k 12 v 60 b table_entry k "ruledecl" k 48 v 10 b table_entry k "id_list" k 5 v 51 b table_entry k "option" k 42 v 37 --- NEW FILE: retbl.mtl --- b lexer c states 12 b lexer_state c final 0 c transitions 13 b lexer_transition v 1 v 0 v 39 b lexer_transition v 2 v 40 v 40 b lexer_transition v 3 v 41 v 41 b lexer_transition v 4 v 42 v 42 b lexer_transition v 1 v 43 v 44 b lexer_transition v 5 v 45 v 45 b lexer_transition v 1 v 46 v 90 b lexer_transition v 6 v 91 v 91 b lexer_transition v 8 v 92 v 92 b lexer_transition v 10 v 93 v 93 b lexer_transition v 1 v 94 v 123 b lexer_transition v 11 v 124 v 124 b lexer_transition v 1 v 125 v 255 b lexer_state c final 2 k 0 b final_state v "LIT" v normal v return_token v remain k 1 b final_state v "LIT" v normal v return_token v remain c transitions 0 b lexer_state c final 2 k 0 b final_state v "LPAREN" v normal v return_token v remain k 1 b final_state v "LIT" v normal v return_token v remain c transitions 0 b lexer_state c final 2 k 0 b final_state v "RPAREN" v normal v return_token v remain k 1 b final_state v "LIT" v normal v return_token v remain c transitions 0 b lexer_state c final 2 k 0 b final_state v "STAR" v normal v return_token v remain k 1 b final_state v "LIT" v normal v return_token v remain c transitions 0 b lexer_state c final 2 k 0 b final_state v "LIT" v normal v return_token v remain k 1 b final_state v "DASH" v normal v return_token v remain c transitions 0 b lexer_state c final 2 k 0 b final_state v "LBRACE" v normal v return_token v change_start_condition v 1 k 1 b final_state v "LIT" v normal v return_token v remain c transitions 1 b lexer_transition v 7 v 94 v 94 b lexer_state c final 1 k 0 b final_state v "INVLBRACE" v normal v return_token v change_start_condition v 1 c transitions 0 b lexer_state c final 2 k 0 b final_state v "LIT" v normal v return_token v remain k 1 b final_state v "LIT" v normal v return_token v remain c transitions 1 b lexer_transition v 9 v 0 v 255 b lexer_state c final 2 k 0 b final_state v "ESCLIT" v normal v return_token v remain k 1 b final_state v "ESCLIT" v normal v return_token v remain c transitions 0 b lexer_state c final 2 k 0 b final_state v "LIT" v normal v return_token v remain k 1 b final_state v "RBRACE" v normal v return_token v change_start_condition v 0 c transitions 0 b lexer_state c final 2 k 0 b final_state v "PIPE" v normal v return_token v remain k 1 b final_state v "LIT" v normal v return_token v remain c transitions 0 --- NEW FILE: retbl.mtp --- b parse_table v 23 c action_table_entries 234 b table_entry k "PIPE" k 16 b action v reduction v "literal" v "RE" v 1 c fields_mapping 1 k 0 v "op1" v none b table_entry k "PIPE" k 19 b action [...2392 lines suppressed...] b table_entry k "LITERAL" k 29 v 40 b table_entry k "LITERAL" k 7 v 40 b table_entry k "LITERAL" k 24 v 31 b table_entry k "LITERAL" k 5 v 16 b table_entry k "CC" k 31 v 27 From commit at keithp.com Mon Nov 29 06:53:31 2004 From: commit at keithp.com (James LaMar) Date: Mon Nov 29 06:53:54 2004 Subject: [Commit] mint/src astprint.5c, NONE, 1.1 constructors.5c, NONE, 1.1 lexer_generator.5c, NONE, 1.1 lexer_io.5c, NONE, 1.1 lexer_runtime.5c, NONE, 1.1 mint.5c, NONE, 1.1 minttest.sh, NONE, 1.1 mintutil.5c, NONE, 1.1 parser_generator.5c, NONE, 1.1 parser_io.5c, NONE, 1.1 parser_runtime.5c, NONE, 1.1 tnode.5c, NONE, 1.1 Message-ID: Committed by: jlamar Update of /local/src/CVS/mint/src In directory home.keithp.com:/tmp/cvs-serv27318/src Added Files: astprint.5c constructors.5c lexer_generator.5c lexer_io.5c lexer_runtime.5c mint.5c minttest.sh mintutil.5c parser_generator.5c parser_io.5c parser_runtime.5c tnode.5c Log Message: Initial version. --- NEW FILE: astprint.5c --- (This appears to be a binary file; contents omitted.) --- NEW FILE: constructors.5c --- (This appears to be a binary file; contents omitted.) --- NEW FILE: lexer_generator.5c --- (This appears to be a binary file; contents omitted.) --- NEW FILE: lexer_io.5c --- (This appears to be a binary file; contents omitted.) --- NEW FILE: lexer_runtime.5c --- (This appears to be a binary file; contents omitted.) --- NEW FILE: mint.5c --- (This appears to be a binary file; contents omitted.) --- NEW FILE: minttest.sh --- #!/bin/sh nickle -l mintutil.5c -l lexer_runtime.5c -l parser_runtime.5c -l lexer_generator.5c -l parser_generator.5c -l constructors.5c -l lexer_io.5c -l parser_io.5c $1 --- NEW FILE: mintutil.5c --- (This appears to be a binary file; contents omitted.) --- NEW FILE: parser_generator.5c --- (This appears to be a binary file; contents omitted.) --- NEW FILE: parser_io.5c --- (This appears to be a binary file; contents omitted.) --- NEW FILE: parser_runtime.5c --- (This appears to be a binary file; contents omitted.) --- NEW FILE: tnode.5c --- (This appears to be a binary file; contents omitted.) From commit at keithp.com Mon Nov 29 06:53:30 2004 From: commit at keithp.com (James LaMar) Date: Mon Nov 29 06:53:59 2004 Subject: [Commit] mint/doc draft1.txt, NONE, 1.1 fig1.fig, NONE, 1.1 regex.txt, NONE, 1.1 Message-ID: Committed by: jlamar Update of /local/src/CVS/mint/doc In directory home.keithp.com:/tmp/cvs-serv27318/doc Added Files: draft1.txt fig1.fig regex.txt Log Message: Initial version. --- NEW FILE: draft1.txt --- + MINT [James, Emma] + Design + LOLA/FLO-style split between generator + lexer and between generator + parser [fig] + Lexer and parser isolated in libraries + Generates Canonical LR(1) parsers + Produces ASTs + Implementation + Code base + Bootstrapping + Achieving goals Design There are three elements in the design of MINT that differentiate it from traditional parser and lexer generators such as YACC and LEX. First, MINT implements a canonical LR(1) parser rather than SLR or LALR. Processor speeds and memory capacities have grown enough in the twenty years since parsing techniques were first developed that it was deemed unecessary to implement a more complex algorithm in order to achieve a (possibly modest) table size reduction. Second, rather than targetting a specific output language such as C, MINT generates language independent lexing and parsing tables, which can then be loaded by lexer/parser libraries (the MINT runtime) implemented in the desired target language. Third, MINT does not allow one to execute arbitary actions during the parsing of input. Instead, MINT constructs an abstract syntax tree. Grammar rules may additionally allow the special action of changing the lexer state (also known as start condition in flex-like parser generators.) This restriction on actions is due to the difficulty of specifying arbitrary actions when the target language is unknown, as it is in the MINT architecture. [fig1: MINT architecture] The design of MINT is split into two main sections: the MINT parser and lexer generator, implemented in Nickle, and the MINT runtime, which is currently implemented in Nickle but may be extended to other languages. The output parsing and lexing tables are generated in a simple line-oriented ASCII format that is easily parsed. Other formats such as XML were considered, but dismissed as overly complicated for this initial proof-of-concept application. Additionally, since the lexer passes tokens to the parser, they need to agree on a standard set of token specifications. As stated above, MINT generates an abstract syntax tree after successfully parsing a string. The advantage of this is that MINT can parser generators targetting arbitrary back-ends written in multiple languages. Implementation The lexer generator uses Thompson's construction and an NFA to DFA conversion to create the lexing table. Minimum-state DFA and table compaction methods were not used. The lexer is a standard DFA based algorithm with three enhancements: lexer states (aka "start conditions"), lookahead patterns, and arbitrary size character sets. Because no code generation is performed at at lexer generation time, the lexer cannot perform arbitrary actions upon a rule match. The only allowed actions are "return a token" and "none." Additionally the lexer may change its own state upon matching a lexeme. MINT implements lexer states that are similar to the "start conditions" present in FLEX. At any point in time, the lexer is in one and only one state. Lexer matching rules only match if the lexer is in the correct state. Rules may match in more than one state. This is typically used to implement different "modes" of lexing-- for example, "string mode," or "comment mode." The lexer's state may be changed internally, by the lexer's own rule actions, or externally by a call from the parser. Lookahead patterns are implemented subject to the same restrictions as for FLEX. That is, lookahead patterns such as "ab*/b" are not allowed. Finally, the lexer can handle character sets of arbitrary size, and this should be particularly useful with Unicode. Because a lookup table would grow impractically large with such a large character set, MINT's lexer implements the lexing table as an adjacency list and transitions are matched based on character ranges. The LR(1) parser generator algorithm is taken straight from the classic text by Aho, Sethi, and Ullman. We decided to implement LR(1) as opposed to SLR or LALR due to the simplicity of this algorithm and the fact that memory sizes are large enough now that the compactness of the tables is not so much of an issue. [cite table size statistics for different algorithms] The parser generator is additionally augmented with "precedence rules" to resolve shift/reduce conflicts. Achieving goals MINT was able to generate parsers for the regular expression and BNF syntaxes fairly easily. Attempting to generate a parse table for a small Nickle subset proved to be more difficult, however. --- NEW FILE: fig1.fig --- #FIG 3.2 Portrait Center Inches Letter 100.00 Single -2 1200 2 6 5203 3039 5718 3586 6 5258 3155 5663 3470 4 0 0 50 0 4 10 0.0000 2 150 405 5258 3275 lexing\001 4 0 0 50 0 4 10 0.0000 2 120 330 5258 3470 table\001 -6 2 2 0 1 0 7 50 0 -1 4.000 0 0 -1 0 0 5 5203 3039 5718 3039 5718 3586 5203 3586 5203 3039 -6 6 3000 2636 7080 2786 4 0 0 50 0 4 10 0.0000 2 120 930 6150 2756 MINT runtime\001 4 0 0 50 0 4 10 0.0000 2 120 645 5107 2756 table files\001 4 0 0 50 0 4 10 0.0000 2 150 1530 3000 2756 parser/lexer generator\001 -6 6 5200 4037 5715 4585 6 5202 4138 5712 4483 4 0 0 50 0 4 10 0.0000 2 120 330 5202 4483 table\001 4 0 0 50 0 4 10 0.0000 2 150 510 5202 4258 parsing\001 -6 2 2 0 1 0 7 50 0 -1 4.000 0 0 -1 0 0 5 5200 4037 5715 4037 5715 4585 5200 4585 5200 4037 -6 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 1 1 2.00 51.54 103.08 4655 3296 5203 3296 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 1 1 2.00 51.54 103.08 4655 4295 5203 4295 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 1 1 2.00 51.54 103.08 5718 3296 6266 3296 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 1 1 2.00 51.54 103.08 5718 4295 6266 4295 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 1 1 2.00 51.54 103.08 6620 3586 6620 4037 2 1 0 1 0 7 50 0 -1 6.000 0 0 -1 1 0 4 1 1 2.00 51.54 103.08 3560 3747 3689 3747 3689 3296 3914 3296 2 1 0 1 0 7 50 0 -1 6.000 0 0 -1 1 0 4 1 1 2.00 51.54 103.08 3560 3844 3689 3844 3689 4295 3914 4295 2 1 0 1 0 7 50 0 -1 6.000 0 0 -1 1 0 2 1 1 2.00 51.54 103.08 2432 3779 2819 3779 2 4 1 1 0 7 50 0 -1 4.000 0 0 3 0 0 5 4816 4810 4816 2813 2593 2813 2593 4810 4816 4810 2 4 1 1 0 7 50 0 -1 4.000 0 0 3 0 0 5 7275 4800 7275 2813 6000 2813 6000 4800 7275 4800 2 4 1 1 0 7 50 0 -1 4.000 0 0 3 0 0 5 5850 4800 5850 2813 4977 2813 4977 4800 5850 4800 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 1 1 2.00 51.54 103.08 7548 3300 7009 3300 2 2 0 1 0 7 50 0 -1 4.000 0 0 -1 0 0 5 2819 3554 3560 3554 3560 4101 2819 4101 2819 3554 2 2 0 1 0 7 50 0 -1 4.000 0 0 -1 0 0 5 3914 3039 4655 3039 4655 3586 3914 3586 3914 3039 2 2 0 1 0 7 50 0 -1 4.000 0 0 -1 0 0 5 3914 4037 4655 4037 4655 4585 3914 4585 3914 4037 2 2 0 1 0 7 50 0 -1 4.000 0 0 -1 0 0 5 6266 3039 7007 3039 7007 3586 6266 3586 6266 3039 2 2 0 1 0 7 50 0 -1 4.000 0 0 -1 0 0 5 6266 4037 7007 4037 7007 4585 6266 4585 6266 4037 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 1 1 2.00 51.54 103.08 7009 4275 7557 4275 4 0 0 50 0 4 10 0.0000 2 120 600 1800 3900 grammar\001 4 0 0 50 0 4 10 0.0000 2 150 345 1800 3750 input\001 4 0 0 50 0 4 10 0.0000 2 150 690 7596 4315 parse tree\001 4 0 0 50 0 4 10 0.0000 2 120 435 2850 4022 parser\001 4 0 0 50 0 4 10 0.0000 2 120 600 2850 3872 grammar\001 4 0 0 50 0 4 10 0.0000 2 120 375 2850 3722 MINT\001 4 0 0 50 0 4 10 0.0000 2 120 330 3975 3260 lexer\001 4 0 0 50 0 4 10 0.0000 2 150 675 3975 3455 generator\001 4 0 0 50 0 4 10 0.0000 2 120 435 3975 4243 parser\001 4 0 0 50 0 4 10 0.0000 2 150 675 3975 4438 generator\001 4 0 0 50 0 4 10 0.0000 2 120 330 6471 3372 lexer\001 4 0 0 50 0 4 10 0.0000 2 120 435 6419 4341 parser\001 4 0 0 50 0 4 10 0.0000 2 150 795 7592 3355 input string\001 --- NEW FILE: regex.txt --- R1 -> R2 PIPE R1 | R2 R2 -> R3 R2 | R3 R3 -> R4 STAR | R4 PLUS | R4 QMARK | R4 RANGE | R4 R4 -> CHAR | CCLASS | DOT | LPAREN R1 RPAREN CCLASS -> LBRACKET (CHAR MINUS CHAR | CHAR)+ RBRACKET -> LBRACKET CARET (CHAR MINUS CHAR | CHAR)+ RBRACKET RANGE -> LBRACE NUMBER MINUS NUMBER RBRACE -> LBRACE NUMBER MINUS RBRACE -> LBRACE MINUS NUMBER RBRACE /* handled by lexer */ CHAR -> [^|*(){}[]-\] -> \[|*(){}[]-\] NUMBER -> [0-9]+ PIPE -> '|' STAR -> '*' PLUS -> '+' MINUS -> '-' CARET -> '^' QMARK -> '?' DOT -> '.' LPAREN -> '(' RPAREN -> ')' LBRACKET -> '[' RBRACKET -> ']' LBRACE -> '{' RBRACE -> '}' From commit at keithp.com Mon Nov 29 11:59:09 2004 From: commit at keithp.com (Emma Kuo) Date: Mon Nov 29 11:59:39 2004 Subject: [Commit] mint/doc architecture.fig, NONE, 1.1 architecture.pstex, NONE, 1.1 architecture.pstex_t, NONE, 1.1 fig1.fig, 1.1, NONE mintsec.tex, NONE, 1.1 Message-ID: Committed by: ekuo Update of /local/src/CVS/mint/doc In directory home.keithp.com:/tmp/cvs-serv4789 Added Files: architecture.fig architecture.pstex architecture.pstex_t mintsec.tex Removed Files: fig1.fig Log Message: --- NEW FILE: architecture.fig --- #FIG 3.2 Portrait Center Inches Letter 100.00 Single -2 1200 2 6 5203 3039 5718 3586 6 5258 3155 5663 3470 4 0 0 50 0 4 10 0.0000 2 150 405 5258 3275 lexing\001 4 0 0 50 0 4 10 0.0000 2 120 330 5258 3470 table\001 -6 2 2 0 1 0 7 50 0 -1 4.000 0 0 -1 0 0 5 5203 3039 5718 3039 5718 3586 5203 3586 5203 3039 -6 6 3000 2636 7080 2786 4 0 0 50 0 4 10 0.0000 2 120 930 6150 2756 MINT runtime\001 4 0 0 50 0 4 10 0.0000 2 120 645 5107 2756 table files\001 4 0 0 50 0 4 10 0.0000 2 150 1530 3000 2756 parser/lexer generator\001 -6 6 5200 4037 5715 4585 6 5202 4138 5712 4483 4 0 0 50 0 4 10 0.0000 2 120 330 5202 4483 table\001 4 0 0 50 0 4 10 0.0000 2 150 510 5202 4258 parsing\001 -6 2 2 0 1 0 7 50 0 -1 4.000 0 0 -1 0 0 5 5200 4037 5715 4037 5715 4585 5200 4585 5200 4037 -6 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 1 1 2.00 51.54 103.08 4655 3296 5203 3296 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 1 1 2.00 51.54 103.08 4655 4295 5203 4295 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 1 1 2.00 51.54 103.08 5718 3296 6266 3296 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 1 1 2.00 51.54 103.08 5718 4295 6266 4295 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 1 1 2.00 51.54 103.08 6620 3586 6620 4037 2 1 0 1 0 7 50 0 -1 6.000 0 0 -1 1 0 4 1 1 2.00 51.54 103.08 3560 3747 3689 3747 3689 3296 3914 3296 2 1 0 1 0 7 50 0 -1 6.000 0 0 -1 1 0 4 1 1 2.00 51.54 103.08 3560 3844 3689 3844 3689 4295 3914 4295 2 1 0 1 0 7 50 0 -1 6.000 0 0 -1 1 0 2 1 1 2.00 51.54 103.08 2432 3779 2819 3779 2 4 1 1 0 7 50 0 -1 4.000 0 0 3 0 0 5 4816 4810 4816 2813 2593 2813 2593 4810 4816 4810 2 4 1 1 0 7 50 0 -1 4.000 0 0 3 0 0 5 7275 4800 7275 2813 6000 2813 6000 4800 7275 4800 2 4 1 1 0 7 50 0 -1 4.000 0 0 3 0 0 5 5850 4800 5850 2813 4977 2813 4977 4800 5850 4800 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 1 1 2.00 51.54 103.08 7548 3300 7009 3300 2 2 0 1 0 7 50 0 -1 4.000 0 0 -1 0 0 5 2819 3554 3560 3554 3560 4101 2819 4101 2819 3554 2 2 0 1 0 7 50 0 -1 4.000 0 0 -1 0 0 5 3914 3039 4655 3039 4655 3586 3914 3586 3914 3039 2 2 0 1 0 7 50 0 -1 4.000 0 0 -1 0 0 5 3914 4037 4655 4037 4655 4585 3914 4585 3914 4037 2 2 0 1 0 7 50 0 -1 4.000 0 0 -1 0 0 5 6266 3039 7007 3039 7007 3586 6266 3586 6266 3039 2 2 0 1 0 7 50 0 -1 4.000 0 0 -1 0 0 5 6266 4037 7007 4037 7007 4585 6266 4585 6266 4037 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 1 1 2.00 51.54 103.08 7009 4275 7557 4275 4 0 0 50 0 4 10 0.0000 2 120 600 1800 3900 grammar\001 4 0 0 50 0 4 10 0.0000 2 150 345 1800 3750 input\001 4 0 0 50 0 4 10 0.0000 2 150 690 7596 4315 parse tree\001 4 0 0 50 0 4 10 0.0000 2 120 435 2850 4022 parser\001 4 0 0 50 0 4 10 0.0000 2 120 600 2850 3872 grammar\001 4 0 0 50 0 4 10 0.0000 2 120 375 2850 3722 MINT\001 4 0 0 50 0 4 10 0.0000 2 120 330 3975 3260 lexer\001 4 0 0 50 0 4 10 0.0000 2 150 675 3975 3455 generator\001 4 0 0 50 0 4 10 0.0000 2 120 435 3975 4243 parser\001 4 0 0 50 0 4 10 0.0000 2 150 675 3975 4438 generator\001 4 0 0 50 0 4 10 0.0000 2 120 330 6471 3372 lexer\001 4 0 0 50 0 4 10 0.0000 2 120 435 6419 4341 parser\001 4 0 0 50 0 4 10 0.0000 2 150 795 7592 3355 input string\001 --- NEW FILE: architecture.pstex --- %!PS-Adobe-2.0 EPSF-2.0 %%Title: architecture.pstex %%Creator: fig2dev Version 3.2 Patchlevel 4 %%CreationDate: Mon Nov 29 11:09:16 2004 %%For: emma@kyo (,,,) %%BoundingBox: 0 0 397 132 %%Magnification: 1.0000 %%EndComments /$F2psDict 200 dict def $F2psDict begin $F2psDict /mtrx matrix put /col-1 {0 setgray} bind def /col0 {0.000 0.000 0.000 srgb} bind def /col1 {0.000 0.000 1.000 srgb} bind def /col2 {0.000 1.000 0.000 srgb} bind def /col3 {0.000 1.000 1.000 srgb} bind def /col4 {1.000 0.000 0.000 srgb} bind def /col5 {1.000 0.000 1.000 srgb} bind def /col6 {1.000 1.000 0.000 srgb} bind def /col7 {1.000 1.000 1.000 srgb} bind def /col8 {0.000 0.000 0.560 srgb} bind def /col9 {0.000 0.000 0.690 srgb} bind def /col10 {0.000 0.000 0.820 srgb} bind def /col11 {0.530 0.810 1.000 srgb} bind def /col12 {0.000 0.560 0.000 srgb} bind def /col13 {0.000 0.690 0.000 srgb} bind def /col14 {0.000 0.820 0.000 srgb} bind def /col15 {0.000 0.560 0.560 srgb} bind def /col16 {0.000 0.690 0.690 srgb} bind def /col17 {0.000 0.820 0.820 srgb} bind def /col18 {0.560 0.000 0.000 srgb} bind def /col19 {0.690 0.000 0.000 srgb} bind def /col20 {0.820 0.000 0.000 srgb} bind def /col21 {0.560 0.000 0.560 srgb} bind def /col22 {0.690 0.000 0.690 srgb} bind def /col23 {0.820 0.000 0.820 srgb} bind def /col24 {0.500 0.190 0.000 srgb} bind def /col25 {0.630 0.250 0.000 srgb} bind def /col26 {0.750 0.380 0.000 srgb} bind def /col27 {1.000 0.500 0.500 srgb} bind def /col28 {1.000 0.630 0.630 srgb} bind def /col29 {1.000 0.750 0.750 srgb} bind def /col30 {1.000 0.880 0.880 srgb} bind def /col31 {1.000 0.840 0.000 srgb} bind def end save newpath 0 132 moveto 0 0 lineto 397 0 lineto 397 132 lineto closepath clip newpath -108.0 289.3 translate 1 -1 scale /cp {closepath} bind def /ef {eofill} bind def /gr {grestore} bind def /gs {gsave} bind def /sa {save} bind def /rs {restore} bind def /l {lineto} bind def /m {moveto} bind def /rm {rmoveto} bind def /n {newpath} bind def /s {stroke} bind def /sh {show} bind def /slc {setlinecap} bind def /slj {setlinejoin} bind def /slw {setlinewidth} bind def /srgb {setrgbcolor} bind def /rot {rotate} bind def /sc {scale} bind def /sd {setdash} bind def /ff {findfont} bind def /sf {setfont} bind def /scf {scalefont} bind def /sw {stringwidth} bind def /tr {translate} bind def /tnt {dup dup currentrgbcolor 4 -2 roll dup 1 exch sub 3 -1 roll mul add 4 -2 roll dup 1 exch sub 3 -1 roll mul add 4 -2 roll dup 1 exch sub 3 -1 roll mul add srgb} bind def /shd {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul 4 -2 roll mul srgb} bind def /$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def /$F2psEnd {$F2psEnteredState restore end} def $F2psBegin 10 setmiterlimit 0 slj 0 slc 0.06000 0.06000 sc % % Fig objects follow % % % here starts figure with depth 50 % Polyline 7.500 slw n 5203 3039 m 5718 3039 l 5718 3586 l 5203 3586 l cp gs col0 s gr % Polyline n 5200 4037 m 5715 4037 l 5715 4585 l 5200 4585 l cp gs col0 s gr % Polyline gs clippath 5218 3321 m 5218 3270 l 5067 3270 l 5171 3296 l 5067 3321 l cp eoclip n 4655 3296 m 5203 3296 l gs col0 s gr gr % arrowhead 15.000 slw n 5067 3321 m 5171 3296 l 5067 3270 l 5067 3321 l cp gs 0.00 setgray ef gr col0 s % Polyline 7.500 slw gs clippath 5218 4320 m 5218 4269 l 5067 4269 l 5171 4295 l 5067 4320 l cp eoclip n 4655 4295 m 5203 4295 l gs col0 s gr gr % arrowhead 15.000 slw n 5067 4320 m 5171 4295 l 5067 4269 l 5067 4320 l cp gs 0.00 setgray ef gr col0 s % Polyline 7.500 slw gs clippath 6281 3321 m 6281 3270 l 6130 3270 l 6234 3296 l 6130 3321 l cp eoclip n 5718 3296 m 6266 3296 l gs col0 s gr gr % arrowhead 15.000 slw n 6130 3321 m 6234 3296 l 6130 3270 l 6130 3321 l cp gs 0.00 setgray ef gr col0 s % Polyline 7.500 slw gs clippath 6281 4320 m 6281 4269 l 6130 4269 l 6234 4295 l 6130 4320 l cp eoclip n 5718 4295 m 6266 4295 l gs col0 s gr gr % arrowhead 15.000 slw n 6130 4320 m 6234 4295 l 6130 4269 l 6130 4320 l cp gs 0.00 setgray ef gr col0 s % Polyline 7.500 slw gs clippath 6594 4052 m 6645 4052 l 6645 3901 l 6620 4005 l 6594 3901 l cp eoclip n 6620 3586 m 6620 4037 l gs col0 s gr gr % arrowhead 15.000 slw n 6594 3901 m 6620 4005 l 6645 3901 l 6594 3901 l cp gs 0.00 setgray ef gr col0 s % Polyline 7.500 slw gs clippath 3929 3321 m 3929 3270 l 3778 3270 l 3882 3296 l 3778 3321 l cp eoclip n 3560 3747 m 3689 3747 l 3689 3296 l 3914 3296 l gs col0 s gr gr % arrowhead 15.000 slw n 3778 3321 m 3882 3296 l 3778 3270 l 3778 3321 l cp gs 0.00 setgray ef gr col0 s % Polyline 7.500 slw gs clippath 3929 4320 m 3929 4269 l 3778 4269 l 3882 4295 l 3778 4320 l cp eoclip n 3560 3844 m 3689 3844 l 3689 4295 l 3914 4295 l gs col0 s gr gr % arrowhead 15.000 slw n 3778 4320 m 3882 4295 l 3778 4269 l 3778 4320 l cp gs 0.00 setgray ef gr col0 s % Polyline 7.500 slw gs clippath 2834 3804 m 2834 3753 l 2683 3753 l 2787 3779 l 2683 3804 l cp eoclip n 2432 3779 m 2819 3779 l gs col0 s gr gr % arrowhead 15.000 slw n 2683 3804 m 2787 3779 l 2683 3753 l 2683 3804 l cp gs 0.00 setgray ef gr col0 s % Polyline 7.500 slw [60] 0 sd n 2638 2813 m 2593 2813 2593 4765 45 arcto 4 {pop} repeat 2593 4810 4771 4810 45 arcto 4 {pop} repeat 4816 4810 4816 2858 45 arcto 4 {pop} repeat 4816 2813 2638 2813 45 arcto 4 {pop} repeat cp gs col0 s gr [] 0 sd % Polyline [60] 0 sd n 6045 2813 m 6000 2813 6000 4755 45 arcto 4 {pop} repeat 6000 4800 7230 4800 45 arcto 4 {pop} repeat 7275 4800 7275 2858 45 arcto 4 {pop} repeat 7275 2813 6045 2813 45 arcto 4 {pop} repeat cp gs col0 s gr [] 0 sd % Polyline [60] 0 sd n 5022 2813 m 4977 2813 4977 4755 45 arcto 4 {pop} repeat 4977 4800 5805 4800 45 arcto 4 {pop} repeat 5850 4800 5850 2858 45 arcto 4 {pop} repeat 5850 2813 5022 2813 45 arcto 4 {pop} repeat cp gs col0 s gr [] 0 sd % Polyline gs clippath 6994 3274 m 6994 3325 l 7144 3325 l 7041 3300 l 7144 3274 l cp eoclip n 7548 3300 m 7009 3300 l gs col0 s gr gr % arrowhead 15.000 slw n 7144 3274 m 7041 3300 l 7144 3325 l 7144 3274 l cp gs 0.00 setgray ef gr col0 s % Polyline 7.500 slw n 2819 3554 m 3560 3554 l 3560 4101 l 2819 4101 l cp gs col0 s gr % Polyline n 3914 3039 m 4655 3039 l 4655 3586 l 3914 3586 l cp gs col0 s gr % Polyline n 3914 4037 m 4655 4037 l 4655 4585 l 3914 4585 l cp gs col0 s gr % Polyline n 6266 3039 m 7007 3039 l 7007 3586 l 6266 3586 l cp gs col0 s gr % Polyline n 6266 4037 m 7007 4037 l 7007 4585 l 6266 4585 l cp gs col0 s gr % Polyline gs clippath 7572 4300 m 7572 4249 l 7421 4249 l 7525 4275 l 7421 4300 l cp eoclip n 7009 4275 m 7557 4275 l gs col0 s gr gr % arrowhead 15.000 slw n 7421 4300 m 7525 4275 l 7421 4249 l 7421 4300 l cp gs 0.00 setgray ef gr col0 s % here ends figure; $F2psEnd rs showpage --- NEW FILE: architecture.pstex_t --- \begin{picture}(0,0)% \includegraphics{architecture.pstex}% \end{picture}% \setlength{\unitlength}{3947sp}% % \begingroup\makeatletter\ifx\SetFigFont\undefined% \gdef\SetFigFont#1#2#3#4#5{% \reset@font\fontsize{#1}{#2pt}% \fontfamily{#3}\fontseries{#4}\fontshape{#5}% \selectfont}% \fi\endgroup% \begin{picture}(6607,2186)(1801,-3983) \put(5259,-2436){\makebox(0,0)[lb]{\smash{{\SetFigFont{10}{12.0}{\sfdefault}{\mddefault}{\updefault}{\color[rgb]{0,0,0}lexing}% }}}} \put(5259,-2631){\makebox(0,0)[lb]{\smash{{\SetFigFont{10}{12.0}{\sfdefault}{\mddefault}{\updefault}{\color[rgb]{0,0,0}table}% }}}} \put(6151,-1917){\makebox(0,0)[lb]{\smash{{\SetFigFont{10}{12.0}{\sfdefault}{\mddefault}{\updefault}{\color[rgb]{0,0,0}MINT runtime}% }}}} \put(5108,-1917){\makebox(0,0)[lb]{\smash{{\SetFigFont{10}{12.0}{\sfdefault}{\mddefault}{\updefault}{\color[rgb]{0,0,0}table files}% }}}} \put(3001,-1917){\makebox(0,0)[lb]{\smash{{\SetFigFont{10}{12.0}{\sfdefault}{\mddefault}{\updefault}{\color[rgb]{0,0,0}parser/lexer generator}% }}}} \put(5203,-3644){\makebox(0,0)[lb]{\smash{{\SetFigFont{10}{12.0}{\sfdefault}{\mddefault}{\updefault}{\color[rgb]{0,0,0}table}% }}}} \put(5203,-3419){\makebox(0,0)[lb]{\smash{{\SetFigFont{10}{12.0}{\sfdefault}{\mddefault}{\updefault}{\color[rgb]{0,0,0}parsing}% }}}} \put(1801,-3061){\makebox(0,0)[lb]{\smash{{\SetFigFont{10}{12.0}{\sfdefault}{\mddefault}{\updefault}{\color[rgb]{0,0,0}grammar}% }}}} \put(1801,-2911){\makebox(0,0)[lb]{\smash{{\SetFigFont{10}{12.0}{\sfdefault}{\mddefault}{\updefault}{\color[rgb]{0,0,0}input}% }}}} \put(7597,-3476){\makebox(0,0)[lb]{\smash{{\SetFigFont{10}{12.0}{\sfdefault}{\mddefault}{\updefault}{\color[rgb]{0,0,0}parse tree}% }}}} \put(2851,-3183){\makebox(0,0)[lb]{\smash{{\SetFigFont{10}{12.0}{\sfdefault}{\mddefault}{\updefault}{\color[rgb]{0,0,0}parser}% }}}} \put(2851,-3033){\makebox(0,0)[lb]{\smash{{\SetFigFont{10}{12.0}{\sfdefault}{\mddefault}{\updefault}{\color[rgb]{0,0,0}grammar}% }}}} \put(2851,-2883){\makebox(0,0)[lb]{\smash{{\SetFigFont{10}{12.0}{\sfdefault}{\mddefault}{\updefault}{\color[rgb]{0,0,0}MINT}% }}}} \put(3976,-2421){\makebox(0,0)[lb]{\smash{{\SetFigFont{10}{12.0}{\sfdefault}{\mddefault}{\updefault}{\color[rgb]{0,0,0}lexer}% }}}} \put(3976,-2616){\makebox(0,0)[lb]{\smash{{\SetFigFont{10}{12.0}{\sfdefault}{\mddefault}{\updefault}{\color[rgb]{0,0,0}generator}% }}}} \put(3976,-3404){\makebox(0,0)[lb]{\smash{{\SetFigFont{10}{12.0}{\sfdefault}{\mddefault}{\updefault}{\color[rgb]{0,0,0}parser}% }}}} \put(3976,-3599){\makebox(0,0)[lb]{\smash{{\SetFigFont{10}{12.0}{\sfdefault}{\mddefault}{\updefault}{\color[rgb]{0,0,0}generator}% }}}} \put(6472,-2533){\makebox(0,0)[lb]{\smash{{\SetFigFont{10}{12.0}{\sfdefault}{\mddefault}{\updefault}{\color[rgb]{0,0,0}lexer}% }}}} \put(6420,-3502){\makebox(0,0)[lb]{\smash{{\SetFigFont{10}{12.0}{\sfdefault}{\mddefault}{\updefault}{\color[rgb]{0,0,0}parser}% }}}} \put(7593,-2516){\makebox(0,0)[lb]{\smash{{\SetFigFont{10}{12.0}{\sfdefault}{\mddefault}{\updefault}{\color[rgb]{0,0,0}input string}% }}}} \end{picture}% --- fig1.fig DELETED --- --- NEW FILE: mintsec.tex --- %+ MINT [James, Emma] % + Design % + LOLA/FLO-style split between generator + lexer and % between generator + parser [fig] % + Lexer and parser isolated in libraries + Generates Canonical % LR(1) parsers + Produces ASTs % + Implementation % + Code base + Bootstrapping % + Achieving goals \section{MINT} \subsection{Design} There are three elements in the design of MINT that differentiate it from traditional parser and lexer generators such as YACC and LEX. First, MINT implements a canonical LR(1) parser rather than SLR or LALR. Processor speeds and memory capacities have grown enough in the twenty years since parsing techniques were first developed that it was deemed unecessary to implement a more complex algorithm in order to achieve a (possibly modest) table size reduction. Second, rather than targetting a specific output language such as C, MINT generates language independent lexing and parsing tables, which can then be loaded by lexer/parser libraries (the MINT runtime) implemented in the desired target language. Third, MINT does not allow one to execute arbitary actions during the parsing of input. Instead, MINT constructs an abstract syntax tree. Grammar rules may additionally allow the special action of changing the lexer state (also known as start condition in flex-like parser generators.) This restriction on actions is due to the difficulty of specifying arbitrary actions when the target language is unknown, as it is in the MINT architecture. \begin{figure*}[htbp] \begin{center} \input{architecture.pstex_t} \caption{MINT Architecture} \label{figure:architecture} \end{center} \end{figure*} The design of MINT is split into two main sections: the MINT parser and lexer generator, implemented in Nickle, and the MINT runtime, which is currently implemented in Nickle but may be extended to other languages. The output parsing and lexing tables are generated in a simple line-oriented ASCII format that is easily parsed. Other formats such as XML were considered, but dismissed as overly complicated for this initial proof-of-concept application. Additionally, since the lexer passes tokens to the parser, they need to agree on a standard set of token specifications. As stated above, MINT generates an abstract syntax tree after successfully parsing a string. The advantage of this is that MINT can generate parsers targetting arbitrary back-ends written in multiple languages. \subsection{Implementation} The lexer generator uses Thompson's construction and an NFA to DFA conversion to create the lexing table. Minimum-state DFA and table compaction methods were not used. The lexer is a standard DFA based algorithm with three enhancements: lexer states (aka ``start conditions''), lookahead patterns, and arbitrary size character sets. Because no code generation is performed at at lexer generation time, the lexer cannot perform arbitrary actions upon a rule match. The only allowed actions are to return a token or ``none.'' Additionally the lexer may change its own state upon matching a lexeme. MINT implements lexer states that are similar to the ``start condition'' present in FLEX. At any point in time, the lexer is in one and only one state. Lexer matching rules only match if the lexer is in the correct state. Rules may match in more than one state. This is typically used to implement different modes of lexing-- for example, string mode, or comment mode. The lexer's state may be changed internally, by the lexer's own rule actions, or externally by a call from the parser. Lookahead patterns are implemented subject to the same restrictions as for FLEX. That is, lookahead patterns such as ``ab*/b'' are not allowed. Finally, the lexer can handle character sets of arbitrary size, and this should be particularly useful with Unicode. Because a lookup table would grow impractically large with such a large character set, MINT's lexer implements the lexing table as an adjacency list and transitions are matched based on character ranges. The LR(1) parser generator algorithm is taken straight from the classic text by Aho, Sethi, and Ullman. We decided to implement LR(1) as opposed to SLR or LALR due to the simplicity of this algorithm and the fact that memory sizes are large enough now that the compactness of the tables is not so much of an issue. [cite table size statistics for different algorithms] The parser generator is additionally augmented with precedence rules to resolve shift/reduce conflicts. \subsection{Achieving goals} MINT was able to generate parsers for the regular expression and BNF syntaxes fairly easily. Attempting to generate a parse table for a small Nickle subset proved to be more difficult, however. From commit at keithp.com Mon Nov 29 14:50:25 2004 From: commit at keithp.com (Bart Massey) Date: Mon Nov 29 14:50:36 2004 Subject: [Commit] mint/grammars expgram.mnt,1.1,1.2 Message-ID: Committed by: bart Update of /local/src/CVS/mint/grammars In directory home.keithp.com:/tmp/cvs-serv7527 Modified Files: expgram.mnt Log Message: Left paren: "(". Right paren: ")". Index: expgram.mnt =================================================================== RCS file: /local/src/CVS/mint/grammars/expgram.mnt,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- expgram.mnt 29 Nov 2004 14:53:27 -0000 1.1 +++ expgram.mnt 29 Nov 2004 22:50:23 -0000 1.2 @@ -11,8 +11,8 @@ token plus /\+/ token mult /\*/ -token rparen /\(/ -token lparen /\)/ +token lparen /\(/ +token rparen /\)/ token id /[A-Za-z0-9]/ skip whitespace /[ ]/ From commit at keithp.com Mon Nov 29 14:51:30 2004 From: commit at keithp.com (Bart Massey) Date: Mon Nov 29 14:51:37 2004 Subject: [Commit] mint/src mint.5c,1.1,1.2 Message-ID: Committed by: bart Update of /local/src/CVS/mint/src In directory home.keithp.com:/tmp/cvs-serv7597 Modified Files: mint.5c Log Message: Restructure driver slightly to make it easier to load and work with. Index: mint.5c =================================================================== RCS file: /local/src/CVS/mint/src/mint.5c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- mint.5c 29 Nov 2004 14:53:28 -0000 1.1 +++ mint.5c 29 Nov 2004 22:51:27 -0000 1.2 @@ -40,16 +40,15 @@ */ -load "mintutil.5c" -import Mintutil; -load "lexer_runtime.5c" -load "parser_runtime.5c" +autoimport Mintutil; +library "lexer_runtime.5c" +library "parser_runtime.5c" import Mint; -load "lexer_generator.5c" -load "parser_generator.5c" -load "parser_io.5c" -load "lexer_io.5c" -load "tnode.5c" +library "lexer_generator.5c" +library "parser_generator.5c" +library "parser_io.5c" +library "lexer_io.5c" +library "tnode.5c" parse_table pgptbl = load_parser("generator_tables/bnftbl.mtp"); parse_table reptbl = load_parser("generator_tables/retbl.mtp"); @@ -389,15 +388,14 @@ return create_parse_table(g); } -if(dim(argv) < 2) { - fprintf(stderr, "Usage: nickle mint.5c grammarfile\n"); -} else { - file f = open(top(argv), "r"); +void make_parser(string fname) { + file f = open(fname, "r"); printf("Parsing File...\n"); try ast a = parse_file(&pgptbl, &pglex, f); catch syntax_error(&lexer_context lc) { - printf("Syntax error on line %d -- before %s\n", lc.line_number, get_token(&lc).lexeme); - exit(1); + printf("Syntax error on line %d -- before %s\n", + lc.line_number, get_token(&lc).lexeme); + exit(1); } printf("Node Transform...\n"); t_node tn = t_node_transform(a); @@ -407,11 +405,18 @@ printf("Generating Parse Table...\n"); try parse_table ptbl = getparser(tn); catch ambiguous(set[int][string] c) { - printf("Grammar is ambiguous\n"); - /*conflict_print(c); */ - exit(1); + printf("Grammar is ambiguous\n"); + /*conflict_print(c); */ + exit(1); } - save_parser(ptbl,top(argv) + ".mtp"); - save_lexer(lex, top(argv) + ".mtl"); + save_parser(ptbl,fname + ".mtp"); + save_lexer(lex, fname + ".mtl"); } +if(dim(argv) > 0) { + if(dim(argv) < 2) { + fprintf(stderr, "Usage: nickle mint.5c grammarfile\n"); + exit(0); + } + make_parser(top(argv)); +}; From commit at keithp.com Mon Nov 29 21:16:11 2004 From: commit at keithp.com (Keith Packard) Date: Mon Nov 29 21:16:17 2004 Subject: [Commit] nickle ChangeLog,1.101,1.102 mem.c,1.20,1.21 Message-ID: Committed by: keithp Update of /local/src/CVS/nickle In directory home.keithp.com:/tmp/cvs-serv12763 Modified Files: ChangeLog mem.c Log Message: 2004-11-29 Keith Packard * mem.c: (newBlock), (MemAddRoot): Call to panic had wrong arguments and caused a segfault. Index: ChangeLog =================================================================== RCS file: /local/src/CVS/nickle/ChangeLog,v retrieving revision 1.101 retrieving revision 1.102 diff -u -d -r1.101 -r1.102 --- ChangeLog 23 Nov 2004 05:02:07 -0000 1.101 +++ ChangeLog 30 Nov 2004 05:16:08 -0000 1.102 @@ -1,3 +1,8 @@ +2004-11-29 Keith Packard + + * mem.c: (newBlock), (MemAddRoot): + Call to panic had wrong arguments and caused a segfault. + 2004-11-22 Bart Massey * builtin-toplevel.5c: Index: mem.c =================================================================== RCS file: /local/src/CVS/nickle/mem.c,v retrieving revision 1.20 retrieving revision 1.21 diff -u -d -r1.20 -r1.21 --- mem.c 10 Aug 2004 17:45:40 -0000 1.20 +++ mem.c 30 Nov 2004 05:16:08 -0000 1.21 @@ -80,7 +80,7 @@ return 0; b = (struct block *) malloc (size); if (!b) - panic (0, "out of memory - quiting\n"); + panic ("Out of memory\n"); } b->sizeIndex = sizeIndex; b->next = head; @@ -225,7 +225,7 @@ RootSize *= 2; roots = malloc (sizeof (void *) * RootSize); if (!roots) - panic ("out of memory"); + panic ("Out of memory"); memcpy (roots, Roots, RootCount * sizeof (void *)); if (Roots) free (Roots); From commit at keithp.com Mon Nov 29 21:27:56 2004 From: commit at keithp.com (Keith Packard) Date: Mon Nov 29 21:28:01 2004 Subject: [Commit] nickle ChangeLog,1.102,1.103 configure.in,1.37,1.38 Message-ID: Committed by: keithp Update of /local/src/CVS/nickle In directory home.keithp.com:/tmp/cvs-serv13009 Modified Files: ChangeLog configure.in Log Message: 2004-11-29 Keith Packard * configure.in: Move AC_CONFIG_AUX_DIR above AM_INIT_AUTOMAKE as needed for new automake version Index: ChangeLog =================================================================== RCS file: /local/src/CVS/nickle/ChangeLog,v retrieving revision 1.102 retrieving revision 1.103 diff -u -d -r1.102 -r1.103 --- ChangeLog 30 Nov 2004 05:16:08 -0000 1.102 +++ ChangeLog 30 Nov 2004 05:27:53 -0000 1.103 @@ -1,5 +1,11 @@ 2004-11-29 Keith Packard + * configure.in: + Move AC_CONFIG_AUX_DIR above AM_INIT_AUTOMAKE as needed for new + automake version + +2004-11-29 Keith Packard + * mem.c: (newBlock), (MemAddRoot): Call to panic had wrong arguments and caused a segfault. Index: configure.in =================================================================== RCS file: /local/src/CVS/nickle/configure.in,v retrieving revision 1.37 retrieving revision 1.38 diff -u -d -r1.37 -r1.38 --- configure.in 29 Jul 2004 00:23:32 -0000 1.37 +++ configure.in 30 Nov 2004 05:27:53 -0000 1.38 @@ -8,10 +8,10 @@ AC_INIT AC_CONFIG_SRCDIR([nickle.h]) +AC_CONFIG_AUX_DIR(.) AM_INIT_AUTOMAKE(nickle,0.0) AM_MAINTAINER_MODE AC_CONFIG_HEADERS([config.h]) -AC_CONFIG_AUX_DIR(.) dnl Checks for programs. AC_PROG_CC From commit at keithp.com Tue Nov 30 10:28:24 2004 From: commit at keithp.com (Bart Massey) Date: Tue Nov 30 10:28:37 2004 Subject: [Commit] nickle ChangeLog,1.103,1.104 math.5c,1.40,1.41 Message-ID: Committed by: bart Update of /local/src/CVS/nickle In directory home.keithp.com:/tmp/cvs-serv26883 Modified Files: ChangeLog math.5c Log Message: * math.5c Added lsb() Index: ChangeLog =================================================================== RCS file: /local/src/CVS/nickle/ChangeLog,v retrieving revision 1.103 retrieving revision 1.104 diff -u -d -r1.103 -r1.104 --- ChangeLog 30 Nov 2004 05:27:53 -0000 1.103 +++ ChangeLog 30 Nov 2004 18:28:21 -0000 1.104 @@ -1,3 +1,8 @@ +2004-11-30 Bart Massey + + * math.5c + Added lsb() + 2004-11-29 Keith Packard * configure.in: Index: math.5c =================================================================== RCS file: /local/src/CVS/nickle/math.5c,v retrieving revision 1.40 retrieving revision 1.41 diff -u -d -r1.40 -r1.41 --- math.5c 14 Jun 2004 06:43:33 -0000 1.40 +++ math.5c 30 Nov 2004 18:28:21 -0000 1.41 @@ -969,6 +969,47 @@ } return below; } + + public exception lsb_0(); + + public int lsb(int b) + /* + * return the bit position of + * the least significant bit of the int argument + * via binary search + */ + { + global bool mask(int b, int ul) { + return (b & ((1 << (ul + 1)) - 1)) != 0; + } + + if (b == 0) + raise lsb_0(); + if (b == -1) + return 0; + /* doubling phase */ + int ul = 1; + for (!mask(b, ul); ul *= 2) + /* do nothing */; + /* binary search phase */ + int ll = 0; + while (ul > ll + 1) { + int step = (ul - ll) // 2; + if (mask(b, ul - step)) { + ul -= step; + continue; + } + if (!mask(b, ll + step)) { + ll += step; + continue; + } + abort("error in binary search"); + } + if (mask(b, ll)) + return ll; + return ul; + } + } /* XXX these shouldn't be here, but it was *convenient* */ From commit at keithp.com Tue Nov 30 10:34:44 2004 From: commit at keithp.com (Bart Massey) Date: Tue Nov 30 10:34:58 2004 Subject: [Commit] nickle builtin.5c,1.8,1.9 Message-ID: Committed by: bart Update of /local/src/CVS/nickle In directory home.keithp.com:/tmp/cvs-serv26983 Modified Files: builtin.5c Log Message: Made abort() available a bit earlier. Index: builtin.5c =================================================================== RCS file: /local/src/CVS/nickle/builtin.5c,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- builtin.5c 8 Jun 2004 09:30:53 -0000 1.8 +++ builtin.5c 30 Nov 2004 18:34:41 -0000 1.9 @@ -97,11 +97,17 @@ new ("library", lex_library); } + # Load the prerequisites for the extra commands. library "ctype.5c"; library "string.5c"; library "file.5c"; library "printf.5c"; + +# Get abort() in early, even if this means not autoimporting it +library "abort.5c"; +import Abort; + library "history.5c"; # Now load the extra commands. @@ -115,7 +121,6 @@ library "socket.5c"; # Now autoload/autoimport the bonus stuff -autoimport Abort; autoload Mutex; autoload ARC4; autoload PRNG; From commit at keithp.com Tue Nov 30 11:51:20 2004 From: commit at keithp.com (Keith Packard) Date: Tue Nov 30 11:51:29 2004 Subject: [Commit] nickle ChangeLog, 1.104, 1.105 float.c, 1.23, 1.24 hash.c, 1.8, 1.9 natural.c, 1.24, 1.25 string.c, 1.18, 1.19 value.c, 1.48, 1.49 value.h, 1.107, 1.108 Message-ID: Committed by: keithp Update of /local/src/CVS/nickle In directory home.keithp.com:/tmp/cvs-serv28065 Modified Files: ChangeLog float.c hash.c natural.c string.c value.c value.h Log Message: 2004-11-30 Keith Packard * float.c: (FloatHash): Provide hash function for float representation * hash.c: (generate_crc32_table), (HashCrc32), (HashInit): * value.h: Implement general purpose crc32 function for hashing * natural.c: (NaturalHash): * string.c: (StringHash): Use crc32 hash for naturals and strings * value.c: (ValueHash), (NewDataCache): Return Zero for representations without hash functions instead of uninit (oops). Initialize datacache to zero before adding as a root (just a cleanup) Index: ChangeLog =================================================================== RCS file: /local/src/CVS/nickle/ChangeLog,v retrieving revision 1.104 retrieving revision 1.105 diff -u -d -r1.104 -r1.105 --- ChangeLog 30 Nov 2004 18:28:21 -0000 1.104 +++ ChangeLog 30 Nov 2004 19:51:16 -0000 1.105 @@ -1,3 +1,21 @@ +2004-11-30 Keith Packard + + * float.c: (FloatHash): + Provide hash function for float representation + + * hash.c: (generate_crc32_table), (HashCrc32), (HashInit): + * value.h: + Implement general purpose crc32 function for hashing + + * natural.c: (NaturalHash): + * string.c: (StringHash): + Use crc32 hash for naturals and strings + + * value.c: (ValueHash), (NewDataCache): + Return Zero for representations without hash functions + instead of uninit (oops). + Initialize datacache to zero before adding as a root (just a cleanup) + 2004-11-30 Bart Massey * math.5c Index: float.c =================================================================== RCS file: /local/src/CVS/nickle/float.c,v retrieving revision 1.23 retrieving revision 1.24 diff -u -d -r1.23 -r1.24 --- float.c 27 Feb 2004 03:50:16 -0000 1.23 +++ float.c 30 Nov 2004 19:51:16 -0000 1.24 @@ -971,6 +971,15 @@ return True; } +static HashValue +FloatHash (Value av) +{ + Float *a = &av->floats; + + return (NaturalHash(a->mant->mag) ^ a->mant->sign ^ + NaturalHash(a->exp->mag) ^ a->exp->sign); +} + static void FloatMark (void *object) { @@ -1002,7 +1011,9 @@ }, FloatPromote, FloatReduce, - FloatPrint + FloatPrint, + 0, + FloatHash, }; Value Index: hash.c =================================================================== RCS file: /local/src/CVS/nickle/hash.c,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- hash.c 29 Jul 2004 00:23:32 -0000 1.8 +++ hash.c 30 Nov 2004 19:51:16 -0000 1.9 @@ -140,9 +140,44 @@ EXIT (); } +#if HAVE_STDINT_H +typedef uint32_t crc32_t; +#else +typedef unsigned int crc32_t; +#endif + +static crc32_t crc32_table[256]; + +static void +generate_crc32_table(void) +{ + crc32_t c, p; + int n, m; + + p = 0xedb88320; + for (n = 0; n < 256; n++) + { + c = n; + for (m = 0; m < 8; m++) + c = (c >> 1) ^ ((c & 1) ? p : 0); + crc32_table[n] = c; + } +} + +HashValue +HashCrc32 (unsigned char *bytes, int nbytes) +{ + crc32_t crc32 = ~0; + if (crc32_table[1] == 0) abort (); + while (nbytes--) + crc32 = (crc32 >> 8) ^ crc32_table[(crc32 ^ *bytes++) & 0xff]; + return (HashValue) ~crc32; +} + int HashInit (void) { + generate_crc32_table (); return 1; } Index: natural.c =================================================================== RCS file: /local/src/CVS/nickle/natural.c,v retrieving revision 1.24 retrieving revision 1.25 diff -u -d -r1.24 -r1.25 --- natural.c 27 May 2004 23:30:55 -0000 1.24 +++ natural.c 30 Nov 2004 19:51:16 -0000 1.25 @@ -1410,20 +1410,11 @@ return True; } -#define hrot(i) (((i) << 1) | ((i) >> (sizeof (HashValue) * 8 - 1))) - HashValue NaturalHash (Natural *a) { - HashValue h = 0; - digit *at; - int index; - - at = NaturalDigits (a); - index = a->length; - while (index--) - h = hrot(h) ^ (HashValue) *at++; - return h; + return HashCrc32 ((unsigned char *) &a->length, + sizeof (int) + sizeof (digit) * a->length); } int Index: string.c =================================================================== RCS file: /local/src/CVS/nickle/string.c,v retrieving revision 1.18 retrieving revision 1.19 diff -u -d -r1.18 -r1.19 --- string.c 8 Jun 2004 09:30:54 -0000 1.18 +++ string.c 30 Nov 2004 19:51:16 -0000 1.19 @@ -194,18 +194,11 @@ return StringChars (&v->string); } -#define hrot(i) (((i) << 1) | ((i) >> (sizeof (HashValue) * 8 - 1))) - static HashValue StringHash (Value av) { - char *string = StringChars (&av->string); - long len = av->string.length; - HashValue h = 0; - - while (len--) - h = hrot(h) ^ (HashValue) *string++; - return h; + return HashCrc32 ((unsigned char *) StringChars(&av->string), + av->string.length); } ValueRep StringRep = { Index: value.c =================================================================== RCS file: /local/src/CVS/nickle/value.c,v retrieving revision 1.48 retrieving revision 1.49 diff -u -d -r1.48 -r1.49 --- value.c 9 Oct 2004 22:38:28 -0000 1.48 +++ value.c 30 Nov 2004 19:51:16 -0000 1.49 @@ -679,10 +679,10 @@ ValueRep *rep; if (!v) - return 0; + return Zero; rep = ValueRep(v); if (!rep->hash) - return 0; + return Zero; return NewInt ((*rep->hash) (v) & MAX_NICKLE_INT); } @@ -810,8 +810,8 @@ sizeof (DataCache) + size * sizeof (void *)); dc->size = size; - MemAddRoot (dc); memset (DataCacheValues(dc), '\0', size * sizeof (Value)); + MemAddRoot (dc); RETURN (dc); } Index: value.h =================================================================== RCS file: /local/src/CVS/nickle/value.h,v retrieving revision 1.107 retrieving revision 1.108 diff -u -d -r1.107 -r1.108 --- value.h 7 Jul 2004 07:32:47 -0000 1.107 +++ value.h 30 Nov 2004 19:51:16 -0000 1.108 @@ -1106,6 +1106,7 @@ Value Popcount(Value); Bool Print (Value, Value, char format, int base, int width, int prec, int fill); void PrintError (char *s, ...); +HashValue HashCrc32 (unsigned char *bytes, int nbytes); Value CopyMutable (Value v); #ifdef HAVE_C_INLINE static inline Value From commit at keithp.com Tue Nov 30 13:18:53 2004 From: commit at keithp.com (Emma Kuo) Date: Tue Nov 30 13:19:02 2004 Subject: [Commit] mint/doc mintskel.tex,NONE,1.1 Message-ID: Committed by: ekuo Update of /local/src/CVS/mint/doc In directory home.keithp.com:/tmp/cvs-serv29366 Added Files: mintskel.tex Log Message: --- NEW FILE: mintskel.tex --- \documentclass[twocolumn,12pt]{article} \usepackage[dvips]{epsfig} \usepackage[dvips]{color} \title{MINT Is A Nickle Translator:\\ Generating Cross-Lingual Recognizers } \author{Emma Kuo \and James LaMar \and Bart Massey\\ Portland State University \and Keith Packard\\ Hewlett-Packard Company} \begin{document} \maketitle \input{mintsec} \end{document} From commit at keithp.com Tue Nov 30 21:30:08 2004 From: commit at keithp.com (James LaMar) Date: Tue Nov 30 21:30:14 2004 Subject: [Commit] mint/src bootmint.5c,NONE,1.1 mint.5c,1.2,1.3 Message-ID: Committed by: jlamar Update of /local/src/CVS/mint/src In directory home.keithp.com:/tmp/cvs-serv10739 Modified Files: mint.5c Added Files: bootmint.5c Log Message: Added in bootstrapping version of mint. --- NEW FILE: bootmint.5c --- (This appears to be a binary file; contents omitted.) Index: mint.5c =================================================================== RCS file: /local/src/CVS/mint/src/mint.5c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- mint.5c 29 Nov 2004 22:51:27 -0000 1.2 +++ mint.5c 1 Dec 2004 05:30:05 -0000 1.3 @@ -99,7 +99,12 @@ return t.lexeme[0]; case "esclit": token t = get_tok(nt.fields["op1"]); - return t.lexeme[1]; + if(t.lexeme[1] == 'n') { + return '\n'; + } else if(t.lexeme[1] == 't') { + return '\t'; + } + return t.lexeme[1]; default: raise regex_error(); } From commit at keithp.com Tue Nov 30 21:30:46 2004 From: commit at keithp.com (James LaMar) Date: Tue Nov 30 21:30:51 2004 Subject: [Commit] mint/grammars bnfgram.mnt,NONE,1.1 nickle.mnt,1.1,1.2 Message-ID: Committed by: jlamar Update of /local/src/CVS/mint/grammars In directory home.keithp.com:/tmp/cvs-serv10844 Modified Files: nickle.mnt Added Files: bnfgram.mnt Log Message: Added grammar for parser generator. --- NEW FILE: bnfgram.mnt --- tokens: token arrow /->/ token equals /=/ token lparen /\(/ token rparen /\)/ token token_t /token/ token skip_t /skip/ token rules /rules:/ token tokens /tokens:/ token precedences /precedence:/ token precedence_t /precedence/ token left_t /left/ token right_t /right/ token nonassoc_t /nonassoc/ skip ws /[ \t\n]/ token lbrace /\[/ token rbrace /\]/ token rule_t /rule/ token id /[A-Za-z][A-Za-z0-9]*/ token colon /:/ token setlexer_t /setlexer/ skip comment /#[^\n]*/ token comma /,/ token regex /\/([^\/]|\\]\/)*\// precedence: rules: # # Top level # rule (S : grammar_definition) -> tokens (tokendecl_list : tokendecl_list) precedences (precdecl_list : precdecl_list) rules (ruledecl_list : ruledecl_list) # # Tokens section # rule (tokendecl_list : tokendecl_list_empty) -> rule (tokendecl_list : tokendecl_list) -> (tokendecl : head) (tokendecl_list : tail) rule (tokendecl : tokendecl) -> token_t (id : name) (start_cond : start_cond) (regex : pattern) (lex_options : options) rule (tokendecl : tokendecl_skip) -> skip_t (id : name) (start_cond : start_cond) (regex : pattern) (lex_options : options) # # Start conditions # rule (start_cond : none) -> rule (start_cond : list) -> lparen (id_list : list) rparen # # Per-token options # rule (lex_options : none) -> rule (lex_options : list) -> lbrace (lex_option_list : tail) rbrace rule (lex_option_list : lex_option_single) -> (lex_option : head) rule (lex_option_list : lex_option_list) -> (lex_option : head) comma (lex_option : tail) rule (lex_option : psetlexer) -> setlexer_t equals (id : value) # # Precedence Section # rule (precdecl_list : precdecl_list_empty) -> rule (precdecl_list : precdecl_list) -> (precdecl : head) (precdecl_list : tail) rule (precdecl : pleft) -> left_t (id_list : tokens) rule (precdecl : pright) -> right_t (id_list : tokens) rule (precdecl : pnonassoc) -> nonassoc_t (id_list : tokens) # # Rules section # rule (ruledecl_list : empty) -> rule (ruledecl_list : ruledecl_list) -> (ruledecl : head) (ruledecl_list : tail) rule (ruledecl : ruledecl) -> rule_t lparen (id : nonterminal) colon (id : type) rparen arrow (prod_list : production) (options : options) rule (prod_list : prod_list_empty) -> rule (prod_list : prod_list) -> (prod_list : tail) (prod : head) rule (prod : untagged) -> (id : symbol) rule (prod : tagged) -> lparen (id : symbol) colon (id : name) rparen rule (options : none) -> rule (options : list) -> lbrace (option_list : tail) rbrace rule (option_list : option_list_single) -> (option : head) rule (option_list : option_list) -> (option : head) comma (option_list : tail) rule (option : psetlexer) -> setlexer_t equals (id : value) rule (option : pprecedence) -> precedence_t equals (id : value) rule (id_list : id_list_single) -> (id : head) rule (id_list : id_list) -> (id : head) (id_list : tail) Index: nickle.mnt =================================================================== RCS file: /local/src/CVS/mint/grammars/nickle.mnt,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- nickle.mnt 29 Nov 2004 14:53:27 -0000 1.1 +++ nickle.mnt 1 Dec 2004 05:30:43 -0000 1.2 @@ -39,6 +39,7 @@ token rbrack /\}/ token id /[a-zA-Z_][a-zA-Z0-9_]*/ token ampersand /&/ +token comma /,/ skip whitespace /[ ]/ From commit at keithp.com Tue Nov 30 22:44:33 2004 From: commit at keithp.com (James LaMar) Date: Tue Nov 30 22:44:41 2004 Subject: [Commit] mint/doc mintsec.tex,1.1,1.2 Message-ID: Committed by: jlamar Update of /local/src/CVS/mint/doc In directory home.keithp.com:/tmp/cvs-serv12187 Modified Files: mintsec.tex Log Message: Index: mintsec.tex =================================================================== RCS file: /local/src/CVS/mint/doc/mintsec.tex,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- mintsec.tex 29 Nov 2004 19:59:06 -0000 1.1 +++ mintsec.tex 1 Dec 2004 06:44:30 -0000 1.2 @@ -101,4 +101,85 @@ MINT was able to generate parsers for the regular expression and BNF syntaxes fairly easily. Attempting to generate a parse table for a -small Nickle subset proved to be more difficult, however. +small Nickle subset proved to be more difficult, however. The +implementation of the parser generator was fairly na\"ive -- as +this particular version was intended to be a proof of concept more +than an efficient implementation of the canoncial LR(1) parsing +algorithm. However, the generated parser and lexer were more than +fast enough for general use. + +\section{Translators in MINT} + +A few simple examples should be adequate to demonstrate the essentials +of the MINT parser generator language. + +Each grammar file is divided into three sections -- tokens, +precedence, and rules. The tokens section specifies an identifier for +each token, along with a regular expression specifying the pattern +of input associated with that token. In short, the token section +compactly represents a lexer. + +The precedence section allows ambiguous grammars to be specified and +disambiguated by the user by specifying the precedence and assocativity +of tokens in the grammar, similar to the YACC ``\%left'' ``\%right'' +and ``\%nonassoc'' directives. + +The rules section represents the productions of the context free grammar. +The syntax of these rules may seem a little confusing at first. A rule +consists of a nonterminal which is tagged with some kind of descriptor, and +zero or more symbols which represent a possible sentence the nonterminal +can derive. Each symbol may be ``tagged'' meaning such that its value +will appear in the syntax tree resulting from a successful parse tagged by a identifier. +Untagged values are not included in the syntax tree. This +labelling allows the user to write syntax tree walkers which are +readable and since the tags are not positional, allows more flexibility +in modifying the grammar. The omission of the untagged values reduces +redundant syntactic clutter. + +A few examples may clarify things: + +\begin{verbatim} + +# +# The canonical expression grammar (with precedence) +# + +# +# Token section +# +tokens: + +token plus /\+/ +token mult /\*/ +token lparen /\(/ +token rparen /\)/ +token id /[A-Za-z0-9]/ +skip whitespace /[ ]/ # Skip whitespace + +# +# Operator precedence +# +precedence: + +left plus +left mult + +# +# Rules +# +rules: + +rule (E : plusexpr) -> (E : op1) plus (E : op2) +rule (E : multexpr) -> (E : op1) mult (E : op2) +rule (E : id) -> (id : name) +rule (E : parenexpr) -> lparen (E : sub) rparen + +\end{verbatim} + +In this example, there is one nonterminal (E) with four productions. +Addition and multiplication are binary operators in which the left +operand is tagged ``op1'' and the right is tagged ``op2''. Both the +additon symbol and the multiplication symbol are untagged -- so they +will not be included in the resulting syntax tree. + + From commit at keithp.com Tue Nov 30 22:47:05 2004 From: commit at keithp.com (Bart Massey) Date: Tue Nov 30 22:47:14 2004 Subject: [Commit] mint-2004b - Imported sources,NONE,NONE Message-ID: Committed by: bart Update of /local/src/CVS/mint-2004b In directory home.keithp.com:/tmp/cvs-serv12270 Log Message: The MINT paper. Intended for LDTA 2005 submission. My synthesis of two other repositories, plus my own stuff. Status: Vendor Tag: bart Release Tags: initial N mint-2004b/abstract.tex N mint-2004b/architecture.fig N mint-2004b/dofigs.sh N mint-2004b/entcs.bst N mint-2004b/entcs.cls N mint-2004b/lola.tex N mint-2004b/mint.bib N mint-2004b/mint.tex N mint-2004b/nickle.tex N mint-2004b/outline.txt N mint-2004b/prentcsmacro.sty N mint-2004b/tool.tex N mint-2004b/Makefile No conflicts created by this import --- NEW FILE: - Imported sources ---