From d7eceebe0eb9cd7840f183dcaf294c85794b0db5 Mon Sep 17 00:00:00 2001 From: dos-reis Date: Sun, 3 Jun 2012 13:02:47 +0000 Subject: * interp/lexing.boot (%Line): Now a record structure. * boot/parser.boot (bpTypeName): Split out of bpTypeAliasDefinition. (bpStruct): Use it. Support parameterized structures. * boot/ast.boot (ctorName): New. (bfEnum): Use it for parameterized enums. (bfRecord): Use it for parameterized records. --- Makefile.am | 2 +- Makefile.in | 2 +- configure | 20 ++++++++++---------- configure.ac | 2 +- src/ChangeLog | 9 +++++++++ src/boot/ast.boot | 7 ++++++- src/boot/parser.boot | 21 ++++++++++++--------- src/boot/strap/ast.clisp | 5 ++++- src/boot/strap/parser.clisp | 7 ++++--- src/interp/lexing.boot | 30 +++++++++++------------------- 10 files changed, 59 insertions(+), 46 deletions(-) diff --git a/Makefile.am b/Makefile.am index d2c36208..5db04f85 100644 --- a/Makefile.am +++ b/Makefile.am @@ -41,7 +41,7 @@ # describe. This description is STILL IN WORK IN PROGRESS. Therefore # it is incorrekt, incomplet, and iNconSiStenT. -ACLOCAL_AMFLAGS = -I config --install --output=config/aclocal.m4 +ACLOCAL_AMFLAGS = -I config #--install --output=config/aclocal.m4 DIST_SUBDIRS = src diff --git a/Makefile.in b/Makefile.in index 1b959f44..796b5826 100644 --- a/Makefile.in +++ b/Makefile.in @@ -354,7 +354,7 @@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ void_type = @void_type@ -ACLOCAL_AMFLAGS = -I config --install --output=config/aclocal.m4 +ACLOCAL_AMFLAGS = -I config #--install --output=config/aclocal.m4 DIST_SUBDIRS = src oa_builddir = $(abs_top_builddir)/build/$(target) oa_installdir = @open_axiom_installdir@ diff --git a/configure b/configure index 275e2cfb..41f202f8 100755 --- a/configure +++ b/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.68 for OpenAxiom 1.5.0-2012-05-29. +# Generated by GNU Autoconf 2.68 for OpenAxiom 1.5.0-2012-06-03. # # Report bugs to . # @@ -570,8 +570,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='OpenAxiom' PACKAGE_TARNAME='openaxiom' -PACKAGE_VERSION='1.5.0-2012-05-29' -PACKAGE_STRING='OpenAxiom 1.5.0-2012-05-29' +PACKAGE_VERSION='1.5.0-2012-06-03' +PACKAGE_STRING='OpenAxiom 1.5.0-2012-06-03' PACKAGE_BUGREPORT='open-axiom-bugs@lists.sf.net' PACKAGE_URL='' @@ -1365,7 +1365,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures OpenAxiom 1.5.0-2012-05-29 to adapt to many kinds of systems. +\`configure' configures OpenAxiom 1.5.0-2012-06-03 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1440,7 +1440,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of OpenAxiom 1.5.0-2012-05-29:";; + short | recursive ) echo "Configuration of OpenAxiom 1.5.0-2012-06-03:";; esac cat <<\_ACEOF @@ -1553,7 +1553,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -OpenAxiom configure 1.5.0-2012-05-29 +OpenAxiom configure 1.5.0-2012-06-03 generated by GNU Autoconf 2.68 Copyright (C) 2010 Free Software Foundation, Inc. @@ -2546,7 +2546,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by OpenAxiom $as_me 1.5.0-2012-05-29, which was +It was created by OpenAxiom $as_me 1.5.0-2012-06-03, which was generated by GNU Autoconf 2.68. Invocation command line was $ $0 $@ @@ -3479,7 +3479,7 @@ fi # Define the identity of the package. PACKAGE='openaxiom' - VERSION='1.5.0-2012-05-29' + VERSION='1.5.0-2012-06-03' cat >>confdefs.h <<_ACEOF @@ -20276,7 +20276,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by OpenAxiom $as_me 1.5.0-2012-05-29, which was +This file was extended by OpenAxiom $as_me 1.5.0-2012-06-03, which was generated by GNU Autoconf 2.68. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -20342,7 +20342,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -OpenAxiom config.status 1.5.0-2012-05-29 +OpenAxiom config.status 1.5.0-2012-06-03 configured by $0, generated by GNU Autoconf 2.68, with options \\"\$ac_cs_config\\" diff --git a/configure.ac b/configure.ac index d11c2742..d83d02ff 100644 --- a/configure.ac +++ b/configure.ac @@ -33,7 +33,7 @@ dnl Makefiles for building OpenAxiom interpreter, compiler, libraries, and dnl auxiliary tools where appropriate. dnl -AC_INIT([OpenAxiom], [1.5.0-2012-05-29], +AC_INIT([OpenAxiom], [1.5.0-2012-06-03], [open-axiom-bugs@lists.sf.net]) dnl Most of the macros used in this configure.ac are defined in files diff --git a/src/ChangeLog b/src/ChangeLog index 728cdea2..50e3e96f 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,12 @@ +2012-06-03 Gabriel Dos Reis + + * interp/lexing.boot (%Line): Now a record structure. + * boot/parser.boot (bpTypeName): Split out of bpTypeAliasDefinition. + (bpStruct): Use it. Support parameterized structures. + * boot/ast.boot (ctorName): New. + (bfEnum): Use it for parameterized enums. + (bfRecord): Use it for parameterized records. + 2012-06-03 Gabriel Dos Reis * boot/parser.boot (bpSignatureTail): Split out of bpSignature. diff --git a/src/boot/ast.boot b/src/boot/ast.boot index 05a1d94d..b7ae91b5 100644 --- a/src/boot/ast.boot +++ b/src/boot/ast.boot @@ -1362,10 +1362,15 @@ bfDs n == n = 0 => '"" strconc('"D",bfDs(n-1)) +ctorName x == + x is [.,:.] => ctorName first x + x + bfEnum(t,csts) == - ['DEFTYPE,t,nil,backquote(['MEMBER,:csts],nil)] + ['DEFTYPE,ctorName t,nil,backquote(['MEMBER,:csts],nil)] bfRecordDef(tu,s,fields,accessors) == + s := ctorName s -- forget parameters parms := [x for f in fields | f is ['%Signature,x,.]] fun := makeSymbol strconc('"mk",symbolName s) ctor := makeSymbol strconc('"MAKE-",symbolName s) diff --git a/src/boot/parser.boot b/src/boot/parser.boot index ce3f4954..43507640 100644 --- a/src/boot/parser.boot +++ b/src/boot/parser.boot @@ -1,4 +1,4 @@ --- Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd. +-- Copyright (c) 1991-2002, The Numerical Algorithms Group Ltd. -- All rights reserved. -- Copyright (C) 2007-2012, Gabriel Dos Reis. -- All rights reserved. @@ -477,7 +477,7 @@ bpExportItem ps == bpRequire(ps,function bpSignature) bpExportItemTail ps or true bpRestore(ps,a) - bpTypeAliasDefition ps + bpTypeAliasDefinition ps false ++ ExportItemList: @@ -542,12 +542,15 @@ bpNamespace ps == bpPush(ps,bfNamespace bpPop1 ps) -- Parse a type alias defnition: --- type-alias-definition: --- identifier <=> logical-expression -bpTypeAliasDefition ps == - (bpTerm(ps,function bpIdList) or bpTrap ps) and +-- TypeAliasDefinition: +-- TypeName <=> logical-expression +bpTypeAliasDefinition ps == + bpTypeName ps and bpEqKey(ps,"TDEF") and bpLogical ps and - bpPush(ps,%TypeAlias(bpPop2 ps, bpPop1 ps)) + bpPush(ps,%TypeAlias(bpPop2 ps,bpPop1 ps)) + +bpTypeName ps == + bpTerm(ps,function bpIdList) or bpTrap ps ++ Parse a signature declaration ++ Signature: @@ -981,7 +984,7 @@ bpDefinition ps == bpDef ps bpEqPeek(ps,"TDEF") => bpRestore(ps,a) - bpTypeAliasDefition ps + bpTypeAliasDefinition ps true bpRestore(ps,a) false @@ -1220,7 +1223,7 @@ bpChecknull ps == bpStruct ps == bpEqKey(ps,"STRUCTURE") and - bpRequire(ps,function bpName) and + bpRequire(ps,function bpTypeName) and (bpEqKey(ps,"DEF") or bpTrap ps) and (bpRecord ps or bpTypeList ps) and bpPush(ps,%Structure(bpPop2 ps,bpPop1 ps)) diff --git a/src/boot/strap/ast.clisp b/src/boot/strap/ast.clisp index 73afad30..9c271751 100644 --- a/src/boot/strap/ast.clisp +++ b/src/boot/strap/ast.clisp @@ -2518,8 +2518,10 @@ (DEFUN |bfDs| (|n|) (COND ((EQL |n| 0) "") (T (CONCAT "D" (|bfDs| (- |n| 1)))))) +(DEFUN |ctorName| (|x|) (COND ((CONSP |x|) (|ctorName| (CAR |x|))) (T |x|))) + (DEFUN |bfEnum| (|t| |csts|) - (LIST 'DEFTYPE |t| NIL (|backquote| (CONS 'MEMBER |csts|) NIL))) + (LIST 'DEFTYPE (|ctorName| |t|) NIL (|backquote| (CONS 'MEMBER |csts|) NIL))) (DEFUN |bfRecordDef| (|tu| |s| |fields| |accessors|) (LET* (|accDefs| @@ -2535,6 +2537,7 @@ |x| |ISTMP#1|) (PROGN + (SETQ |s| (|ctorName| |s|)) (SETQ |parms| (LET ((|bfVar#2| NIL) (|bfVar#3| NIL) diff --git a/src/boot/strap/parser.clisp b/src/boot/strap/parser.clisp index d0d000c8..1b05fd82 100644 --- a/src/boot/strap/parser.clisp +++ b/src/boot/strap/parser.clisp @@ -556,10 +556,11 @@ (|bpPush| |ps| (|bfNamespace| (|bpPop1| |ps|))))) (DEFUN |bpTypeAliasDefition| (|ps|) - (AND (OR (|bpTerm| |ps| #'|bpIdList|) (|bpTrap| |ps|)) (|bpEqKey| |ps| 'TDEF) - (|bpLogical| |ps|) + (AND (|bpTypeName| |ps|) (|bpEqKey| |ps| 'TDEF) (|bpLogical| |ps|) (|bpPush| |ps| (|%TypeAlias| (|bpPop2| |ps|) (|bpPop1| |ps|))))) +(DEFUN |bpTypeName| (|ps|) (OR (|bpTerm| |ps| #'|bpIdList|) (|bpTrap| |ps|))) + (DEFUN |bpSignature| (|ps|) (AND (|bpName| |ps|) (|bpSignatureTail| |ps|))) (DEFUN |bpSignatureTail| (|ps|) @@ -1282,7 +1283,7 @@ (COND ((NULL |a|) (|bpTrap| |ps|)) (T (|bpPush| |ps| |a|)))))) (DEFUN |bpStruct| (|ps|) - (AND (|bpEqKey| |ps| 'STRUCTURE) (|bpRequire| |ps| #'|bpName|) + (AND (|bpEqKey| |ps| 'STRUCTURE) (|bpRequire| |ps| #'|bpTypeName|) (OR (|bpEqKey| |ps| 'DEF) (|bpTrap| |ps|)) (OR (|bpRecord| |ps|) (|bpTypeList| |ps|)) (|bpPush| |ps| (|%Structure| (|bpPop2| |ps|) (|bpPop1| |ps|))))) diff --git a/src/interp/lexing.boot b/src/interp/lexing.boot index 426e1fbc..09fbd7d5 100644 --- a/src/interp/lexing.boot +++ b/src/interp/lexing.boot @@ -47,28 +47,20 @@ module lexing where --% --% Line abstract datatype ---% structure Line == ---% Record(buffer: String, curChar: Character, ---% curIdx: SingleInteger, lstIdx: SingleInteger, lineNo: SingleInteger) --% -makeLine(buf == makeString 0, ch == charByName "Return", - curIdx == 1, lstIdx == 0, no == 0) == - [buf,ch,curIdx,lstIdx,no] - -macro lineBuffer l == - first l - -macro lineCurrentChar l == - second l +structure %Line == + Record(buf: %String, cchar: %Char, cidx: %Short, + lidx: %Short, no: %Short) with + lineBuffer == (.buf) -- input string buffer + lineCurrentChar == (.cchar) -- current character + lineCurrentIndex == (.cidx) -- current index + lineLastIndex == (.lidx) -- last valid index + lineNumber == (.no) -- line number -macro lineCurrentIndex l == - third l -macro lineLastIndex l == - fourth l - -macro lineNumber l == - fifth l +makeLine(buf == makeString 0, ch == charByName "Return", + curIdx == 1, lstIdx == 0, no == 0) == + mk%Line(buf,ch,curIdx,lstIdx,no) lineClear! l == lineBuffer(l) := makeString 0 -- cgit v1.2.3