You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
bbsandbox/bristlecode_parser.treetop

52 lines
819 B
Plaintext

grammar Bristlecode
rule root
(tag / text)* <RootNode>
end
rule text
(!tag .)+ <TextNode>
end
rule tag
bold / italic
end
##############################
# bold
##############################
rule bold
bold_open
((!bold_close .)+ <TextNode>)
bold_close
<BoldNode>
end
rule bold_open
'[b]' <BoldOpenNode> / '[B]' <BoldOpenNode>
end
rule bold_close
'[/b]' <BoldCloseNode> / '[/B]' <BoldCloseNode>
end
##############################
# italic
##############################
rule italic
italic_open
((!italic_close .)+ <TextNode>)
italic_close
<ItalicNode>
end
rule italic_open
'[i]' <ItalicOpenNode> / '[I]' <ItalicOpenNode>
end
rule italic_close
'[/i]' <ItalicCloseNode> / '[/I]' <ItalicCloseNode>
end
end