Skip to content

Commit

Permalink
Added support for new terse operator syntax. Also fixed a problem wit…
Browse files Browse the repository at this point in the history
…h the help() operator's case definition.
  • Loading branch information
sprowell committed May 16, 2012
1 parent 610cb35 commit cff3115
Show file tree
Hide file tree
Showing 4 changed files with 171 additions and 75 deletions.
2 changes: 1 addition & 1 deletion Elision/src/ornl/elision/core/BuiltinOperators.scala
Expand Up @@ -148,7 +148,7 @@ of each one (if given). Operators whose name begins with an underscore
are suppressed in this list."""
})

def({ operator #name=help #cases %()->_help_all(), %($r:OPREF)->_help_op($r)
def({ operator #name=help #cases %($r:OPREF)->_help_op($r), _help_all:OPREF
#description="Get general help or help on an operator."
#detail=
"""With no argument, list all operators. If provided with an operator
Expand Down
31 changes: 16 additions & 15 deletions Elision/src/ornl/elision/core/Operator.scala
Expand Up @@ -648,6 +648,19 @@ protected class SymbolicOperator protected (sfh: SpecialFormHolder,
}
}
} // Loop over atoms.

// Handle actual operator application.
def handleApply(binds: Bindings): BasicAtom = {
// Re-package the arguments with the correct properties.
val newargs = AtomSeq(params.props, newseq)
// See if we are bypassing the native handler.
if (!bypass) {
// Run any native handler.
if (handler.isDefined) return handler.get(this, newargs, binds)
}
// No native handler.
return OpApply(OperatorRef(this), newargs, binds)
}

// There are special cases to handle here. First, if the argument list
// is empty, but there is an identity, return it.
Expand All @@ -658,8 +671,9 @@ protected class SymbolicOperator protected (sfh: SpecialFormHolder,
return ident
case None =>
// No identity. We're done.
return OpApply(OperatorRef(this), AtomSeq(params.props, newseq),
Bindings())
return handleApply(Bindings())
// return OpApply(OperatorRef(this), AtomSeq(params.props, newseq),
// Bindings())
}
}

Expand Down Expand Up @@ -709,19 +723,6 @@ protected class SymbolicOperator protected (sfh: SpecialFormHolder,
params.atoms
}

// Handle actual operator application.
def handleApply(binds: Bindings): BasicAtom = {
// Re-package the arguments with the correct properties.
val newargs = AtomSeq(params.props, newseq)
// See if we are bypassing the native handler.
if (!bypass) {
// Run any native handler.
if (handler.isDefined) return handler.get(this, newargs, binds)
}
// No native handler.
return OpApply(OperatorRef(this), newargs, binds)
}

// We've run out of special cases to handle. Now just try to match the
// arguments against the parameters.
SequenceMatcher.tryMatch(newparams, newseq) match {
Expand Down

0 comments on commit cff3115

Please sign in to comment.