blob: 6778e744c9c765a78b91320d448fb1869500a9fb (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
package scalam.m.ast
/**
* A matlab identifier.
* @name name of variable (this must be a valid matlab identifier string)
*
* @define construct identifier
*/
case class Identifier(name: String) extends Mable {
def m = name
def toValid = {
val word = name.filter(c => c.isLetterOrDigit || c == '_')
val id = word.headOption match {
case None => "x"
case Some(c) => if (!c.isLetter) 'x' + word else word
}
Identifier(id)
}
}
|