diff options
author | dos-reis <gdr@axiomatics.org> | 2007-12-12 07:59:44 +0000 |
---|---|---|
committer | dos-reis <gdr@axiomatics.org> | 2007-12-12 07:59:44 +0000 |
commit | 09fab9d5ead86e96edbcc3a8a9a7a138d9fd3b0d (patch) | |
tree | cc38efd0737d6eea451cf8fb7a9ec9b567b6fdcd /src | |
parent | 6d7d09414b6a40d3005b591ed05f2f466a4494f0 (diff) | |
download | open-axiom-09fab9d5ead86e96edbcc3a8a9a7a138d9fd3b0d.tar.gz |
* syntax.spad (case$Syntax): Add four overloads with flag
parameters. Remove previous declaration.
(conver$Syntax): Use cases to filter out erroneous input.
(getOperator$Syntax): Remove dead code.
Diffstat (limited to 'src')
-rw-r--r-- | src/algebra/ChangeLog | 7 | ||||
-rw-r--r-- | src/algebra/syntax.spad | 58 |
2 files changed, 39 insertions, 26 deletions
diff --git a/src/algebra/ChangeLog b/src/algebra/ChangeLog index 3fd7f05d..e31ec7b0 100644 --- a/src/algebra/ChangeLog +++ b/src/algebra/ChangeLog @@ -1,3 +1,10 @@ +2007-12-12 Gabriel Dos Reis <gdr@cs.tamu.edu> + + * syntax.spad (case$Syntax): Add four overloads with flag + parameters. Remove previous declaration. + (conver$Syntax): Use cases to filter out erroneous input. + (getOperator$Syntax): Remove dead code. + 2007-12-11 Gabriel Dos Reis <gdr@cs.tamu.edu> * syntax.spad (nil?$Syntax): New predicate. diff --git a/src/algebra/syntax.spad b/src/algebra/syntax.spad index df62adb5..b6fac427 100644 --- a/src/algebra/syntax.spad +++ b/src/algebra/syntax.spad @@ -29,7 +29,6 @@ --NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - )abbrev domain SYNTAX Syntax ++ Author: Gabriel Dos Reis ++ Date Created: November 10, 2007 @@ -96,9 +95,17 @@ Syntax(): Public == Private where getOperands: % -> List % ++ getOperands(x) returns the list of operands to the operator in `x'. - _case: (%, Domain) -> Boolean - ++ x case t returns true if x really is of type t, e.g. - ++ Integer, DoubleFloat, Symbol, String, or %. + _case: (%, [|Integer|]) -> Boolean + ++ x case Integer is true is x really is an Integer + + _case: (%, [|DoubleFloat|]) -> Boolean + ++ x case DoubleFloat is true is x really is a DoubleFloat + + _case: (%, [|Symbol|]) -> Boolean + ++ x case Symbol is true is x really is a Symbol + + _case: (%, [|String|]) -> Boolean + ++ x case String is true is x really is a String Private ==> SExpression add rep(x: %): SExpression == @@ -107,6 +114,18 @@ Syntax(): Public == Private where per(x: SExpression): % == x pretend % + s case Integer == + integer? rep s + + s case DoubleFloat == + float? rep s + + s case String == + string? rep s + + s case Symbol == + symbol? rep s + convert(x: %): SExpression == rep x @@ -117,29 +136,29 @@ Syntax(): Public == Private where i pretend % convert(i: %): Integer == - not integer? rep i => userError "invalid conversion target type" - i pretend Integer + i case Integer => i + userError "invalid conversion target type" coerce(f: DoubleFloat): % == f pretend % convert(f: %): DoubleFloat == - not float? rep f => userError "invalid conversion target type" - f pretend DoubleFloat + f case DoubleFloat => f + userError "invalid conversion target type" coerce(s: Symbol): % == s pretend % convert(s: %): Symbol == - not symbol? rep s => userError "invalid conversion target type" - s pretend Symbol + s case Symbol => s + userError "invalid conversion target type" coerce(s: String): % == s pretend % convert(s: %): String == - not string? rep s => userError "invalid conversion target type" - s pretend String + s case String => s + userError "invalid conversion target type" buildSyntax(s: Symbol, l: List %): % == -- ??? ideally we should have overloaded operator `per' that convert @@ -155,22 +174,9 @@ Syntax(): Public == Private where getOperator x == atom? rep x => userError "atom as operand to getOperator" - s := car rep x - symbol? s => symbol s - integer? s => integer s - float? s => float s - string? s => string s - convert s + convert car rep x getOperands x == s := rep x atom? s => [] [per t for t in destruct cdr s] - - s case t == - symbol? rep s => t is Symbol - integer? rep s => t is Integer - float? rep s => t is DoubleFloat - string? rep s => t is String - pair? rep s => t is % - false |