commit 1c1efc0fe6d306556c1f9fee1444fbf617c7a120 Author: Simon From Jakobsen Date: Thu Jul 18 12:44:39 2024 +0000 init, benchmark, vim syntax diff --git a/benchmark.stela b/benchmark.stela new file mode 100644 index 0000000..38fd2ba --- /dev/null +++ b/benchmark.stela @@ -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; +} + diff --git a/stela.vim b/stela.vim new file mode 100644 index 0000000..20b8351 --- /dev/null +++ b/stela.vim @@ -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" +