amble_engine 0.67.0

Data-first interactive fiction engine and REPL for worlds authored in the Amble DSL.
Documentation
COMMENT    = _{ "#" ~ (!NEWLINE ~ ANY)* }
WHITESPACE = _{ " " | "\t" | NEWLINE | COMMENT }
NEWLINE    = _{ "\n" | "\r\n" }

repl_input = { SOI ~ command ~ EOI }

ident     = @{ ASCII_ALPHA ~ ("_" | "-" | ASCII_ALPHANUMERIC)* }
save_name = @{ ASCII_ALPHANUMERIC ~ ("_" | "-" | "." | ASCII_ALPHANUMERIC)* }
word      = @{ (ASCII_ALPHANUMERIC | "-" | "_" | "'")+ }
phrase    = @{ word ~ (WHITESPACE+ ~ !prep ~ !manner_prep ~ word)* }

command = _{ list_saves | verb_do_io | verb_obj | simple }

artic       = _{ "the" | "an" | "a" }
prep        = _{ "at" | "into" | "on" | "off" | "in" | "to" | "from" | "down" }
manner_prep = _{ "with" | "using" }
dir_prep    = _{ "in to" | "to" | "at" | "into" | "on" | "in" | "through" }

// synonyms
take_verb   = _{ "take" | "get" | "grab" | "snag" | "steal" | "pick" ~ "up" | "remove" }
start_verb  = _{ "start" | "trigger" | "activate" | "fire" | "turn" ~ "on" | "switch" ~ "on" }
stop_verb   = _{ "stop" | "disable" | "halt" | "kill" | "turn" ~ "off" | "switch" ~ "off" }
switch_verb = _{ "turn" | "switch" | "flip" }
// " " after go is intentional to keep from matching "goals"
go_verb = _{ ("go " ~ !"back") | "walk" | "move" | "climb" | "jog" | "run" }

// simple commands - no objects
simple     = _{ inventory | help | goals | look | quit | go_back | vm_clear | vm_verbose | vm_brief | list_saves }
inventory  =  { "inventory" | "inv" }
help       =  { "help" | "?" }
goals      =  { "goals" | "goal" | "what" ~ ("next" | "now") ~ ("?")* }
look       =  { "look" }
quit       =  { "quit" }
go_back    =  { "back" | "go" ~ "back" }
vm_clear   =  { "clear" }
vm_verbose =  { "verbose" }
vm_brief   =  { "brief" }
list_saves =  { "saves" | ("list" ~ "saves") }

// verb -> single object commands
verb_obj = _{
    look_at
  | load
  | save
  | take
  | drop
  | talk_to
  | turn_on
  | turn_off
  | theme
  | close
  | lock
  | unlock
  | move_to
  | open
  | read
  | eat
  | drink
  | inhale
  | touch
}
look_at  =  { "look" ~ prep? ~ artic? ~ phrase }
load     =  { ("load" | "reload") ~ save_name }
save     =  { "save" ~ save_name }
take     =  { take_verb ~ artic? ~ phrase }
drop     =  { (("drop" | "leave") ~ artic? ~ phrase) | ("put" ~ artic? ~ phrase ~ "down") }
talk_to  =  { ("talk" | "speak") ~ ("to" | "with") ~ artic? ~ phrase }
turn_on  =  { (start_verb ~ artic? ~ phrase) | (switch_verb ~ artic? ~ phrase ~ "on") }
turn_off =  { (stop_verb ~ artic? ~ phrase) | (switch_verb ~ artic? ~ phrase ~ "off") }
theme    =  { "theme" ~ ident }
open     =  { "open" ~ artic? ~ phrase }
close    =  { ("close" | "shut" | "slam") ~ artic? ~ phrase }
lock     =  { "lock" ~ artic? ~ phrase }
unlock   =  { "unlock" ~ artic? ~ phrase }
move_to  =  { go_verb ~ dir_prep? ~ artic? ~ phrase }
read     =  { ("read" | "examine" | "exam" | "ex" | "inspect") ~ artic? ~ phrase }
eat      =  { ("eat" | "scarf" | "devour" | (("snack" | "munch") ~ "on")) ~ artic? ~ phrase }
drink    =  { ("drink" | "swallow" | "chug") ~ artic? ~ phrase }
inhale   =  { ("inhale" | "sniff" | "breathe") ~ artic? ~ phrase }
touch    =  { ("touch" | "press" | "push") ~ artic? ~ phrase }

