Permalink
Browse files

Skeleton, nay - Spine - of parser.rb

  • Loading branch information...
1 parent 21b299c commit b8c069fe3868fa1ac1c1ba0da043a505edbb2d9f rking committed May 2, 2012
Showing with 31 additions and 0 deletions.
  1. +31 −0 lib/pegex/parser.rb
View
@@ -0,0 +1,31 @@
+class Pegex
+ class Parser
+ attr_accessor :grammar, :receiver, :debug
+ def initialize args
+ @grammar = args[:grammar]
+ @receiver = default_receiver args[:receiver]
+ @debug = args[:debug]
+
+ @input = nil
+ @buffer = nil
+ @indent = 0
+ @position = nil # was: has 'position' => default => sub {0};
+
+ @throw_on_error = true
+ @wrap = true # Should come from receiver.wrap (pm)
+ #py: terminator
+ end
+
+ def parse input, args = {}
+ # XXX "input" is a simple string ATM.
+ raise 'No grammar specified' if @grammar.nil?
+ end
+
+ def default_receiver maybe_recvr
+ maybe_recvr or begin
+ require 'pegex/receiver'
+ Receiver.new
+ end
+ end
+ end
+end

0 comments on commit b8c069f

Please sign in to comment.