aboutsummaryrefslogtreecommitdiff
path: root/src/interp/lexing.boot
diff options
context:
space:
mode:
authordos-reis <gdr@axiomatics.org>2011-10-11 22:00:39 +0000
committerdos-reis <gdr@axiomatics.org>2011-10-11 22:00:39 +0000
commit4aa013faa1399b7e31fa4220ae09b039c4a1b0e2 (patch)
tree82d673d5f3fe12e94f079c67d85fc2188393c73f /src/interp/lexing.boot
parent3d58c8ff9d2a29477d85828b0dd1c35fecbaab5b (diff)
downloadopen-axiom-4aa013faa1399b7e31fa4220ae09b039c4a1b0e2.tar.gz
* interp/lexing.boot (matchAdvanceString): New.
* interp/spad-parser.boot: New parsing functions. * interp/fnewmeta.lisp: Use them. (PARSE-VarForm): Remove. (PARSE-Scripts): Likewise. (PARSE-ScriptItem): Likewise. (PARSE-AnyId): Likewise. * interp/parsing.lisp (PARSE-OperatorFunctionName): Remove. (MATCH-ADVANCE-STRING): Likewise.
Diffstat (limited to 'src/interp/lexing.boot')
-rw-r--r--src/interp/lexing.boot21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/interp/lexing.boot b/src/interp/lexing.boot
index 712b1927..8be1464f 100644
--- a/src/interp/lexing.boot
+++ b/src/interp/lexing.boot
@@ -39,7 +39,9 @@ import sys_-macros
namespace BOOT
-module lexing
+module lexing where
+ matchString: %String -> %Maybe %Short
+ matchAdvanceString: %String -> %Maybe %Short
--%
--% Line abstract datatype
@@ -326,10 +328,12 @@ getIdentifier(tok,esc?) ==
'IDENTIFIER
tokenInstall(s,tt,tok,$nonblank)
+escapeKeywords: (%String,%Symbol) -> %String
escapeKeywords(nm,id) ==
symbolMember?(id,Keywords) => strconc('"__",nm)
nm
+underscore: %String -> %String
underscore s ==
n := #s - 1
and/[alphabetic? stringChar(s,i) for i in 0..n] => s
@@ -341,6 +345,7 @@ underscore s ==
buf := [c,:buf]
listToString reverse! buf
+quoteIfString: %Thing -> %Maybe %String
quoteIfString tok ==
tok = nil => nil
tt := tokenType tok
@@ -349,7 +354,7 @@ quoteIfString tok ==
tt is 'SPECIAL_-CHAR => charString tokenSymbol tok
tt is 'IDENTIFIER =>
escapeKeywords(symbolName tokenSymbol tok,tokenSymbol tok)
- tokenSymbol tok
+ symbolName tokenSymbol tok
ungetTokens() ==
$validTokens = 0 => true
@@ -385,6 +390,18 @@ matchString x ==
and/[stringChar(x,i) = stringChar(buf,idx + i) for i in 0..nx-1] and nx
nil
+++ Same as matchString except if successful, advance inputstream past `x'.
+matchAdvanceString x ==
+ n := #x >= #quoteIfString currentToken() and matchString x =>
+ lineCurrentIndex($spadLine) := lineCurrentIndex $spadLine + n
+ c :=
+ linePastEnd? $spadLine => charByName '"Space"
+ lineBuffer($spadLine).(lineCurrentIndex $spadLine)
+ lineCurrentChar($spadLine) := c
+ $priorToken := makeToken(makeSymbol x,'IDENTIFIER,$nonblank)
+ n
+ nil
+
--%
--% Stack abstract datatype.
--% Operational semantics: