ehhhhh treetop isn't my favorite right now

treetop
Jordan Orelli 9 years ago
parent fc69b7d45e
commit 2a4f77d8f9

@ -15,7 +15,9 @@ module Bristlecode
end
def inspect(indent="")
"#{indent}TextNode: #{text_value}"
s = "#{indent}TextNode:\n"
text_value.each_line{|line| s += "#{indent} #{line}"}
s
end
def to_html
@ -23,13 +25,30 @@ module Bristlecode
end
end
##############################
# bold
##############################
class BoldNode < Treetop::Runtime::SyntaxNode
end
class BoldOpenNode < Treetop::Runtime::SyntaxNode
end
class BoldCloseNode < Treetop::Runtime::SyntaxNode
end
class BoldNode < Treetop::Runtime::SyntaxNode
##############################
# italic
##############################
class ItalicNode < Treetop::Runtime::SyntaxNode
end
class ItalicOpenNode < Treetop::Runtime::SyntaxNode
end
class ItalicCloseNode < Treetop::Runtime::SyntaxNode
end
class TagNode < Treetop::Runtime::SyntaxNode

@ -1,6 +1,6 @@
grammar Bristlecode
rule root
(tag / text)+ <RootNode>
(tag / text)* <RootNode>
end
rule text
@ -8,7 +8,7 @@ grammar Bristlecode
end
rule tag
(bold) <TagNode>
bold / italic
end
##############################
@ -29,4 +29,23 @@ grammar Bristlecode
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

Loading…
Cancel
Save