module RedParse::MacroMixin

Public Class Methods

new(*args,&block) click to toggle source
Calls superclass method
# File lib/macro.rb, line 989
def initialize(*args,&block)
  super
end

Public Instance Methods

PRECEDENCE() click to toggle source
Calls superclass method
# File lib/macro.rb, line 938
def PRECEDENCE
  result=super
  return result.merge({"^@"=>result["+@"], "v"=>result[";"]})
end
RULES() click to toggle source
Calls superclass method
# File lib/macro.rb, line 943
def RULES
  @@soft_nl||=KW(';')&-{:not_real? =>false}
  [
    -[KW('macro'), KW(beginsendsmatcher).~.*, KW('end'), KW(/^(do|\{)$/).~.la]>>MisparsedNode
  ]+super+[
    -['<+', Expr, '+>']>>FormEscapeNode, 
    -[Op('v'), Expr, lower_op()]>>FormEscapeNode, 
    -[Op('v'), Expr, /^;$|^<doubled-parens>$/, '(', Expr.-, ')']>>FormEscapeNode, #constructor needs update
    -[Op('v'), Expr, ';', KW('(').~.la]>>FormEscapeNode,
    -[Op('v'), Expr, @@soft_nl.la]>>:shift,
    -[Op('^@'), Expr, lower_op()]>>FormEscapeNode,
    -[Op(':@'), (ParenedNode&-{:size=>(0..1)})|(SequenceNode&-{:size=>0})]>>FormNode,
    -['macro', CallSiteNode, KW(';'),
       Expr.-, RescueNode.*, ElseNode.-, EnsureNode.-,
      'end'
     ]>>MacroNode,
    -[ '(', Expr.-, ')', '<doubled-parens>', '(', Expr.-, ')', BlockNode.-, KW('do').~.la]>>CallNode, #constructor needs update
  ]
end
addl_node_containers() click to toggle source
# File lib/macro.rb, line 987
def addl_node_containers; [::Macro] end
beginsendsmatcher() click to toggle source

A regex for all the keywords that can be terminated with the ‘end’ keyword

We use the base class’s list, and add the ‘macro’ keyword to it.

# File lib/macro.rb, line 971
def beginsendsmatcher
  return @bem||=/#{super}|^macro$/ 
end
redparse_modules_init() click to toggle source
Calls superclass method
# File lib/macro.rb, line 925
def redparse_modules_init
  if defined? @lexer and @lexer.respond_to? :enable_macros!
    @lexer.enable_macros!
    @lexer.extend ::RubyLexer::MacroMixin
    @lexer.rubylexer_modules_init
  end
  # binary
  @unary_or_binary_op=/^([\^:]|#@unary_or_binary_op)$/


  super
end
reduce_withs_directory() click to toggle source
# File lib/macro.rb, line 975
def reduce_withs_directory
  "macro"
end
rubykeywordlist() click to toggle source
Calls superclass method
# File lib/macro.rb, line 983
def rubykeywordlist
  super+%w[macro v]
end
rubyoperatorlist() click to toggle source
Calls superclass method
# File lib/macro.rb, line 979
def rubyoperatorlist
  super+%w[:@ ^@ v] 
end
wants_semi_context() click to toggle source
Calls superclass method
# File lib/macro.rb, line 962
def wants_semi_context
  super|KW('macro')
end