Class: NCPP::Parser

Inherits:
Parslet::Parser
  • Object
show all
Defined in:
lib/ncpp/parser.rb

Overview

Parses raw text into a tree

Instance Method Summary collapse

Constructor Details

#initialize(cmd_prefix: 'ncpp_') ⇒ Parser

Returns a new instance of Parser.



10
11
12
# File 'lib/ncpp/parser.rb', line 10

def initialize(cmd_prefix: 'ncpp_')
  @COMMAND_PREFIX = cmd_prefix
end

Instance Method Details

#parse(str, root: :line) ⇒ Object



14
15
16
# File 'lib/ncpp/parser.rb', line 14

def parse(str, root: :line)
  send(root).parse(str)
end

#spaced(atom) ⇒ Object



116
117
118
# File 'lib/ncpp/parser.rb', line 116

def spaced(atom)
  space? >> atom >> space?
end