// verb -> direct and indirect object commands
verb_do_io  = _{ vtwt_cmd | take_from | put_in | give_to_npc }
give_to_npc =  { ("give" | "hand" | "toss" | "pass") ~ phrase ~ "to" ~ phrase }
put_in      =  { ("place" | "put" | "insert" | "drop") ~ artic? ~ phrase ~ prep ~ artic? ~ phrase }
take_from   =  { take_verb ~ artic? ~ phrase ~ ("from" | "out" ~ "of") ~ artic? ~ phrase }

// <Verb> Target With Tool form commands.
vtwt_cmd       = _{
    clean_twt
  | cover_twt
  | cut_twt
  | handle_twt
  | move_twt
  | open_twt
  | repair_twt
  | sharpen_twt
  | turn_twt
  | unlock_twt
  | extinguish_twt
  | burn_twt
  | break_twt
  | attach_twt
  | detach_twt
}
attach_twt     =  { ii_attach_vb ~ artic? ~ phrase ~ ("to" | "with" | "and") ~ artic? ~ phrase }
detach_twt     =  { ii_detach_vb ~ artic? ~ phrase ~ "from" ~ artic? ~ phrase }
break_twt      =  { ii_break_vb ~ artic? ~ phrase ~ ("with" | "using") ~ artic? ~ phrase }
burn_twt       =  { ii_burn_vb ~ artic? ~ phrase ~ ("with" | "using") ~ artic? ~ phrase }
extinguish_twt =  { ii_extinguish_vb ~ artic? ~ phrase ~ ("with" | "using") ~ artic? ~ phrase }
clean_twt      =  { ii_clean_vb ~ artic? ~ phrase ~ ("with" | "using") ~ artic? ~ phrase }
cover_twt      =  { ii_cover_vb ~ artic? ~ phrase ~ ("with" | "using") ~ artic? ~ phrase }
cut_twt        =  { ii_cut_vb ~ artic? ~ phrase ~ ("with" | "using") ~ artic? ~ phrase }
handle_twt     =  { ii_handle_vb ~ artic? ~ phrase ~ ("with" | "using") ~ artic? ~ phrase }
move_twt       =  { ii_move_vb ~ artic? ~ phrase ~ ("with" | "using") ~ artic? ~ phrase }
open_twt       =  { ii_open_vb ~ artic? ~ phrase ~ ("with" | "using") ~ artic? ~ phrase }
repair_twt     =  { ii_repair_vb ~ artic? ~ phrase ~ ("with" | "using") ~ artic? ~ phrase }
sharpen_twt    =  { ii_sharpen_vb ~ artic? ~ phrase ~ ("with" | "using") ~ artic? ~ phrase }
turn_twt       =  { ii_turn_vb ~ artic? ~ phrase ~ ("with" | "using") ~ artic? ~ phrase }
unlock_twt     =  { ii_unlock_vb ~ artic? ~ phrase ~ ("with" | "using") ~ artic? ~ phrase }

// item interaction verbs for (interaction)-tool-with-target commands, e.g. "sharpen sword with stone"
ii_attach_vb     = _{ "attach" | "join" | "connect" }
ii_detach_vb     = _{ "detach" | "separate" | "disconnect" }
ii_break_vb      = _{ "break" | "smash" | "crack" | "shatter" | "crush" }
ii_burn_vb       = _{ "burn" | "ignite" | "melt" | "light" }
ii_extinguish_vb = _{ "extinguish" | "douse" | "quench" | "spray" }
ii_clean_vb      = _{ "clean" | "wipe" | "scrub" | "wash" }
ii_cover_vb      = _{ "cover" | "wrap" | "seal" | "hide" }
ii_cut_vb        = _{ "cut" | "slice" | "chop" | "carve" }
ii_handle_vb     = _{ "handle" | "grasp" | "hold" | "pick" ~ "up" | "take" }
ii_move_vb       = _{ "move" | "shift" | "slide" | "transport" }
ii_open_vb       = _{ "open" | "unseal" | "uncover" }
ii_repair_vb     = _{ "repair" | "fix" | "restore" | "mend" }
ii_sharpen_vb    = _{ "sharpen" | "hone" | "edge" | "whet" }
ii_turn_vb       = _{ "turn" | "rotate" | "spin" | "twist" | "swivel" }
ii_unlock_vb     = _{ "unlock" | "unfasten" | "unlatch" | "unbolt" }