aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordos-reis <gdr@axiomatics.org>2012-05-21 04:22:23 +0000
committerdos-reis <gdr@axiomatics.org>2012-05-21 04:22:23 +0000
commit174a15e2ab0bc2fd44e536f995111f706fe5d1f5 (patch)
tree99f8e717beca16cb358ab95301984a8417fa4c75 /src
parent43eb220cc23f10a7b597d0354ccd4e7e5ea5ffd1 (diff)
downloadopen-axiom-174a15e2ab0bc2fd44e536f995111f706fe5d1f5.tar.gz
* interp/lexing.boot (getDecimalNumberToken): New.
(getIntegerInRadix): Likewise. (getSpadIntegerToken): Likewise. (getToken): Use it. * interp/Makefile.in (bootlex.$(FASLEXT)): Remove rule. (OBJS): Do not include it. * interp/bootlex.lisp: Remove.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog10
-rw-r--r--src/interp/Makefile.in6
-rw-r--r--src/interp/bootlex.lisp102
-rw-r--r--src/interp/lexing.boot42
-rw-r--r--src/interp/spad.lisp2
5 files changed, 54 insertions, 108 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index b997cbdf..6c61c356 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,15 @@
2012-05-20 Gabriel Dos Reis <gdr@cs.tamu.edu>
+ * interp/lexing.boot (getDecimalNumberToken): New.
+ (getIntegerInRadix): Likewise.
+ (getSpadIntegerToken): Likewise.
+ (getToken): Use it.
+ * interp/Makefile.in (bootlex.$(FASLEXT)): Remove rule.
+ (OBJS): Do not include it.
+ * interp/bootlex.lisp: Remove.
+
+2012-05-20 Gabriel Dos Reis <gdr@cs.tamu.edu>
+
* interp/spad-parser.boot (parseSexpr1): Simplify.
(parseDara): Likewise. Do not set LABLASOC.
* interp/bootlex.lisp (PRINT-DEFUN): Remove.
diff --git a/src/interp/Makefile.in b/src/interp/Makefile.in
index f9e427d9..5c8aa886 100644
--- a/src/interp/Makefile.in
+++ b/src/interp/Makefile.in
@@ -101,7 +101,7 @@ OBJS= boot-pkg.$(FASLEXT) types.$(FASLEXT) \
server.$(FASLEXT) setvars.$(FASLEXT) \
sfsfun-l.$(FASLEXT) sfsfun.$(FASLEXT) \
slam.$(FASLEXT) \
- preparse.$(FASLEXT) bootlex.$(FASLEXT) \
+ preparse.$(FASLEXT) \
spad.$(FASLEXT) termrw.$(FASLEXT) \
trace.$(FASLEXT) word.$(FASLEXT) \
fortcall.$(FASLEXT) i-parser.$(FASLEXT) \
@@ -320,8 +320,6 @@ spad-parser.$(FASLEXT): parse.$(FASLEXT) preparse.$(FASLEXT)
parse.$(FASLEXT): parsing.$(FASLEXT) postpar.$(FASLEXT)
packtran.$(FASLEXT): sys-macros.$(FASLEXT)
postpar.$(FASLEXT): macros.$(FASLEXT)
-bootlex.$(FASLEXT): preparse.$(FASLEXT) macros.$(FASLEXT) \
- nlib.$(FASLEXT) sys-globals.$(FASLEXT)
newaux.$(FASLEXT): macros.$(FASLEXT)
preparse.$(FASLEXT): parsing.$(FASLEXT)
parsing.$(FASLEXT): lexing.$(FASLEXT) macros.$(FASLEXT)
@@ -355,7 +353,7 @@ dq.$(FASLEXT): types.$(FASLEXT)
## General support and utilities.
daase.$(FASLEXT): sys-utility.$(FASLEXT)
debug.$(FASLEXT): macros.$(FASLEXT) parsing.$(FASLEXT)
-spad.$(FASLEXT): bootlex.$(FASLEXT) postpar.$(FASLEXT) debug.$(FASLEXT)
+spad.$(FASLEXT): spad-parser.$(FASLEXT) postpar.$(FASLEXT) debug.$(FASLEXT)
monitor.$(FASLEXT): macros.$(FASLEXT)
sfsfun-l.$(FASLEXT): sys-macros.$(FASLEXT)
trace.$(FASLEXT): debug.$(FASLEXT)
diff --git a/src/interp/bootlex.lisp b/src/interp/bootlex.lisp
deleted file mode 100644
index b7a22269..00000000
--- a/src/interp/bootlex.lisp
+++ /dev/null
@@ -1,102 +0,0 @@
-;; Copyright (c) 1991-2002, The Numerical Algorithms Group Ltd.
-;; All rights reserved.
-;; Copyright (C) 2007-2012, Gabriel Dos Reis.
-;; All rights reserved.
-;;
-;; Redistribution and use in source and binary forms, with or without
-;; modification, are permitted provided that the following conditions are
-;; met:
-;;
-;; - Redistributions of source code must retain the above copyright
-;; notice, this list of conditions and the following disclaimer.
-;;
-;; - Redistributions in binary form must reproduce the above copyright
-;; notice, this list of conditions and the following disclaimer in
-;; the documentation and/or other materials provided with the
-;; distribution.
-;;
-;; - Neither the name of The Numerical Algorithms Group Ltd. nor the
-;; names of its contributors may be used to endorse or promote products
-;; derived from this software without specific prior written permission.
-;;
-;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
-;; IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
-;; TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
-;; PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
-;; OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-;; EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-;; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-;; PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-;; LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-;; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-
-; NAME: BootLex.lisp
-; PURPOSE: Parsing support routines for Boot and Spad code
-; CONTENTS:
-;
-; 0. Global parameters
-; 1. BOOT File Handling
-; 2. BOOT Line Handling
-; 3. BOOT Token Handling
-; 4. BOOT Token Parsing Actions
-; 5. BOOT Error Handling
-
-(import-module "sys-globals")
-(IMPORT-MODULE "preparse")
-(IMPORT-MODULE "macros")
-(IMPORT-MODULE "nlib")
-(in-package "BOOT")
-
-; *** 3. BOOT Token Handling ***
-
-;; -*- Parse an integer number -*-
-;; The number may be written in plain format, where the radix
-;; is implicitly taken to be 10. Or the spelling can explicitly
-;; specify a radix. That radix can be anything in the range 2..36
-
-;; Subroutine GET-NUMBER-TOKEN-MAYBE-WITH-RADIX.
-;; Read a the characters of a decimal integer and returns its
-;; value.
-(defun get-decimal-number-token (buf)
- (tagbody lp
- (suffix (|currentChar|) buf)
- (let ((next-chr (|nextChar|)))
- (cond ((digitp next-chr)
- (|advanceChar!|)
- (go lp)))))
- (parse-integer buf))
-
-;; Subroutine of GET-NUMBER-TOKEN-MAYBE-WITH-RADIX.
-;; We just read the radix of an integer number; parse the
-;; digits forming that integer token.
-(defun get-integer-in-radix (buf r)
- (unless (> r 1)
- (spad_syntax_error))
- (let ((mark (1+ (size buf))))
- (tagbody lp
- (suffix (|currentChar|) buf)
- (let* ((nxt (|nextChar|))
- (dig (|rdigit?| nxt)))
- (when dig
- (unless (< dig r)
- (spad_syntax_error))
- (|advanceChar!|)
- (go lp))))
- (parse-integer buf :start mark :radix r)))
-
-(defun is-radix-char (c)
- (or (eql c #\r)
- (eql c #\R)))
-
-;; Parse an integer token, written either implicitly in decimal form,
-;; or explicitly specified radix.
-(defun get-spad-integer-token (token)
- (let* ((buf (make-adjustable-string 0))
- (val (get-decimal-number-token buf)))
- (|advanceChar!|)
- (when (is-radix-char (|currentChar|))
- (setq val (get-integer-in-radix buf val))
- (|advanceChar!|))
- (|tokenInstall| val 'number token (size buf))))
diff --git a/src/interp/lexing.boot b/src/interp/lexing.boot
index 940f0e4d..3143b23c 100644
--- a/src/interp/lexing.boot
+++ b/src/interp/lexing.boot
@@ -189,6 +189,46 @@ tokenInstall(sym,typ,tok,nonblank == true) ==
tokenNonblank?(tok) := nonblank
tok
+++ Subroutine of getSpadIntegerToken.
+++ Read a the characters of a decimal integer and returns its value.
+getDecimalNumberToken buf ==
+ repeat
+ SUFFIX(currentChar(),buf)
+ not DIGITP nextChar() => leave nil
+ advanceChar!()
+ readIntegerIfCan buf
+
+++ Subroutine of getSpadIntegerToken.
+++ We just read the radix of an integer number; parse the
+++ digits forming that integer token.
+getIntegerInRadix(buf,r) ==
+ r < 2 => SPAD__SYNTAX__ERROR()
+ mark := #buf + 1
+ repeat
+ SUFFIX(currentChar(),buf)
+ d := rdigit? nextChar()
+ d = nil => leave nil
+ d >= r => SPAD__SYNTAX__ERROR()
+ advanceChar!()
+ PARSE_-INTEGER(buf,KEYWORD::START,mark,KEYWORD::RADIX,r)
+
+radixSuffix? c ==
+ c = char "r" or c = char "R"
+
+++ Parse an integer token, written either implicitly in decimal form,
+++ or explicitly specified radix. The number may be written in plain
+++ format, where the radix is implicitly taken to be 10. Or the spelling
+++ can explicitly specify a radix. That radix can be anything
+++ in the range 2..36
+getSpadIntegerToken tok ==
+ buf := MAKE_-ADJUSTABLE_-STRING 0
+ val := getDecimalNumberToken buf
+ advanceChar!()
+ if radixSuffix? currentChar() then
+ val := getIntegerInRadix(buf,val)
+ advanceChar!()
+ tokenInstall(val,'NUMBER,tok,#buf)
+
getNumberToken tok ==
buf := nil
repeat
@@ -214,7 +254,7 @@ getToken tok ==
getIdentifier(tok,true)
tt is 'ARGUMENT_-DESIGNATOR => getArgumentDesignator tok
tt is 'ID => getIdentifier(tok,false)
- tt is 'NUM => GET_-SPAD_-INTEGER_-TOKEN tok
+ tt is 'NUM => getSpadIntegerToken tok
tt is 'STRING => getSpadString tok
tt is 'SPECIAL_-CHAR => getSpecial tok
getGliph(tok,tt)
diff --git a/src/interp/spad.lisp b/src/interp/spad.lisp
index a5cc55e6..51127730 100644
--- a/src/interp/spad.lisp
+++ b/src/interp/spad.lisp
@@ -35,7 +35,7 @@
; NAME: Scratchpad Package
; PURPOSE: This is an initialization and system-building file for Scratchpad.
-(IMPORT-MODULE "bootlex")
+(IMPORT-MODULE "spad-parser")
(import-module "postpar")
(import-module "debug")
(in-package "BOOT")