\documentclass{article} \usepackage{axiom} \author{Gabriel Dos~Reis} \begin{document} \begin{abstract} \end{abstract} \tableofcontents \eject \section{domain Syntax} <>= import UnionType import SetCategory import Boolean import Integer import DoubleFloat import Symbol import SExpression )abbrev domain SYNTAX Syntax ++ Author: Gabriel Dos Reis ++ Date Created: November 10, 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. 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: Integer, DoubleFloat, Symbol, String, SExpression. ++ See Also: SExpression. ++ The equality supported by this domain is structural. Syntax(): Public == Private where Public == Join(UnionType, SetCategory, RetractableTo Integer, RetractableTo DoubleFloat, RetractableTo Symbol, RetractableTo String) with convert: % -> SExpression ++ convert(s) returns the s-expression representation of a syntax. convert: SExpression -> % ++ convert(s) converts an s-expression to Syntax. Note, when `s' ++ is not an atom, it is expected that it designates a proper list, ++ e.g. a sequence of cons cells ending with nil. coerce: % -> Integer ++ coerce(s) extracts and integer value from the syntax `s' autoCoerce: % -> Integer ++ autoCoerce(s) forcibly extracts an integer value from ++ the syntax `s'; no check performed. To be called only ++ at the discretion of the compiler. coerce: % -> DoubleFloat ++ coerce(s) extracts a float value from the syntax `s'. autoCoerce: % -> DoubleFloat ++ autoCoerce(s) forcibly extracts a float value from the syntax `s'; ++ no check performed. To be called only at the discretion of ++ the compiler coerce: % -> Symbol ++ coerce(s) extracts a symbol from the syntax `s'. autoCoerce: % -> Symbol ++ autoCoerce(s) forcibly extracts a symbo from the Syntax ++ domain `s'; no check performed. To be called only at ++ at the discretion of the compiler. coerce: % -> String ++ coerce(s) extracts a string value from the syntax `s'. autoCoerce: % -> String ++ autoCoerce(s) forcibly extracts a string value from ++ the syntax `s'; no check performed. To be called only at ++ the discretion of the compiler. buildSyntax: (Symbol, List %) -> % ++ buildSyntax(op, [a1, ..., an]) builds a syntax object ++ for op(a1,...,an). buildSyntax: (%, List %) -> % ++ buildSyntax(op, [a1, ..., an]) builds a syntax object ++ for op(a1,...,an). nil?: % -> Boolean ++ nil?(s) is true when `s' is a syntax for the constant nil. getOperator: % -> Union(Integer, DoubleFloat, Symbol, String, %) ++ getOperator(x) returns the operator, or tag, of the syntax `x'. ++ The value returned is itself a syntax if `x' really is an ++ application of a function symbol as opposed to being an ++ atomic ground term. getOperands: % -> List % ++ getOperands(x) returns the list of operands to the operator in `x'. compound?: % -> Boolean ++ compound? x is true when `x' is not an atomic syntax. _case: (%, [|Integer|]) -> Boolean ++ x case Integer is true if `x' really is an Integer _case: (%, [|DoubleFloat|]) -> Boolean ++ x case DoubleFloat is true if `x' really is a DoubleFloat _case: (%, [|Symbol|]) -> Boolean ++ x case Symbol is true if `x' really is a Symbol _case: (%, [|String|]) -> Boolean ++ x case String is true if `x' really is a String Private == add x = y == EQUAL(x,y)$Lisp s case Integer == INTEGERP(s)$Lisp s case DoubleFloat == FLOATP(s)$Lisp s case String == STRINGP(s)$Lisp s case Symbol == IDENTP(s)$Lisp coerce(x: %): OutputForm == x case String => outputForm(x : String) x pretend OutputForm convert(x: %): SExpression == x : SExpression convert(x: SExpression): % == x pretend % coerce(i: Integer): % == i pretend % autoCoerce(i: %): Integer == -- used for hard coercion i : Integer retractIfCan(x: %): Union(Integer,"failed") == x case Integer => x@Integer "failed" coerce(i: %): Integer == retract(i)@Integer coerce(f: DoubleFloat): % == f pretend % autoCoerce(f: %): DoubleFloat == -- used for hard coercion f : DoubleFloat retractIfCan(x: %): Union(DoubleFloat,"failed") == x case DoubleFloat => x@DoubleFloat "failed" coerce(f: %): DoubleFloat == retract(f)@DoubleFloat coerce(s: Symbol): % == s pretend % autoCoerce(s: %): Symbol == -- used for hard coercion s : Symbol retractIfCan(x: %): Union(Symbol,"failed") == x case Symbol => x@Symbol "failed" coerce(s: %): Symbol == retract(s)@Symbol coerce(s: String): % == s pretend % autoCoerce(s: %): String == -- used for hard coercion s : String retractIfCan(x: %): Union(String,"failed") == x case String => x@String "failed" coerce(s: %): String == retract(s)@String buildSyntax(s: Symbol, l: List %): % == CONS(s,l)$Lisp buildSyntax(op: %, l: List %): % == CONS(op,l)$Lisp nil? x == NULL(x)$Lisp atom?(x: %): Boolean == ATOM(x)$Lisp getOperator x == 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 == CONSP(x)$Lisp getOperands x == atom? x => [] CDR(x)$Lisp @ \section{domain ConstructorCall} <>= import SetCategory import Symbol import List Syntax )abbrev domain CTORCALL ConstructorCall ++ Author: Gabriel Dos Reis ++ Date Created: January 19, 2008 ++ Date Last Updated: July 03, 2008 ++ Description: This domains represents a syntax object that ++ designates a category, domain, or a package. ++ See Also: Syntax, Domain ConstructorCall(): Public == Private where Public == SetCategory with constructorName: % -> Symbol ++ constructorName c returns the name of the constructor arguments: % -> List Syntax ++ arguments returns the list of syntax objects for the ++ arguments used to invoke the constructor. Private == add Rep == List Syntax constructorName x == (first rep x)::Symbol arguments x == rest rep x x = y == rep x = rep y coerce x == outputDomainConstructor(x)$Lisp @ \section{The Signature domain} <>= import SetCategory import CoercibleTo import List import Syntax )abbrev domain SIG Signature ++ Author: Gabriel Dos Reis ++ Date Created: January 10, 2008 ++ Date Last Updated: August 30, 2008 ++ Description: This is the datatype for operation signatures as ++ used by the compiler and the interpreter. Note that this domain ++ differs from SignatureAst. ++ See also: ConstructorCall, Domain. Signature(): Public == Private where Public == SetCategory with signature: (List Syntax,Syntax) -> % ++ signature(s,t) constructs a Signature object with parameter ++ types indicaded by `s', and return type indicated by `t'. target: % -> Syntax ++ target(s) returns the target type of the signature `s'. source: % -> List Syntax ++ source(s) returns the list of parameter types of `s'. Private == add Rep == List Syntax signature(s,t) == per cons(t,s) target x == first rep x source x == rest rep x x = y == rep x = rep y coerce(x: %): OutputForm == rarrow([s::OutputForm for s in source x]::OutputForm, target(x)::OutputForm)$OutputForm @ \section{domain ElaboratedExpression} <>= import Boolean import Symbol import ConstructorCall import List import SExpression )abbrev domain ELABEXPR ElaboratedExpression ++ Author: Gabriel Dos Reis ++ Date Created: January 19, 2008 ++ Date Last Updated: January 20, 2008 ++ Description: This domains an expresion as elaborated by the interpreter. ++ See Also: ElaboratedExpression(): Public == Private where Public ==> CoercibleTo OutputForm with type: % -> ConstructorCall ++ type(e) returns the type of the expression as computed by ++ the interpreter. constant?: % -> Boolean ++ constant?(e) returns true if `e' is a constant. getConstant: % -> Union(SExpression,"failed") ++ getConstant(e) retrieves the constant value of `e'e. variable?: % -> Boolean ++ variable?(e) returns true if `e' is a variable. getIdentifier: % -> Union(Symbol,"failed") ++ getIdentifier(e) retrieves the name of the variable `e'. callForm?: % -> Boolean ++ callForm?(e) is true when `e' is a call expression. getOperator: % -> Union(Symbol, "failed") ++ getOperator(e) retrieves the operator being invoked in `e', ++ when `e' is an expression. getOperands: % -> Union(List %, "failed") ++ getOperands(e) returns the list of operands in `e', assuming it ++ is a call form. Private ==> add isAtomic(x: %): Boolean == ATOM(x)$Lisp @ Boolean type x == getMode(x)$Lisp @ ConstructorCall callForm? x == CONSP(x)$Lisp @ Boolean getOperator x == op: SExpression := getUnnameIfCan(x)$Lisp null? op => "failed" op pretend Symbol constant? x == isAtomic x and EQ(getUnnameIfCan(x)$Lisp, _$immediateDataSymbol$Lisp)$Lisp : Boolean getConstant x == constant? x => getValue(x)$Lisp @ SExpression "failed" variable? x == isAtomic x and not constant? x getIdentifier x == variable? x => symbol (getUnname(x)$Lisp@SExpression) "failed" @ \section{SpadAbstractSyntaxCategory} <>= import SetCategory import CoercibleTo Syntax )abbrev category ASTCAT AbstractSyntaxCategory ++ Author: Gabriel Dos Reis ++ Date Created: July 5, 2008 ++ Date Last Modified: September 21, 2008 ++ Description: This is the category of Spad abstract syntax trees. AbstractSyntaxCategory(): Category == Join(SetCategory, CoercibleTo Syntax) with coerce: Syntax -> % ++ coerce(s) parses syntax object `s' as a Spad construct. add coerce(x: %): Syntax == x pretend Syntax coerce(x: Syntax): % == x pretend % coerce(x: %): OutputForm == x::Syntax::OutputForm @ \section{The SpadSyntaxCategory category} <>= )abbrev category SASTCAT SpadSyntaxCategory ++ Author: Gabriel Dos Reis ++ Date Created: July 5, 2008 ++ Date Last Modified: September 3, 2008 ++ Description: This is the category of Spad syntax objects. SpadSyntaxCategory(): Category == AbstractSyntaxCategory @ \subsection{The Exports of SpadAst} <>= )abbrev category SPADXPT SpadAstExports ++ Author: Gabriel Dos Reis ++ Date Created: September 20, 2008 ++ Date Last Modified: September 21, 2008 ++ Description: This category describes the exported ++ signatures of the SpadAst domain. SpadAstExports(): Category == Join(SpadSyntaxCategory, UnionType) with _case: (%, [|ImportAst()|]) -> Boolean ++ s case ImportAst holds if `s' represents an `import' statement. autoCoerce: % -> ImportAst() ++ autoCoerce(s) returns the ImportAst view of `s'. Left at the ++ discretion of the compiler. _case: (%, [|DefinitionAst()|]) -> Boolean ++ s case DefinitionAst holds if `s' represents a definition. autoCoerce: % -> DefinitionAst() ++ autoCoerce(s) returns the DefinitionAst view of `s'. Left at the ++ discretion of the compiler. _case: (%, [|MacroAst()|]) -> Boolean ++ s case MacroAst holds if `s' represents a macro definition. autoCoerce: % -> MacroAst() ++ autoCoerce(s) returns the MacroAst view of `s'. Left at the ++ discretion of the compiler. _case: (%, [|WhereAst()|]) -> Boolean ++ s case WhereAst holds if `s' represents an expression with ++ local definitions. autoCoerce: % -> WhereAst() ++ autoCoerce(s) returns the WhereAst view of `s'. Left at the ++ discretion of the compiler. _case: (%, [|CategoryAst()|]) -> Boolean ++ s case CategoryAst holds if `s' represents an unnamed category. autoCoerce: % -> CategoryAst() ++ autoCoerce(s) returns the CategoryAst view of `s'. Left at the ++ discretion of the compiler. _case: (%, [|CapsuleAst()|]) -> Boolean ++ s case CapsuleAst holds if `s' represents a domain capsule. autoCoerce: % -> CapsuleAst() ++ autoCoerce(s) returns the CapsuleAst view of `s'. Left at the ++ discretion of the compiler. _case: (%, [|SignatureAst()|]) -> Boolean ++ s case SignatureAst holds if `s' represents a signature export. autoCoerce: % -> SignatureAst() ++ autoCoerce(s) returns the SignatureAst view of `s'. Left at the ++ discretion of the compiler. _case: (%, [|AttributeAst()|]) -> Boolean ++ s case AttributeAst holds if `s' represents an attribute. autoCoerce: % -> AttributeAst() ++ autoCoerce(s) returns the AttributeAst view of `s'. Left at the ++ discretion of the compiler. _case: (%, [|MappingAst()|]) -> Boolean ++ s case MappingAst holds if `s' represents a mapping type. autoCoerce: % -> MappingAst() ++ autoCoerce(s) returns the MappingAst view of `s'. Left at the ++ discretion of the compiler. _case: (%, [|IfAst()|]) -> Boolean ++ s case IfAst holds if `s' represents an if-statement. autoCoerce: % -> IfAst() ++ autoCoerce(s) returns the IfAst view of `s'. Left at the ++ discretion of the compiler. _case: (%, [|RepeatAst()|]) -> Boolean ++ s case RepeatAst holds if `s' represents an repeat-loop. autoCoerce: % -> RepeatAst() ++ autoCoerce(s) returns the RepeatAst view of `s'. Left at the ++ discretion of the compiler. _case: (%, [|WhileAst()|]) -> Boolean ++ s case WhileAst holds if `s' represents a while-iterator autoCoerce: % -> WhileAst() ++ autoCoerce(s) returns the WhileAst view of `s'. Left at the ++ discretion of the compiler. _case: (%, [|InAst()|]) -> Boolean ++ s case InAst holds if `s' represents a in-iterator autoCoerce: % -> InAst() ++ autoCoerce(s) returns the InAst view of `s'. Left at the ++ discretion of the compiler. _case: (%, [|CollectAst()|]) -> Boolean ++ s case CollectAst holds if `s' represents a list-comprehension. autoCoerce: % -> CollectAst() ++ autoCoerce(s) returns the CollectAst view of `s'. Left at the ++ discretion of the compiler. _case: (%, [|ConstructAst()|]) -> Boolean ++ s case ConstructAst holds if `s' represents a list-expression. autoCoerce: % -> ConstructAst() ++ autoCoerce(s) returns the ConstructAst view of `s'. Left at the ++ discretion of the compiler. _case: (%, [|ExitAst()|]) -> Boolean ++ s case ExitAst holds if `s' represents an exit-expression. autoCoerce: % -> ExitAst() ++ autoCoerce(s) returns the ExitAst view of `s'. Left at the ++ discretion of the compiler. _case: (%, [|ReturnAst()|]) -> Boolean ++ s case ReturnAst holds if `s' represents a return-statement. autoCoerce: % -> ReturnAst() ++ autoCoerce(s) returns the ReturnAst view of `s'. Left at the ++ discretion of the compiler. _case: (%, [|CoerceAst()|]) -> Boolean ++ s case ReturnAst holds if `s' represents a coerce-expression. autoCoerce: % -> CoerceAst() ++ autoCoerce(s) returns the CoerceAst view of `s'. Left at the ++ discretion of the compiler. _case: (%, [|PretendAst()|]) -> Boolean ++ s case PretendAst holds if `s' represents a pretend-expression. autoCoerce: % -> PretendAst() ++ autoCoerce(s) returns the PretendAst view of `s'. Left at the ++ discretion of the compiler. _case: (%, [|RestrictAst()|]) -> Boolean ++ s case RestrictAst holds if `s' represents a restrict-expression. autoCoerce: % -> RestrictAst() ++ autoCoerce(s) returns the RestrictAst view of `s'. Left at the ++ discretion of the compiler. _case: (%, [|SegmentAst()|]) -> Boolean ++ s case SegmentAst holds if `s' represents a segment-expression. autoCoerce: % -> SegmentAst() ++ autoCoerce(s) returns the SegmentAst view of `s'. Left at the ++ discretion of the compiler. _case: (%, [|SequenceAst()|]) -> Boolean ++ s case SequenceAst holds if `s' represents a sequence-of-statements. autoCoerce: % -> SequenceAst() ++ autoCoerce(s) returns the SequenceAst view of `s'. Left at the ++ discretion of the compiler. _case: (%, [|LetAst()|]) -> Boolean ++ s case LetAst holds if `s' represents an assignment-expression. autoCoerce: % -> LetAst() ++ autoCoerce(s) returns the LetAst view of `s'. Left at the ++ discretion of the compiler. _case: (%, [|SuchThatAst()|]) -> Boolean ++ s case SuchThatAst holds if `s' represents a qualified-expression. autoCoerce: % -> SuchThatAst() ++ autoCoerce(s) returns the SuchThatAst view of `s'. Left at the ++ discretion of the compiler. _case: (%, [|ColonAst()|]) -> Boolean ++ s case ColonAst holds if `s' represents a colon-expression. autoCoerce: % -> ColonAst() ++ autoCoerce(s) returns the ColoonAst view of `s'. Left at the ++ discretion of the compiler. _case: (%, [|CaseAst()|]) -> Boolean ++ s case CaseAst holds if `s' represents a case-expression. autoCoerce: % -> CaseAst() ++ autoCoerce(s) returns the CaseAst view of `s'. Left at the ++ discretion of the compiler. _case: (%, [|HasAst()|]) -> Boolean ++ s case HasAst holds if `s' represents a has-expression. autoCoerce: % -> HasAst() ++ autoCoerce(s) returns the HasAst view of `s'. Left at the ++ discretion of the compiler. _case: (%, [|IsAst()|]) -> Boolean ++ s case IsAst holds if `s' represents an is-expression. autoCoerce: % -> IsAst() ++ autoCoerce(s) returns the IsAst view of `s'. Left at the ++ discretion of the compiler. _case: (%, [|Identifier|]) -> Boolean ++ s case Identifier holds if `s' represents an identifier. autoCoerce: % -> Identifier ++ autoCoerce(s) returns the Identifier view of `s'. Left at the ++ discretion of the compiler. _case: (%, [|String|]) -> Boolean ++ s case String holds if `s' represents a string literal. autoCoerce: % -> String ++ autoCoerce(s) returns the String view of `s'. Left at the ++ discretion of the compiler. _case: (%, [|Integer|]) -> Boolean ++ s case Integer holds if `s' represents an integer literal. autoCoerce: % -> Integer ++ autoCoerce(s) returns the Integer view of `s'. Left at the ++ discretion of the compiler. @ \subsection{The Literal domain} <>= )abbrev domain LITERAL Literal ++ Author: Gabriel Dos Reis ++ Date Created: July 5, 2008 ++ Date Last Modified: September 1, 2008 ++ Description: This domain represents AST for Spad literals. Literal(T: SetCategory): Public == Private where Public == Join(SpadSyntaxCategory, CoercibleTo T) Private == add Rep == T coerce(x: %): T == rep x coerce(x: %): OutputForm == x::T::OutputForm @ \subsection{The Identifier domain} <>= ++ Author: Gabriel Dos Reis ++ Date Created: July 5, 2008 ++ Date Last Modified: September 1, 2008 ++ Description: This domain represents identifer AST. )abbrev domain IDENT Identifier Identifier(): Public == Private where Public == Join(SpadSyntaxCategory, CoercibleTo Symbol) Private == add Rep == Symbol coerce(x: %): Symbol == rep x coerce(x: %): OutputForm == x::Symbol::OutputForm @ \subsection{The HeadAst domain} <>= import AbstractSyntaxCategory import Symbol import List Symbol )abbrev domain HEADAST HeadAst ++ Author: Gabriel Dos Reis ++ Date Created: November 10, 2007 ++ Date Last Modified: September 21, 2008 ++ Description: This domain represents the header of a definition. HeadAst(): Public == Private where Public == SpadSyntaxCategory with headAst: (Identifier,List Identifier) -> % ++ headAst(f,[x1,..,xn]) constructs a function definition header. name: % -> Identifier ++ name(h) returns the name of the operation defined defined. parameters: % -> List Identifier ++ parameters(h) gives the parameters specified in the ++ definition header `h'. Private == add Rep == List Identifier headAst(op,args) == per cons(op,args) name h == first rep h parameters h == rest rep h coerce(x: %): OutputForm == elt('HeadAst::OutputForm, ['name::OutputForm = name(x)::OutputForm, 'parameters::OutputForm = parameters(x)::OutputForm])$OutputForm @ \subsection{The TypeAst domain} <>= SpadAst(): SpadAstExports import AbstractSyntaxCategory )abbrev domain TYPEAST TypeAst ++ Author: Gabriel Dos Reis ++ Date Created: November 10, 2007 ++ Date Last Modified: September 21, 2008 ++ Description: This domain represents a type AST. TypeAst(): Public == Private where Public == SpadSyntaxCategory Private == add coerce(x: %): OutputForm == (x : SpadAst)::OutputForm @ \subsection{The ImportAst domain} <>= import List import TypeAst )abbrev domain IMPTAST ImportAst )abbrev domain TYPEAST TypeAst ++ Author: Gabriel Dos Reis ++ Date Created: November 10, 2007 ++ Date Last Modified: September 21, 2008 ++ Description: This domain represents an `import' of types. ImportAst(): Public == Private where Public == SpadSyntaxCategory with coerce: List TypeAst -> % ++ ts::ImportAst constructs an ImportAst for the list if types `ts'. imports: % -> List TypeAst ++ imports(x) returns the list of imported types. Private == add import Pair Rep == Pair(Symbol, List TypeAst) coerce(ts: List TypeAst): % == per pair('import,ts) imports x == second rep x coerce(x: %): OutputForm == elt('ImportAst::OutputForm, ['imports::OutputForm = imports(x)::OutputForm])$OutputForm @ \subsection{The MappingAst domain} <>= )abbrev domain MAPPAST MappingAst ++ Author: Gabriel Dos Reis ++ Date Created: November 10, 2007 ++ Date Last Modified: September 21, 2008 ++ Description: This domain represents a mapping type AST. A mapping AST ++ is a syntactic description of a function type, e.g. its result ++ type and the list of its argument types. MappingAst(): Public == Private where Public == Join(SpadSyntaxCategory, CoercibleTo TypeAst) with coerce: Signature -> % ++ sig::MappingAst builds a MappingAst from the Signature `sig'. mappingAst: (List TypeAst, TypeAst) -> % ++ mappingAst(s,t) builds the mapping AST s -> t source: % -> List TypeAst ++ source(s) returns the parameter type AST list of `s'. target: % -> TypeAst ++ target(s) returns the result type AST for `s'. Private == add import Pair Rep == Pair(Symbol,Signature) coerce(sig: Signature): % == per pair('Mapping,sig) mappingAst(s,t) == per pair('Mapping,cons(t,s) : Signature) source x == source(second rep x)$Signature : List(TypeAst) target x == target(second rep x)$Signature : TypeAst coerce(x: %): TypeAst == x : TypeAst coerce(x: %): OutputForm == elt('MappingAst::OutputForm, ['source::OutputForm = source(x)::OutputForm, 'target::OutputForm = target(x)::OutputForm])$OutputForm @ \subsection{The SignatureAst domain} <>= )abbrev domain SIGAST SignatureAst ++ Author: Gabriel Dos Reis ++ Date Created: November 10, 2007 ++ Date Last Modified: September 21, 2008 ++ Description: This domain represents a signature AST. A signature AST ++ is a description of an exported operation, e.g. its name, result ++ type, and the list of its argument types. SignatureAst(): Public == Private where Public == SpadSyntaxCategory with signatureAst: (Identifier, Signature) -> % ++ signatureAst(n,s,t) builds the signature AST n: s -> t name: % -> Identifier ++ name(s) returns the name of the signature `s'. signature: % -> Signature ++ signature(s) returns AST of the declared signature for `s'. Private == add import List Rep == Pair(Symbol, Pair(Identifier,List Signature)) signatureAst(n,sig) == per pair('SIGNATURE,pair(n,[sig])) name x == first second rep x signature x == value second second rep x coerce(x: %): OutputForm == elt('SignatureAst::OutputForm, ['name::OutputForm = name(x)::OutputForm, 'signature::OutputForm = signature(x)::OutputForm])$OutputForm @ \subsection{The AttributeAst domain} <>= SpadAst(): SpadAstExports )abbrev domain ATTRAST AttributeAst ++ Author: Gabriel Dos Reis ++ Date Created: November 10, 2007 ++ Date Last Modified: September 21, 2008 ++ Description: This domain represents the syntax of an attribute in ++ a category expression. AttributeAst(): Public == Private where Public == SpadSyntaxCategory with name: % -> SpadAst ++ name(a) returns the name of the attribute `a'. Note, this ++ name may be domain name, not just an identifier. Private == add Rep == Pair(Symbol,SpadAst) name x == second rep x coerce(x: %): OutputForm == elt('AttributeAst::OutputForm, ['name::OutputForm = name(x)::OutputForm])$OutputForm @ \subsection{The JoinAst domain} <>= )abbrev domain JOINAST JoinAst ++ Author: Gabriel Dos Reis ++ Date Created: November 10, 2007 ++ Date Last Modified: September 21, 2008 ++ Description: This domain represents the join of categories ASTs. JoinAst(): Public == Private where Public == Join(SpadSyntaxCategory, CoercibleTo TypeAst) with coerce: List TypeAst -> % ++ ts::JoinAst construct the AST for a join of the types `ts'. categories: % -> List TypeAst ++ catehories(x) returns the types in the join `x'. Private == add Rep == Pair(Symbol, List TypeAst) categories x == second rep x coerce(cats: List TypeAst): % == per pair('Join,cats) coerce(x: %): TypeAst == x : TypeAst @ \subsection{The IfAst domain} <>= SpadAst(): SpadAstExports )abbrev domain IFAST IfAst ++ Author: Gabriel Dos Reis ++ Date Created: November 10, 2007 ++ Date Last Modified: September 21, 2008 ++ Description: This domain represents AST for conditional expressions. IfAst(): Public == Private where Public == SpadSyntaxCategory with condition: % -> SpadAst ++ condition(e) returns the condition of the if-expression `e'. thenBranch: % -> SpadAst ++ thenBranch(e) returns the `then-branch' of `e'. elseBranch: % -> SpadAst ++ thenBranch(e) returns the `else-branch' of `e'. Private == add Rep == List SpadAst condition x == second rep x thenBranch x == third rep x elseBranch x == last rep x coerce(x: %): OutputForm == elt('IfAst::OutputForm, ['condition::OutputForm = condition(x)::OutputForm, 'thenBranch::OutputForm = thenBranch(x)::OutputForm, 'elseBranch::OutputForm = elseBranch(x)::OutputForm])$OutputForm @ \subsection{The RepeatAst domain} <>= SpadAst(): SpadAstExports )abbrev domain RPTAST RepeatAst ++ Author: Gabriel Dos Reis ++ Date Created: November 10, 2007 ++ Date Last Modified: September 21, 2008 ++ Description: This domain represents the `repeat' iterator syntax. RepeatAst(): Public == Private where Public == SpadSyntaxCategory with iterators: % -> List SpadAst ++ iterators(e) returns the list of iterators controlling the loop `e'. body: % -> SpadAst ++ body(e) returns the body of the loop `e'. Private == add Rep == List SpadAst iterators x == s := rep x s.(2..(#s - 1)) body x == last rep x coerce(x: %): OutputForm == elt('RepeatAst::OutputForm, ['iterators::OutputForm = iterators(x)::OutputForm, 'body::OutputForm = body(x)::OutputForm])$OutputForm @ \subsection{The WhileAst domain} <>= SpadAst(): SpadAstExports )abbrev domain WHILEAST WhileAst ++ Author: Gabriel Dos Reis ++ Date Created: November 10, 2007 ++ Date Last Modified: September 21, 2008 ++ Description: This domain represents the `while' iterator syntax. WhileAst(): Public == Private where Public == SpadSyntaxCategory with condition: % -> SpadAst ++ condition(i) returns the condition of the while iterator `i'. Private == add Rep == Pair(Symbol,SpadAst) condition x == second rep x coerce(x: %): OutputForm == elt('WhileAst::OutputForm, ['condition::OutputForm = condition(x)::OutputForm])$OutputForm @ \subsection{The InAst domain} <>= SpadAst(): SpadAstExports )abbrev domain INAST InAst ++ Author: Gabriel Dos Reis ++ Date Created: November 10, 2007 ++ Date Last Modified: September 21, 2008 ++ Description: This domain represents the `in' iterator syntax. InAst(): Public == Private where Public == SpadSyntaxCategory with iterationVar: % -> Symbol ++ iterationVar(i) returns the name of the iterating ++ variable of the `in' iterator 'i' sequence: % -> SpadAst ++ sequence(i) returns the sequence expression being ++ iterated over by `i'. Private == add Rep == List Syntax iterationVar x == (second rep x)::Symbol sequence x == (last rep x) : SpadAst coerce(x: %): OutputForm == elt('InAst::OutputForm, ['iterationVar::OutputForm = iterationVar(x)::OutputForm, 'sequence::OutputForm = sequence(x)::OutputForm])$OutputForm @ \subsection{The CollectAst domain} <>= SpadAst(): SpadAstExports )abbrev domain CLLCTAST CollectAst ++ Author: Gabriel Dos Reis ++ Date Created: November 10, 2007 ++ Date Last Modified: September 21, 2008 ++ Description: This domain represents list comprehension syntax. CollectAst(): Public == Private where Public == SpadSyntaxCategory with iterators: % -> List SpadAst ++ iterators(e) returns the list of the iterators of ++ the list comprehension `e'. body: % -> SpadAst ++ body(e) return the expression being ++ collected by the list comprehension `e'. Private == add Rep == List SpadAst body x == last rep x iterators x == s := rep x s.(2..(#s -1)) coerce(x: %): OutputForm == elt('CollectAst::OutputForm, ['iterators::OutputForm = iterators(x)::OutputForm, 'body::OutputForm = body(x)::OutputForm])$OutputForm @ \subsection{The ReduceAst domain} <>= SpadAst(): SpadAstExports )abbrev domain RDUCEAST ReduceAst ++ Author: Gabriel Dos Reis ++ Date Created: November 10, 2007 ++ Date Last Modified: September 21, 2008 ++ Description: This domain represents list reduction syntax. ReduceAst(): Public == Private where Public == SpadSyntaxCategory with operator: % -> SpadAst ++ operator(e) returns the magma operation being applied. body: % -> SpadAst ++ body(e) return the list of expressions being redcued. Private == add Rep == List SpadAst operator x == second rep x body x == third rep x @ \subsection{The ConstructAst domain} <>= SpadAst(): SpadAstExports )abbrev domain LSTAST ConstructAst ++ Author: Gabriel Dos Reis ++ Date Created: November 10, 2007 ++ Date Last Modified: September 21, 2008 ++ Description: This domain represents `literal sequence' syntax. ConstructAst(): Public == Private where Public == SpadSyntaxCategory with elements: % -> List SpadAst ++ elements(e) returns the list of expressions in the ++ `literal' list `e'. Private == add import Pair Rep == Pair(Symbol, List SpadAst) elements x == second rep x coerce(x: %): OutputForm == elt('ConstructAst::OutputForm, ['elements::OutputForm = elements(x)::OutputForm])$OutputForm @ \subsection{The ExitAst domain} <>= SpadAst(): SpadAstExports )abbrev domain EXITAST ExitAst ++ Author: Gabriel Dos Reis ++ Date Created: November 10, 2007 ++ Date Last Modified: September 21, 2008 ++ Description: This domain represents exit expressions. ExitAst(): Public == Private where Public == SpadSyntaxCategory with expression: % -> SpadAst ++ expression(e) returns the exit expression of `e'. level: % -> Integer ++ level(e) returns the nesting exit level of `e' Private == add Rep == List SpadAst expression x == third rep x level x == (second rep x) : Integer coerce(x: %): OutputForm == elt('ExitAst::OutputForm, ['level::OutputForm = level(x)::OutputForm, 'expression::OutputForm = expression(x)::OutputForm])$OutputForm @ \subsection{The ReturnAst domain} <>= SpadAst(): SpadAstExports )abbrev domain RETAST ReturnAst ++ Author: Gabriel Dos Reis ++ Date Created: November 10, 2007 ++ Date Last Modified: September 21, 2008 ++ Description: This domain represents `return' expressions. ReturnAst(): Public == Private where Public == SpadSyntaxCategory with expression: % -> SpadAst ++ expression(e) returns the expression returned by `e'. Private == add import Pair Rep == Pair(Symbol,SpadAst) expression x == second rep x coerce(x: %): OutputForm == elt('ReturnAst::OutputForm, ['expression::OutputForm = expression(x)::OutputForm])$OutputForm @ \subsection{The SequenceAst domain} <>= SpadAst(): SpadAstExports )abbrev domain SEQAST SequenceAst ++ Author: Gabriel Dos Reis ++ Date Created: November 10, 2007 ++ Date Last Modified: September 21, 2008 ++ Description: This domain represents a block of expressions. SequenceAst(): Public == Private where Public == SpadSyntaxCategory with body: % -> List SpadAst ++ body(e) returns the list of expressions in the sequence ++ of instruction `e'. last: % -> SpadAst ++ last(e) returns the last instruction in `e'. Private == add import Pair Rep == Pair(Symbol,List SpadAst) body x == second rep x last x == last(second rep x)$List(SpadAst) coerce(x: %): OutputForm == elt('SequenceAst::OutputForm, ['body::OutputForm = body(x)::OutputForm])$OutputForm @ \subsection{The LetAst domain} <>= SpadAst(): SpadAstExports import List )abbrev domain LETAST LetAst ++ Author: Gabriel Dos Reis ++ Date Created: November 10, 2007 ++ Date Last Modified: September 21, 2008 ++ Description: This domain represents assignment expressions. LetAst(): Public == Private where Public == SpadSyntaxCategory with lhs: % -> SpadAst ++ lhs(e) returns the left hand side of the assignment expression `e'. rhs: % -> SpadAst ++ rhs(e) returns the right hand side of the assignment expression `e'. Private == add Rep == List SpadAst lhs x == second rep x rhs x == third rep x coerce(x: %): OutputForm == elt('LetAst::OutputForm, ['lhs::OutputForm = lhs(x)::OutputForm, 'rhs::OutputForm = rhs(x)::OutputForm])$OutputForm @ \subsection{The PretendAst domain} <>= SpadAst(): SpadAstExports )abbrev domain PRTDAST PretendAst ++ Author: Gabriel Dos Reis ++ Date Created: November 10, 2007 ++ Date Last Modified: September 21, 2008 ++ Description: This domain represents `pretend' expressions. PretendAst(): Public == Private where Public == SpadSyntaxCategory with expression: % -> SpadAst ++ expression(e) returns the expression being converted. target: % -> TypeAst ++ target(e) returns the target type of the conversion.. Private == add Rep == List Syntax expression x == (second rep x) : SpadAst target x == (third rep x) : TypeAst coerce(x: %): OutputForm == elt('PretendAst::OutputForm, ['expression::OutputForm = expression(x)::OutputForm, 'target::OutputForm = target(x)::OutputForm])$OutputForm @ \subsection{The CoerceAst domain} <>= SpadAst(): SpadAstExports )abbrev domain CRCEAST CoerceAst ++ Author: Gabriel Dos Reis ++ Date Created: November 10, 2007 ++ Date Last Modified: September 21, 2008 ++ Description: This domain represents `coerce' expressions. CoerceAst(): Public == Private where Public == SpadSyntaxCategory with expression: % -> SpadAst ++ expression(e) returns the expression being converted. target: % -> TypeAst ++ target(e) returns the target type of the conversion.. Private == add Rep == List Syntax expression x == (second rep x) : SpadAst target x == (third rep x) : TypeAst coerce(x: %): OutputForm == elt('CoerceAst::OutputForm, ['expression::OutputForm = expression(x)::OutputForm, 'target::OutputForm = target(x)::OutputForm])$OutputForm @ \subsection{The RestrictAst domain} <>= SpadAst(): SpadAstExports )abbrev domain RSTRCAST RestrictAst ++ Author: Gabriel Dos Reis ++ Date Created: November 10, 2007 ++ Date Last Modified: September 21, 2008 ++ Description: This domain represents `restrict' expressions. RestrictAst(): Public == Private where Public == SpadSyntaxCategory with expression: % -> SpadAst ++ expression(e) returns the expression being converted. target: % -> TypeAst ++ target(e) returns the target type of the conversion.. Private == add Rep == List Syntax expression x == (second rep x) : SpadAst target x == (third rep x) : TypeAst coerce(x: %): OutputForm == elt('RestrictAst::OutputForm, ['expression::OutputForm = expression(x)::OutputForm, 'target::OutputForm = target(x)::OutputForm])$OutputForm @ \subsection{The CallAst domain} <>= SpadAst(): SpadAstExports import List )abbrev domain CALLAST CallAst ++ Author: Gabriel Dos Reis ++ Date Created: November 10, 2007 ++ Date Last Modified: September 21, 2008 ++ Description: This domain represents calls. CallAst(): Public == Private where Public == SpadSyntaxCategory with operator: % -> SpadAst ++ operation(e) returns the operation being called in `e'. operands: % -> List SpadAst ++ arguments(e) returns the argument list used in the call `e'. Private == add Rep == List SpadAst operator x == first rep x operands x == rest rep x coerce(x: %): OutputForm == elt('CallAst::OutputForm, ['operator::OutputForm = operator(x)::OutputForm, 'operands::OutputForm = operands(x)::OutputForm])$OutputForm @ \subsection{The SegmentAst domain} <>= SpadAst(): SpadAstExports )abbrev domain SEGAST SegmentAst ++ Author: Gabriel Dos Reis ++ Date Created: November 10, 2007 ++ Date Last Modified: September 21, 2008 ++ Description: This domain represents segement expressions. SegmentAst(): Public == Private where Public == SpadSyntaxCategory with bounds: % -> List SpadAst ++ bounds(s) returns the bounds of the segment `s'. If ++ `s' designates an infinite interval, then the returns ++ list a singleton list. Private == add Rep == List SpadAst bounds x == rest rep x coerce(x: %): OutputForm == elt('SegmentAst::OutputForm, ['bounds::OutputForm = bounds(x)::OutputForm])$OutputForm @ \subsection{The SuchThatAst domain} <>= SpadAst(): SpadAstExports )abbrev domain SUCHTAST SuchThatAst ++ Author: Gabriel Dos Reis ++ Date Created: November 10, 2007 ++ Date Last Modified: September 21, 2008 ++ Description: This domain represents the filter iterator syntax. SuchThatAst(): Public == Private where Public == SpadSyntaxCategory with predicate: % -> SpadAst ++ predicate(e) returns the syntax object for the predicate ++ in the filter iterator syntax `e'. Private == add Rep == List SpadAst predicate e == second rep e coerce(x: %): OutputForm == elt('SuchThatAst::OutputForm, ['predicate::OutputForm = predicate(x)::OutputForm])$OutputForm @ \subsection{The ColonAst domain} <>= SpadAst(): SpadAstExports )abbrev domain COLONAST ColonAst ++ Author: Gabriel Dos Reis ++ Date Created: November 10, 2007 ++ Date Last Modified: September 21, 2008 ++ Description: This domain represents type specification ++ for an identifier or expression. ColonAst(): Public == Private where Public == SpadSyntaxCategory with lhs: % -> SpadAst ++ lhs(e) returns the left hand side of the colon expression `e'. rhs: % -> TypeAst ++ rhs(e) returns the right hand side of the colon expression `e'. Private == add Rep == List SpadAst lhs x == (second rep x) : SpadAst rhs x == (third rep x) : TypeAst coerce(x: %): OutputForm == elt('ColonAst::OutputForm, ['lhs::OutputForm = lhs(x)::OutputForm, 'rhs::OutputForm = rhs(x)::OutputForm])$OutputForm @ \subsection{The AddAst domain} <>= SpadAst(): SpadAstExports )abbrev domain ADDAST AddAst ++ Author: Gabriel Dos Reis ++ Date Created: November 10, 2007 ++ Date Last Modified: September 21, 2008 ++ Description: This domain represents the syntax for an add-expression. AddAst(): Public == Private where Public == SpadSyntaxCategory with base: % -> SpadAst ++ base(d) returns the base domain(s) of the add-domain expression. body: % -> SpadAst ++ base(d) returns the actual body of the add-domain expression `d'. Private == add Rep == List SpadAst base x == second rep x body x == third rep x coerce(x: %): OutputForm == elt('AddAst::OutputForm, ['base::OutputForm = base(x)::OutputForm, 'body::OutputForm = body(x)::OutputForm])$OutputForm @ \subsection{The CapsuleAst domain} <>= SpadAst(): SpadAstExports )abbrev domain CAPSLAST CapsuleAst ++ Author: Gabriel Dos Reis ++ Date Created: November 10, 2007 ++ Date Last Modified: September 21, 2008 ++ Description: This domain represents the capsule of a domain definition. CapsuleAst(): Public == Private where Public == SpadSyntaxCategory with body: % -> List SpadAst ++ body(c) returns the list of top level expressions appearing in `c'. Private == add Rep == Pair(Symbol, List SpadAst) body x == second rep x coerce(x: %): OutputForm == elt('CapsuleAst::OutputForm, ['body::OutputForm = body(x)::OutputForm])$OutputForm @ \subsection{The CaseAst domain} <>= SpadAst(): SpadAstExports )abbrev domain CASEAST CaseAst ++ Author: Gabriel Dos Reis ++ Date Created: November 10, 2007 ++ Date Last Modified: September 21, 2008 ++ Description: This domain represents a `case' expression. CaseAst(): Public == Private where Public == SpadSyntaxCategory with lhs: % -> SpadAst ++ lhs(e) returns the left hand side of the case expression `e'. rhs: % -> SpadAst ++ rhs(e) returns the right hand side of the case expression `e'. Private == add Rep == List SpadAst lhs x == second rep x rhs x == third rep x coerce(x: %): OutputForm == elt('CaseAst::OutputForm, ['lhs::OutputForm = lhs(x)::OutputForm, 'rhs::OutputForm = rhs(x)::OutputForm])$OutputForm @ \subsection{The HasAst domain} <>= SpadAst(): SpadAstExports )abbrev domain HASAST HasAst ++ Author: Gabriel Dos Reis ++ Date Created: November 10, 2007 ++ Date Last Modified: September 21, 2008 ++ Description: This domain represents a `has' expression. HasAst(): Public == Private where Public == SpadSyntaxCategory with lhs: % -> SpadAst ++ lhs(e) returns the left hand side of the has expression `e'. rhs: % -> SpadAst ++ rhs(e) returns the right hand side of the case expression `e'. Private == add Rep == List SpadAst lhs x == second rep x rhs x == third rep x coerce(x: %): OutputForm == elt('HasAst::OutputForm, ['lhs::OutputForm = lhs(x)::OutputForm, 'rhs::OutputForm = rhs(x)::OutputForm])$OutputForm @ \subsection{The IsAst domain} <>= SpadAst(): SpadAstExports )abbrev domain ISAST IsAst ++ Author: Gabriel Dos Reis ++ Date Created: November 10, 2007 ++ Date Last Modified: September 21, 2008 ++ Description: This domain represents a `has' expression. IsAst(): Public == Private where Public == SpadSyntaxCategory with lhs: % -> SpadAst ++ lhs(e) returns the left hand side of the is expression `e'. rhs: % -> SpadAst ++ rhs(e) returns the right hand side of the is expression `e'. Private == add Rep == List SpadAst lhs x == second rep x rhs x == third rep x coerce(x: %): OutputForm == elt('IsAst::OutputForm, ['lhs::OutputForm = lhs(x)::OutputForm, 'rhs::OutputForm = rhs(x)::OutputForm])$OutputForm @ \subsection{The CategoryAst domain} <>= SpadAst(): SpadAstExports )abbrev domain CATAST CategoryAst ++ Author: Gabriel Dos Reis ++ Date Created: November 10, 2007 ++ Date Last Modified: September 21, 2008 ++ Description: This domain represents the unnamed category defined ++ by a list of exported signatures CategoryAst(): Public == Private where Public == SpadSyntaxCategory with kind: % -> Symbol ++ kind(c) returns the kind of unnamed category, either ++ 'domain' or 'package'. body: % -> List SpadAst ++ body(c) returns the list of exports in category syntax `c'. Private == add Rep == List SpadAst kind x == (second rep x) : Symbol body x == rest rest rep x coerce(x: %): OutputForm == elt('CategoryAst::OutputForm, ['kind::OutputForm = kind(x)::OutputForm, 'body::OutputForm = body(x)::OutputForm])$OutputForm @ \subsection{The WhereAst domain} <>= SpadAst(): SpadAstExports )abbrev domain WHEREAST WhereAst ++ Author: Gabriel Dos Reis ++ Date Created: November 10, 2007 ++ Date Last Modified: September 21, 2008 ++ Description: This domain represents the syntax of a `where' expression. WhereAst(): Public == Private where Public == SpadSyntaxCategory with mainExpression: % -> SpadAst ++ mainExpression(e) returns the main expression of the ++ `where' expression `e'. qualifier: % -> SpadAst ++ qualifier(e) returns the qualifier of the expression `e'. Private == add Rep == List SpadAst mainExpression x == second rep x qualifier x == third rep x coerce(x: %): OutputForm == elt('WhereAst::OutputForm, ['mainExpression::OutputForm = mainExpression(x)::OutputForm, 'qualifier::OutputForm = qualifier(x)::OutputForm])$OutputForm @ \subsection{The CommaAst domain} <>= SpadAst(): SpadAstExports )abbrev domain COMMAAST CommaAst ++ Author: Gabriel Dos Reis ++ Date Created: November 10, 2007 ++ Date Last Modified: September 21, 2008 ++ Description: This domain represents the syntax of a comma-separated ++ list of expressions. CommaAst(): Public == Private where Public == SpadSyntaxCategory with body: % -> List SpadAst ++ body(e) returns the list of expressions making up `e'. Private == add Rep == List SpadAst body x == rest rep x coerce(x: %): OutputForm == elt('CommaAst::OutputForm, ['body::OutputForm = body(x)::OutputForm])$OutputForm @ \subsection{The QuasiquoteAst domain} <>= SpadAst(): SpadAstExports )abbrev domain QQUTAST QuasiquoteAst ++ Author: Gabriel Dos Reis ++ Date Created: November 10, 2007 ++ Date Last Modified: September 21, 2008 ++ Description: This domain represents the syntax of a quasiquote ++ expression. QuasiquoteAst(): Public == Private where Public == SpadSyntaxCategory with expression: % -> SpadAst ++ expression(e) returns the syntax for the expression being quoted. Private == add Rep == List SpadAst expression x == second rep x coerce(x: %): OutputForm == elt('QuasiquoteAst::OutputForm, ['expression::OutputForm = expression(x)::OutputForm])$OutputForm @ \subsection{The DefinitionAst domain} <>= SpadAst(): SpadAstExports )abbrev domain DEFAST DefinitionAst ++ Author: Gabriel Dos Reis ++ Date Created: November 10, 2007 ++ Date Last Modified: September 21, 2008 ++ Description: This domain represents the syntax of a definition. DefinitionAst(): Public == Private where Public == SpadSyntaxCategory with head: % -> HeadAst ++ head(d) returns the head of the definition `d'. This is a ++ list of identifiers starting with the name of the operation ++ followed by the name of the parameters, if any. signature: % -> Signature ++ signature(d) returns the signature of the operation being ++ defined. Note that this list may be partial in that it ++ contains only the types actually specified in the definition. body: % -> SpadAst ++ body(d) returns the right hand side of the definition `d'. Private == add Rep == List SpadAst head x == (second rep x) : HeadAst signature x == (third rep x) : Signature body x == last rep x coerce(x: %): OutputForm == elt('DefinitionAst::OutputForm, ['head::OutputForm = head(x)::OutputForm, 'signature::OutputForm = signature(x)::OutputForm, 'body::OutputForm = body(x)::OutputForm])$OutputForm @ \subsection{The MacroAst domain} <>= SpadAst(): SpadAstExports )abbrev domain MACROAST MacroAst ++ Author: Gabriel Dos Reis ++ Date Created: November 10, 2007 ++ Date Last Modified: September 21, 2008 ++ Description: This domain represents the syntax of a macro definition. MacroAst(): Public == Private where Public == SpadSyntaxCategory with head: % -> HeadAst ++ head(m) returns the head of the macro definition `m'. This is a ++ list of identifiers starting with the name of the macro ++ followed by the name of the parameters, if any. body: % -> SpadAst ++ body(m) returns the right hand side of the definition `m'. Private == add Rep == List SpadAst head x == (second rep x) : HeadAst body x == last rep x coerce(x: %): OutputForm == elt('MacroAst::OutputForm, ['head::OutputForm = head(x)::OutputForm, 'body::OutputForm = body(x)::OutputForm])$OutputForm @ \subsection{The SpadAst domain} <>= )abbrev domain SPADAST SpadAst ++ Author: Gabriel Dos Reis ++ Date Created: September 21, 2008 ++ Date Last Modified: September 21, 2008 ++ Description: This domain represents a kind of base domain ++ for Spad syntax domain. It merely exists as a kind of ++ of abstract base in object-oriented programming language. ++ However, this is not an abstract class. SpadAst(): SpadAstExports() == add isAst(x: %, tag: Symbol): Boolean == (op := getOperator(x::Syntax)) case Symbol and op = tag x case ImportAst == isAst(x,'import) autoCoerce(x: %): ImportAst == x : ImportAst x case DefinitionAst == isAst(x,'DEF) autoCoerce(x: %): DefinitionAst == x : DefinitionAst x case MacroAst == isAst(x,'MDEF) autoCoerce(x: %): MacroAst == x : MacroAst x case WhereAst == isAst(x,'where) autoCoerce(x: %): WhereAst == x : WhereAst x case CategoryAst == isAst(x,'CATEGORY) autoCoerce(x: %): CategoryAst == x : CategoryAst x case CapsuleAst == isAst(x,'CAPSULE) autoCoerce(x: %): CapsuleAst == x : CapsuleAst x case SignatureAst == isAst(x,'SIGNATURE) autoCoerce(x: %): SignatureAst == x : SignatureAst x case AttributeAst == isAst(x,'ATTRIBUTE) autoCoerce(x: %): AttributeAst == x : AttributeAst x case MappingAst == isAst(x,'Mapping) autoCoerce(x: %): MappingAst == x : MappingAst x case IfAst == isAst(x,'IF) autoCoerce(x: %): IfAst == x : IfAst x case RepeatAst == isAst(x,'REPEAT) autoCoerce(x: %): RepeatAst == x : RepeatAst x case WhileAst == isAst(x,'WHILE) autoCoerce(x: %): WhileAst == x : WhileAst x case InAst == isAst(x,'IN) autoCoerce(x: %): InAst == x : InAst x case CollectAst == isAst(x,'COLLECT) autoCoerce(x: %): CollectAst == x : CollectAst x case ConstructAst == isAst(x,'construct) autoCoerce(x: %): ConstructAst == x : ConstructAst x case ExitAst == isAst(x,'exit) autoCoerce(x: %): ExitAst == x : ExitAst x case ReturnAst == isAst(x,'RETURN) autoCoerce(x: %): ReturnAst == x : ReturnAst x case CoerceAst == isAst(x,'_:_:) autoCoerce(x: %): CoerceAst == x : CoerceAst x case PretendAst == isAst(x,'pretend) autoCoerce(x: %): PretendAst == x : PretendAst x case RestrictAst == isAst(x,'_@) autoCoerce(x: %): RestrictAst == x : RestrictAst x case SegmentAst == isAst(x,'SEGMENT) autoCoerce(x: %): SegmentAst == x : SegmentAst x case SequenceAst == isAst(x,'SEQ) autoCoerce(x: %): SequenceAst == x : SequenceAst x case LetAst == isAst(x,'_%LET) autoCoerce(x: %): LetAst == x : LetAst x case SuchThatAst == isAst(x,'_|) autoCoerce(x: %): SuchThatAst == x : SuchThatAst x case ColonAst == isAst(x,'_:) autoCoerce(x: %): ColonAst == x : ColonAst x case CaseAst == isAst(x,'_case) autoCoerce(x: %): CaseAst == x : CaseAst x case HasAst == isAst(x,'_has) autoCoerce(x: %): HasAst == x : HasAst x case IsAst == isAst(x,'_is) autoCoerce(x: %): IsAst == x : IsAst x case Identifier == (x::Syntax) case Symbol autoCoerce(x: %): Identifier == x:Identifier x case String == (x::Syntax) case String autoCoerce(x: %): String == x : String x case Integer == (x::Syntax) case Integer autoCoerce(x: %): Integer == x : Integer coerce(x: %): OutputForm == x' := x : Syntax compound? x' and ((op := getOperator x') case Symbol) => op = 'IF => x:IfAst::OutputForm op = 'REPEAT => x:RepeatAst::OutputForm op = 'WHILE => x:WhileAst::OutputForm op = 'IN => x:InAst::OutputForm op = 'COLLECT => x:CollectAst::OutputForm op = 'construct => x:ConstructAst::OutputForm op = 'exit => x:ExitAst::OutputForm op = 'return => x:ReturnAst::OutputForm op = 'SEQ => x:SequenceAst::OutputForm op = '_%LET => x:LetAst::OutputForm op = 'pretend => x:PretendAst::OutputForm op = '_:_: => x:CoerceAst::OutputForm op = '_@ => x:RestrictAst::OutputForm op = 'SEGMENT => x:SegmentAst::OutputForm op = '_| => x:SuchThatAst::OutputForm op = '_: => x:ColonAst::OutputForm op = 'add => x:AddAst::OutputForm op = '_case => x:CaseAst::OutputForm op = '_has => x:CaseAst::OutputForm op = '_is => x:CaseAst::OutputForm op = 'where => x:WhereAst::OutputForm op = '_%Comma => x:CommaAst::OutputForm op = 'Mapping => x:MappingAst::OutputForm op = 'DEF => x:DefinitionAst::OutputForm op = 'MDEF => x:MacroAst::OutputForm op = 'SIGNATURE => x:SignatureAst::OutputForm op = 'ATTRIBUTE => x:AttributeAst::OutputForm op = 'CATEGORY => x:CategoryAst::OutputForm op = 'CAPSULE => x:CapsuleAst::OutputForm op = 'import => x:ImportAst::OutputForm x'::OutputForm x'::OutputForm @ \section{License} <>= --Copyright (C) 2007-2008, 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. @ <<*>>= <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> @ \end{document}