Module: Sydney
- Defined in:
- lib/sydney.rb,
lib/sydney/version.rb
Constant Summary collapse
- VERSION =
"0.0.2"
- @@parser =
SydneyAliasFileParser.new
Class Method Summary collapse
-
.aliases(data) ⇒ Object
Parse the string and return an array of AliasEntry nodes.
-
.parse(data) ⇒ Object
Parse the supplied string and return a Treetop::Runtime::SyntaxNode tree.
-
.sections(data) ⇒ Object
Parse the string and return an array of Section nodes.
Class Method Details
.aliases(data) ⇒ Object
Parse the string and return an array of AliasEntry nodes
35 36 37 |
# File 'lib/sydney.rb', line 35 def self.aliases(data) sections(data).map(&:entries).flatten.map(&:alias).flatten end |
.parse(data) ⇒ Object
Parse the supplied string and return a Treetop::Runtime::SyntaxNode tree
19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/sydney.rb', line 19 def self.parse(data) # Pass the data over to the parser instance tree = @@parser.parse(data) # If the AST is nil then there was an error during parsing # we need to report a simple error message to help the user if(tree.nil?) raise Exception, "Parse error at offset: #{@@parser.index}" end self.clean_tree(tree) tree end |
.sections(data) ⇒ Object
Parse the string and return an array of Section nodes
40 41 42 |
# File 'lib/sydney.rb', line 40 def self.sections(data) parse(data).sections end |