Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
189 lines (181 sloc) 5.02 KB
{
meta: {
language: "Calculator"
description: "A simple expression evaluator language (for neos testing purposes)"
language.file.extension: [ ".calc" ]
copyright: "Copyright (C) 2019 Leigh Johnston"
version: "1.0.0"
}
libraries: [
neos.core
neos.math.universal
]
expect: statement
expect: whitespace
tokens: {
statement: done
whitespace: done
}
character: {
is: string.utf8.character
}
whitespace: {
is: language.whitespace
tokens: {
' ': done
'\n': done
'\r': done
'\t': done
default: error
}
}
statement: {
is: language.statement
expect: end
expect: expression
tokens: {
expression: {
expect: end
end: done
}
end: done
whitespace: ignore
}
end: {
tokens: {
';': done
whitespace: ignore
}
}
}
expression: {
is: math.expression
expect: term
tokens: {
term: {
expect: none
'+': math.operator.add
'-': math.operator.subtract
math.operator.addition: {
expect: term
}
whitespace: ignore
default: next
}
}
term: {
expect: term2
tokens: {
term2: {
expect: none
'*': math.operator.multiply
'/': math.operator.divide
math.operator.multiplication: {
expect: term2
}
whitespace: ignore
default: next
}
}
}
term2: {
expect: primary
tokens: {
primary: {
expect: none
'**': math.operator.power
'^': math.operator.power
math.operator: {
expect: primary
}
whitespace: ignore
default: next
}
}
}
primary: {
is: math.expression.operand
tokens: {
math.universal.number.digit: universal_number
universal_number: done
'-': math.operator.negate
math.operator.negate: {
expect: primary
primary: done
whitespace: ignore
}
'(': {
expect: expression
expression: {
expect: ')'
')': done
whitespace: ignore
}
whitespace: ignore
}
whitespace: ignore
}
}
}
universal_number: {
is: math.universal.number
tokens: {
digit: {
digit: continue
'.': point
point: {
'.': error
digit: continue
'e': exponent
'E': exponent
default: next
}
default: next
}
'#': base
base: {
hexdigit: continue
'.': point
point: {
'.': error
hexdigit: continue
'#': {
'e': exponent
'E': exponent
default: next
}
default: next
}
'#': {
'e': exponent
'E': exponent
default: next
}
}
exponent: {
expect: '+'
expect: '-'
'+': exponent.positive
exponent.positive: {
expect: digit
digit: exponent.digit
exponent.digit: {
digit: exponent.digit
exponent.digit: continue
default: next
}
}
'-': exponent.negative
exponent.negative: {
expect: digit
digit: exponent.digit
exponent.digit: {
digit: exponent.digit
exponent.digit: continue
default: next
}
}
}
}
}
}
You can’t perform that action at this time.