No matter what I try, I always get something like:
Consumed 0 characters.
Line: 19
Column: 1
, ason: Expected one of ,, any character,
, " at line 19, column 1 (byte 394) after Chapter: "The beginning of the end"
Action: unlock_grate
Terms:
"unlock grate, open grate"
Processor:
{{{
if !player_in?('depression')
['There is no grate here.', {}]
elsif !player_has?('keys')
['You have no keys!', {}]
else
['The grate is now unlocked.', {:grate_unlocked => true}]
end
}}}
end
end
Sample input:
Chapter: "The beginning of the end"
Action: unlock_grate
Terms:
"unlock grate, open grate"
Processor:
{{{
if !player_in?('depression')
['There is no grate here.', {}]
elsif !player_has?('keys')
['You have no keys!', {}]
else
['The grate is now unlocked.', {:grate_unlocked => true}]
end
}}}
end
end
grammar TheFates
#
# Interactive Fiction
#
rule interactive_fiction
chapter (white_space chapter)*
end
#
# Chapter
#
rule chapter
chapter_header white_space actions 'end' !not_space_or_tab
end
rule chapter_header
'Chapter:' space_or_tab quoted_string end_of_line
end
#
# Actions
#
rule actions
action white_space+ actions white_space+ 'end' !not_space_or_tab
end
rule action
action_header white_space+ terms white_space+ processor
end
rule action_header
'Action:' space_or_tab+ identifier end_of_line
end
rule terms
'Terms:' white_space+ term_list
end
rule processor
'Processor:' white_space+ '{{{' code '}}}'
end
rule code
!'}}}'
(. / white_space)+
end
# Low-level constructs
rule alphanumeric_character
alphabetical_character / [0-9]
end
rule alphabetical_character
[A-Za-z_]
end
rule comment_to_end_of_line
'#' characters_to_end_of_line
end
rule characters_to_end_of_line
(!end_of_line .)*
end
rule description
'Description:' white_space+ quoted_string
end
rule identifier
[a-zA-Z] [a-zA-Z0-9_]*
end
rule quoted_string
single_quoted_string / double_quoted_string
end
rule double_quoted_string
'"' (!'"' ("\\\\" / '\"' / .))* '"'
end
rule single_quoted_string
"'" (!"'" ("\\\\" / "\\'" / .))* "'"
end
rule term_list
'"' term (white_space* ',' white_space* term)* '"'
end
rule term
(!',' .)+
end
# White space
rule white_space
(space_or_tab / end_of_line)+
end
rule not_space_or_tab
!space_or_tab .
end
rule space_or_tab
[ \t]
end
rule end_of_line
("\r" "\n"?) / "\n"
end
end