Class: IRB::SLex
- Extended by:
- Exception2MessageMapper
- Defined in:
- lib/irb/slex.rb
Defined Under Namespace
Classes: Node
Constant Summary collapse
- DOUT =
Notifier::def_notifier("SLex::")
- D_WARN =
DOUT::def_notifier(1, "Warn: ")
- D_DEBUG =
DOUT::def_notifier(2, "Debug: ")
- D_DETAIL =
DOUT::def_notifier(4, "Detail: ")
Instance Method Summary collapse
- #create(token, preproc = nil, postproc = nil) ⇒ Object
- #def_rule(token, preproc = nil, postproc = nil, &block) ⇒ Object
- #def_rules(*tokens, &block) ⇒ Object
-
#initialize ⇒ SLex
constructor
A new instance of SLex.
- #inspect ⇒ Object
- #match(token) ⇒ Object
-
#postproc(token) ⇒ Object
$BMW%A%‘%C%/(B?.
- #preproc(token, proc) ⇒ Object
- #search(token) ⇒ Object
Constructor Details
Instance Method Details
#create(token, preproc = nil, postproc = nil) ⇒ Object
66 67 68 |
# File 'lib/irb/slex.rb', line 66 def create(token, preproc = nil, postproc = nil) @head.create_subnode(token.split(//), preproc, postproc) end |
#def_rule(token, preproc = nil, postproc = nil, &block) ⇒ Object
35 36 37 38 39 40 |
# File 'lib/irb/slex.rb', line 35 def def_rule(token, preproc = nil, postproc = nil, &block) D_DETAIL.pp token postproc = block if block_given? create(token, preproc, postproc) end |
#def_rules(*tokens, &block) ⇒ Object
42 43 44 45 46 47 48 49 |
# File 'lib/irb/slex.rb', line 42 def def_rules(*tokens, &block) if block_given? p = block end for token in tokens def_rule(token, nil, p) end end |
#inspect ⇒ Object
83 84 85 |
# File 'lib/irb/slex.rb', line 83 def inspect format("<SLex: @head = %s>", @head.inspect) end |
#match(token) ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/irb/slex.rb', line 70 def match(token) case token when Array when String return match(token.split(//)) else return @head.match_io(token) end ret = @head.match(token) D_DETAIL.exec_if{D_DETAIL.printf "match end: %s:%s\n", ret, token.inspect} ret end |
#postproc(token) ⇒ Object
$BMW%A%‘%C%/(B?
57 58 59 60 |
# File 'lib/irb/slex.rb', line 57 def postproc(token) node = search(token, proc) node.postproc=proc end |
#preproc(token, proc) ⇒ Object
51 52 53 54 |
# File 'lib/irb/slex.rb', line 51 def preproc(token, proc) node = search(token) node.preproc=proc end |
#search(token) ⇒ Object
62 63 64 |
# File 'lib/irb/slex.rb', line 62 def search(token) @head.search(token.split(//)) end |