Class: Macro::FormEscapeNode

Inherits:
ValueNode
  • Object
show all
Defined in:
lib/macro/form.rb,
lib/macro/ReduceWithsFor_RedParse_RedParse__MacroMixin_RedParse__WithMacros_1_9.rb,
lib/macro/ReduceWithsFor_RedParse_RedParse__MacroMixin_RedParse__WithMacros_1_8.rb,
lib/macro.rb

Overview

The syntax node for a form escape

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.create(*args) ⇒ Object



291
292
293
294
295
296
297
298
299
300
301
302
303
# File 'lib/macro/form.rb', line 291

def self.create(*args)
  v=args.last
  case v
  when UndefNode; v=MisparsedNode.new('',v,'')
  when KeywordToken
    case v.ident
    when /\A(?:;|\+>)\z/; v=args[-2]
    when ')'; huh "v foo;(*params) unhandled yet"
    else fail
    end
  end
  new v
end

Instance Method Details

#imageObject



736
737
738
# File 'lib/macro.rb', line 736

def image
   "^"+body.image
end

#lhs_unparse(o = default_unparse_options) ⇒ Object



314
315
316
# File 'lib/macro/form.rb', line 314

def lhs_unparse o=default_unparse_options
  "(^"+val.unparse(o)+")"
end

#reducer_identObject



19088
19089
19090
# File 'lib/macro/ReduceWithsFor_RedParse_RedParse__MacroMixin_RedParse__WithMacros_1_9.rb', line 19088

def reducer_ident
  :FormEscapeNode
end

#to_sexp(session) ⇒ Object

Convert this node to an S-expression

session

the context in which this macro is being processed



721
722
723
724
725
726
727
728
729
730
731
732
733
734
# File 'lib/macro.rb', line 721

def to_sexp session
  nest=session[:form_nest_level]||1
  carets=0
  node=self
  while FormEscapeNode===node
    node=node.text
    carets+=1
  end
  if carets==nest
    return node.unparse
  else
    return super
  end
end

#unparse(o = default_unparse_options) ⇒ Object

Performs the reverse of a parse operation (turns the node into a string)

o

a list of options for unparse



310
311
312
# File 'lib/macro/form.rb', line 310

def unparse o=default_unparse_options
  "^"+val.unparse(o)      
end

#wraplevelObject

The number of carats (^) that occur in the escape. Note that this method is recursive.



320
321
322
323
# File 'lib/macro/form.rb', line 320

def wraplevel
  return val.wraplevel+1 if FormEscapeNode===val
  return 1
end