Module: DataMetaParse

Defined in:
lib/dataMetaParse.rb,
lib/dataMetaParse/uriDataMeta.rb

Overview

Grammar parsing commons for the dataMeta Project.

For command line details either check the new method’s source or the README.rdoc file, the usage section.

Defined Under Namespace

Classes: Err, Uri

Constant Summary collapse

VERSION =

Current version

'1.0.0'

Class Method Summary collapse

Class Method Details

.loadBaseRulzObject

Loads the base rules from dataMetaParse/basic.treetop



40
41
42
# File 'lib/dataMetaParse.rb', line 40

def loadBaseRulz
    Treetop.load("#{File.dirname(__FILE__)}/dataMetaParse/basic")
end

.parse(parser, source) ⇒ Object

Parse with error handling, convenience shortcut to the content of this method.

Parameters:

  • parser (Object)

    Treetop compiled parser whichever class it is. It may be Treetop::Runtime::CompiledParser

  • source (String)

    the data to parse with the given parser

Returns:

  • (Object)

    either the AST, likely as Treetop::Runtime::SyntaxNode if the parsing was successful or Err if it was not or nil if there is no match. It’s not very consistent of when you get an Err or when you get a nil, it’s not exact science. One way to get a nil is to cause mismatch in the very first token.



53
54
55
# File 'lib/dataMetaParse.rb', line 53

def parse(parser, source)
    parser.parse(source) || ( parser.failure_reason ? Err.new(source, parser) : nil)
end