-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtbt.pest
71 lines (65 loc) · 2.37 KB
/
tbt.pest
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// SPDX-FileCopyrightText: 2023 German Aerospace Center (DLR)
// SPDX-License-Identifier: Apache-2.0
Specification = { COMMENT* ~ Constants ~ TBT }
// Constants
Constants = { Constant* }
Constant = { Word ~ "=" ~ Float ~ ";"}
// TBT operators
TBT = _{ Leaf | Fallback | Parallel | Sequence | Timeout | Kleene }
TBTList = { "(" ~(TBT ~("," ~TBT)*)? ~")"}
Leaf = { ("'"~ Word ~"'")? ~ STL }
Fallback = { "?" ~ TBTList }
Parallel = { "=>" ~ Number ~ TBTList}
Sequence = { "->" ~ TBTList}
Timeout = { "@" ~ Number ~ TBT }
Kleene = { "*" ~ Number ~ TBT }
// STL operators
STL = { STL_element ~ (STL_OP_BINARY ~ STL_element)* }
STL_element = { Atomic | Brackets | STL_unary_op }
STL_unary_op = { STL_OP_UNARY ~ STL }
STL_OP_BINARY = _{ Conjunction | Disjunction | Until | Until_interval }
STL_OP_UNARY = _{ STLNeg | Next | Eventually | Globally | Eventually_interval | Globally_interval }
Atomic = { Word ~ Arguments ~ "["~ Function ~"]" }
Arguments = { "(" ~(Word ~("," ~Word)*)? ~")" }
Brackets = { "(" ~ STL ~ ")" }
Conjunction = { "&" }
Disjunction = { "|" }
Until = { "U" }
Until_interval = { "IU("~ Number ~ ".." ~ Number ~ ")" }
STLNeg = { "!" | "¬" }
Next = { "O" }
Eventually = {"<>" }
Globally = { "[]" }
Eventually_interval = {"<" ~Number ~ ".." ~ Number ~">" }
Globally_interval = {"[" ~Number ~ ".." ~ Number ~"]" }
// Atomic propositions
Function = { Function_element ~ (Operation ~ Function_element)* }
Function_element = { Word | Float | FnBrackets | FunctionCall}
FunctionCall = { UFn~"("~Function~")" | BFn~"("~ Function ~ "," ~ Function ~")"}
FnBrackets = { "(" ~ Function ~ ")" }
Operation = _{ Add | Subtract | Power | Multiply | Divide | Mod }
Add = { "+" }
Subtract = { "-" }
Power = { "^" }
Multiply = { "*" }
Divide = { "/" }
Mod = { "%" }
UFn = { Root | Abs | RadToDeg | DegToRad | Cos | Sin}
Root = { "!sqrt" }
Abs = { "!abs" }
RadToDeg = { "!radToDeg" }
DegToRad = { "!degToRad" }
Cos = { "!cos" }
Sin = { "!sin" }
BFn = { Min | Max }
Min = { "!min" }
Max = { "!max" }
// Symbols
Letter = _{ 'a'..'z' | 'A'..'Z'}
Digit = _{'0'..'9'}
Under = _{ "_" }
Float = { ("-")? ~ Number ~ ("." ~ Number)? }
Word = { Letter~(Letter | Digit | Under)* }
Number = { '0'..'9'+ }
WHITESPACE = _{ " " | "\t" | "\r" | "\n"}
COMMENT = _{ ("/*" ~ (!"*/" ~ ANY)* ~ "*/") | ("//" ~(!("\n")~ANY)*~ "\n"? ) }