class CorrespondenceMarkup::CorrespondenceMarkupCompiler
Compiler that parses and compiles correspondence markup source code into an array of StructureGroup
objects (from which HTML can be generated in the format required by correspondence.js).
Public Class Methods
new()
click to toggle source
Initialize by creating the CorrespondenceMarkupLanguageParser (defined by the Treetop source).
# File lib/correspondence-markup.rb, line 14 def initialize @parser = CorrespondenceMarkupLanguageParser.new end
Public Instance Methods
compile_structure_groups(markup)
click to toggle source
Compile source code into an array of StructureGroup
objects, throwing an exception if there is a parse error.
# File lib/correspondence-markup.rb, line 20 def compile_structure_groups(markup) syntax_tree = @parser.parse(markup, root: :structure_groups) if(syntax_tree.nil?) raise Exception, "Parse error: #{@parser.failure_reason}" end syntax_tree.value end