Skip to content

Instantly share code, notes, and snippets.

@tralamazza
Created September 25, 2018 09:59
Show Gist options
  • Save tralamazza/2eca8a84f57831343600d7ef22b99c7c to your computer and use it in GitHub Desktop.
Save tralamazza/2eca8a84f57831343600d7ef22b99c7c to your computer and use it in GitHub Desktop.
FSM := source? start_state class_name header_file? include_file*
package_name* import* declare* access* map+
source := '%{' raw_code '%}'
start_state := '%start' word
class_name := '%class' word
header_file := '%header' raw_code_line
include_file := '%include' raw_code_line
package_name := '%package' word
import := '%import' raw_code_line
declare := '%declare' raw_code_line
access := '%access' raw_code_line
map := '%map' word '%%' states '%%'
states := word entry? exit? '{' transitions* '}'
entry := 'Entry {' actions* '}'
exit := 'Exit {' actions '}'
transitions := word transition_args? guard? next_state '{' actions '}'
transition_args := '(' parameters ')'
parameters := parameter |
parameter ',' parameters
parameter := word ':' raw_code
guard := '[' raw_code ']'
next_state := word |
'nil' |
push_transition |
pop_transition
push_transition := word '/' 'push(' word ')' |
'nil/push(' word ')' |
'push(' word ')'
pop_transition := 'pop' |
'pop(' word? ')' |
'pop(' word ',' pop_arguments* ')'
pop_arguments := raw_code |
raw_code ',' pop_arguments
actions := dotnet_assignment |
action |
action actions
dotnet_assignment := word '=' raw_code ';'
action := word '(' arguments* ');'
arguments := raw_code |
raw_code ',' arguments
word := [A-Za-z][A-Za-z0-9_.]* |
_[A-Za-z][A-Za-z0-9_.]*
// Reads in code verbatim until end-of-line is reached.
raw_code_line := .* '\n\r\f'
// Read in code verbatim.
raw_code := .*
// Both the // and /* */ comment types are supported.
// Note: SMC honors nested /* */ comments.
comment1 := '//' .* '\n\r\f'
comment2 := '/*' .* '*/'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment