init, benchmark, vim syntax
This commit is contained in:
commit
1c1efc0fe6
101
benchmark.stela
Normal file
101
benchmark.stela
Normal file
@ -0,0 +1,101 @@
|
||||
|
||||
class HouseSettings {
|
||||
public attribute Settings: [int; 10];
|
||||
|
||||
operation get(id: int) -> int { return 0; }
|
||||
operation set(id: int, value: int) {}
|
||||
}
|
||||
|
||||
enumeration DoorState {
|
||||
Closed,
|
||||
Open,
|
||||
}
|
||||
|
||||
derivable class GenericDoorControl {
|
||||
attribute Runtime: int;
|
||||
attribute SensorState: DoorState;
|
||||
|
||||
operation Close() {}
|
||||
operation Open() {}
|
||||
|
||||
operation SetRuntime(time: int) {}
|
||||
operation State() -> DoorState { return DoorState::Closed; }
|
||||
}
|
||||
|
||||
class DoorControl derives GenericDoorControl {
|
||||
associate itsHouseSettings: HouseSettings;
|
||||
|
||||
attribute State: DoorState;
|
||||
attribute locked: bool;
|
||||
|
||||
operation SetState(state: DoorState) {}
|
||||
operation GetState() -> DoorState { return DoorState::Closed; }
|
||||
|
||||
operation Lock() { this.locked = true; }
|
||||
operation Unlock() { this.locked = false; }
|
||||
|
||||
state_machine {
|
||||
entry {
|
||||
transition DoorControl;
|
||||
}
|
||||
DoorControl {
|
||||
state_machine "Door operation" {
|
||||
initial {
|
||||
transition Closing {
|
||||
SetState(DoorState::Closed);
|
||||
}
|
||||
}
|
||||
Closing {
|
||||
entry {
|
||||
Lock();
|
||||
}
|
||||
exit {
|
||||
Unlock();
|
||||
}
|
||||
transition Opening {
|
||||
SetState(DoorState::Open);
|
||||
};
|
||||
}
|
||||
Opening {
|
||||
state_machine {
|
||||
initial {
|
||||
transition Unlocked;
|
||||
}
|
||||
Unlocked {
|
||||
ThreadSleepSeconds(1);
|
||||
if this.locked
|
||||
transition Unlocked
|
||||
else
|
||||
transition final {
|
||||
SetState(DoorState::Open);
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
state_machine "Check sensor" {
|
||||
initial {
|
||||
transition Check;
|
||||
}
|
||||
Check {
|
||||
ThreadSleepSeconds(1);
|
||||
transition Check;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class WinterGardenControl {
|
||||
associate itsHouseSettings: HouseSettings;
|
||||
associate itsDoorControl: &[HouseSettings];
|
||||
|
||||
public attribute NofDoors: int;
|
||||
|
||||
operation SetState(amount: int) {}
|
||||
operation SetDoors(amount: int) {}
|
||||
|
||||
operation GetState() -> DoorState;
|
||||
operation GetState(door: int) -> DoorState;
|
||||
}
|
||||
|
50
stela.vim
Normal file
50
stela.vim
Normal file
@ -0,0 +1,50 @@
|
||||
" Vim syntax file
|
||||
" Language: STate machine Event LAnguage
|
||||
" Maintainer: Simon
|
||||
" Latest Revision: 17 July 2024
|
||||
|
||||
if exists("b:current_syntax")
|
||||
finish
|
||||
endif
|
||||
|
||||
syn keyword Keyword return if else
|
||||
syn keyword Keyword enumeration derivable derives class public private
|
||||
syn keyword Keyword operation attribute associate state_machine
|
||||
syn keyword Keyword transition
|
||||
syn keyword Special initial final entry exit
|
||||
syn keyword Type void int float bool
|
||||
syn keyword Boolean true false
|
||||
syn keyword Identifier this
|
||||
|
||||
syn match Operator '-'
|
||||
syn match Operator '->'
|
||||
syn match Operator ':'
|
||||
syn match Operator '::'
|
||||
syn match Operator '='
|
||||
syn match Operator '+'
|
||||
syn match Operator '\*'
|
||||
syn match Operator ';'
|
||||
syn match Operator '\.'
|
||||
syn match Operator ','
|
||||
|
||||
syn match Number '\d\+'
|
||||
syn match Number '[-+]\d\+'
|
||||
|
||||
syn match Float '[-+]\d\+\.\d*'
|
||||
syn match Float '[-+]\=\d[[:digit:]]*[eE][\-+]\=\d\+'
|
||||
syn match Float '\d[[:digit:]]*[eE][\-+]\=\d\+'
|
||||
syn match Float '[-+]\=\d[[:digit:]]*\.\d*[eE][\-+]\=\d\+'
|
||||
syn match Float '\d[[:digit:]]*\.\d*[eE][\-+]\=\d\+'
|
||||
|
||||
syn region String start=+"+ skip=+\\"+ end=+"+
|
||||
|
||||
syn keyword Todo contained TODO FIXME XXX NOTE
|
||||
syn match Comment "#.*$" contains=Todo
|
||||
syn match Comment "//.*$" contains=Todo
|
||||
|
||||
syn match Function '[a-zA-Z_]\w*\ze('
|
||||
|
||||
syn region stelaBlock start="{" end="}" transparent fold
|
||||
|
||||
let b:current_syntax = "stela"
|
||||
|
Loading…
Reference in New Issue
Block a user