aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordos-reis <gdr@axiomatics.org>2008-10-19 00:02:42 +0000
committerdos-reis <gdr@axiomatics.org>2008-10-19 00:02:42 +0000
commitb1c72c39b960f8b0ad6471d331ff23f94bdfb6c1 (patch)
tree06bfbfcddd69640d00cd42048d5cc00320a7d2bd /src
parent55322fdb5d4cdf67644b3cc0d9930511e1abe80a (diff)
downloadopen-axiom-b1c72c39b960f8b0ad6471d331ff23f94bdfb6c1.tar.gz
* algebra/syntax.spad.pamphlet (Syntax): Simplify.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog4
-rw-r--r--src/algebra/syntax.spad.pamphlet78
2 files changed, 40 insertions, 42 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index fa693bce..8cd268ff 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,7 @@
+2008-10-18 Gabriel Dos Reis <gdr@cs.tamu.edu>
+
+ * algebra/syntax.spad.pamphlet (Syntax): Simplify.
+
2008-10-17 Gabriel Dos Reis <gdr@cs.tamu.edu>
* interp/debug.lisp (WHOCALLED): Add dummy definition.
diff --git a/src/algebra/syntax.spad.pamphlet b/src/algebra/syntax.spad.pamphlet
index 963e841b..380748d8 100644
--- a/src/algebra/syntax.spad.pamphlet
+++ b/src/algebra/syntax.spad.pamphlet
@@ -24,18 +24,19 @@ import SExpression
)abbrev domain SYNTAX Syntax
++ Author: Gabriel Dos Reis
++ Date Created: November 10, 2007
-++ Date Last Updated: December 05, 2007
+++ Date Last Updated: October 18, 2008
++ Description: This domain provides a simple domain, general enough for
-++ building complete representation of Spad programs as objects
-++ of a term algebra built from ground terms of type integers, foats,
-++ symbols, and strings.
-++ This domain differs from InputForm in that it represents
-++ any entity in a Spad program, not just expressions.
+++ building complete representation of Spad programs as objects
+++ of a term algebra built from ground terms of type integers, foats,
+++ symbols, and strings.
+++ This domain differs from InputForm in that it represents
+++ any entity in a Spad program, not just expressions. Furthermore,
+++ while InputForm may contain atoms like vectors and other Lisp
+++ objects, the Syntax domain is supposed to contain only that
+++ initial algebra build from the primitives listed above.
++ Related Constructors: Boolean, Integer, Float, Symbol, String, SExpression.
-++ See Also: SExpression, SetCategory.
+++ See Also: SExpression.
++ The equality supported by this domain is structural.
-++ Fixme: Provide direct support for boolean values, arbritrary
-++ precision float point values.
Syntax(): Public == Private where
Public == Join(UnionType, SetCategory) with
convert: % -> SExpression
@@ -118,32 +119,30 @@ Syntax(): Public == Private where
++ x case String is true if `x' really is a String
Private == add
- Rep == SExpression
x = y ==
EQUAL(x,y)$Lisp
-
+
s case Integer ==
- integer? rep s
+ INTEGERP(s)$Lisp
s case DoubleFloat ==
- float? rep s
+ FLOATP(s)$Lisp
s case String ==
- string? rep s
+ STRINGP(s)$Lisp
s case Symbol ==
- symbol? rep s
+ IDENTP(s)$Lisp
coerce(x: %): OutputForm ==
- x' := rep x
- string? x' => outputForm(x' : String)
- x'::OutputForm
+ x case String => outputForm(x : String)
+ x pretend OutputForm
convert(x: %): SExpression ==
- rep x
+ x : SExpression
convert(x: SExpression): % ==
- per x
+ x pretend %
coerce(i: Integer): % ==
i pretend %
@@ -158,7 +157,7 @@ Syntax(): Public == Private where
coerce(f: DoubleFloat): % ==
f pretend %
- autoCoerce(f: %): DoubleFloat == -- used for hard coercion
+ autoCoerce(f: %): DoubleFloat == -- used for hard coercion
f : DoubleFloat
coerce(f: %): DoubleFloat ==
@@ -186,37 +185,32 @@ Syntax(): Public == Private where
userError "invalid conversion target type"
buildSyntax(s: Symbol, l: List %): % ==
- -- ??? ideally we should have overloaded operator `per' that convert
- -- from list of syntax to syntax. But the compiler is at the
- -- moment defective for non-exported overloaded operations.
- -- Furthermore, this direct call to `CONS' is currently necessary
- -- in order to have the Syntax domain compiled as early as possible
- -- in algebra boostrapping process. It should be removed once
- -- the bootstrap process is improved.
- CONS(s,l)$Lisp @ %
+ CONS(s,l)$Lisp
buildSyntax(op: %, l: List %): % ==
- CONS(op,l)$Lisp @ %
+ CONS(op,l)$Lisp
nil? x ==
- null? rep x
+ NULL(x)$Lisp
+
+ atom?(x: %): Boolean ==
+ ATOM(x)$Lisp
getOperator x ==
- atom? rep x => userError "atom as operand to getOperator"
- op := car rep x
- symbol? op => symbol op
- integer? op => integer op
- float? op => float op
- string? op => string op
- convert op
+ atom? x => userError "atom as operand to getOperator"
+ op: % := CAR(x)$Lisp
+ op case Symbol => op pretend Symbol
+ op case Integer => op pretend Integer
+ op case DoubleFloat => op pretend DoubleFloat
+ op case String => op pretend String
+ op
compound? x ==
- pair? rep x
+ CONSP(x)$Lisp
getOperands x ==
- s := rep x
- atom? s => []
- [per t for t in destruct cdr s]
+ atom? x => []
+ CDR(x)$Lisp
@