diff options
Diffstat (limited to 'src/main/scala/scalam/m/ast/expressions.scala')
-rw-r--r-- | src/main/scala/scalam/m/ast/expressions.scala | 70 |
1 files changed, 69 insertions, 1 deletions
diff --git a/src/main/scala/scalam/m/ast/expressions.scala b/src/main/scala/scalam/m/ast/expressions.scala index db99ae6..81e048e 100644 --- a/src/main/scala/scalam/m/ast/expressions.scala +++ b/src/main/scala/scalam/m/ast/expressions.scala @@ -1,6 +1,10 @@ package scalam.m.ast -trait Expression extends Mable with Root{ +/** + * Represents a matlab expression. + * @define construct expression + */ +trait Expression extends Mable with Root { def m: String = this match { case IntLiteral(x) => x.toString case DoubleLiteral(x) => x.toString @@ -18,13 +22,77 @@ trait Expression extends Mable with Root{ } } +/** + * A matlab integer literal. + * @define construct integer literal + */ case class IntLiteral(x: Int) extends Expression + +/** + * A matlab double literal. + * @define construct double literal + */ case class DoubleLiteral(x: Double) extends Expression + +/** + * A matlab string literal. + * @define construct string literal + */ case class StringLiteral(x: String) extends Expression + +/** + * The matlab slice literal (:). + * @define construct slice literal + */ case object SliceLiteral extends Expression + +/** + * A matlab array or single-line matrix literal. + * @param elements elements of the array + * + * @define construct array literal + */ case class ArrayLiteral(elements: Expression*) extends Expression + +/** + * A matlab matrix literal. + * @param rows rows of the matrix + * + * @define construct matrix literal + */ case class MatrixLiteral(rows: Expression*) extends Expression + +/** + * A matlab variable access. + * @param id identifier ("variable name") of the variable + * + * @define construct variable access + */ case class Variable(id: Identifier) extends Expression + +/** + * A matlab matrix access by index. + * @param id identifier of the variable to index + * @param indices indices + * + * @define construct matrix access by index + */ case class IndexMatrix(id: Identifier, indices: Expression*) extends Expression + +/** + * A matlab structure access by index. + * @param id identifier of the variable to index + * @param indices indices + * + * @define construct structure access by index + */ case class IndexStructure(id: Identifier, indices: Expression*) extends Expression + +/** + * A matlab function call. + * @param function identifier of the function + * @param params parameters to pass to function call + * + * @define construct function call + */ case class Function(function: Identifier, params: Expression*) extends Expression
\ No newline at end of file |