if (!lhsTree.isAssignable)
throw new InvalidInputException("Non-assignable expression on LHS of assignment.")
- else
- new Assignment(lhsTree, rhsTree)
+ else (lhsTree, rhsTree) match {
+ case (lhs: ScalarExpression, rhs: ScalarExpression) => new Assignment(lhs, rhs)
+ case _ => throw new InvalidInputException("Assignment must be of scalar type.")
+ }
}
private def buildIndexedOperand(term: parser.IndexedIdentifier) : Expression = {
import ofc.expression.{Dictionary,Assignment}
trait Generator {
- def acceptInput(dictionary: Dictionary, expression: Assignment, targetSpecific : Seq[TargetAssignment]) : Unit
+ def acceptInput(dictionary: Dictionary, expression: Assignment, targetSpecific : Seq[TargetAssignment])
}
import ofc.generators.onetep._
import ofc.parser
-import ofc.expression.{Assignment,Dictionary}
+import ofc.expression.{Assignment,Expression,Dictionary}
class Onetep extends Generator {
- def acceptInput(dictionary: Dictionary, assignment: Assignment, targetSpecific : Seq[parser.TargetAssignment]) = {
+ def acceptInput(dictionary: Dictionary, assignment: Assignment, targetSpecific : Seq[parser.TargetAssignment]) {
println(assignment)
+ if (matchLHS(assignment.lhs))
+ println("ha!")
}
+
+ private def matchLHS(expression: Expression) : Boolean = {
+ import ofc.expression._
+
+ expression match {
+ case ScalarIndexingOperation(_: Matrix, List(bra, ket)) => true
+ case _ => false
+ }
+ }
+
/*
def buildMatrix(id: parser.Identifier, call : Option[parser.FunctionCall]) {