module SheepAst::SyntaxAlias

syntax wrapper to allow user to use syntax easily. This simplifies syntax user should input

@api public

Attributes

s_db[RW]

Public Instance Methods

<<(elem) click to toggle source
# File lib/sheep_ast/syntax_alias.rb, line 66
def <<(elem)
  if elem.is_a? Enumerable
    T.unsafe(self).concat(elem)
  else
    T.unsafe(self).push(elem)
  end
end
A(kind, *para, **options) click to toggle source
# File lib/sheep_ast/syntax_alias.rb, line 99
def A(kind, *para, **options)
  @af.gen(kind, *para, **options)
end
E(kind, *para, **options) click to toggle source
# File lib/sheep_ast/syntax_alias.rb, line 35
def E(kind, *para, **options)
  @mf.gen(kind, *para, **options)
end
NEQ(expr, index = 1) click to toggle source
# File lib/sheep_ast/syntax_alias.rb, line 129
def NEQ(expr, index = 1)
  Qualifier.new(expr, offset: index)
end
S(index = :root, **options, &blk) click to toggle source
# File lib/sheep_ast/syntax_alias.rb, line 57
def S(index = :root, **options, &blk)
  if @s_db.nil?
    @s_db = {}
    @s_db[:root] = []
  end

  elem = @s_db[index]&.dup || []

  elem.instance_eval {
    def <<(elem)
      if elem.is_a? Enumerable
        T.unsafe(self).concat(elem)
      else
        T.unsafe(self).push(elem)
      end
    end
  }

  #elem.parent_ref(self, index)
  if block_given?
    @s_db[index] = blk.call
  end

  return elem
end
SS(*para, **options) click to toggle source
# File lib/sheep_ast/syntax_alias.rb, line 88
def SS(*para, **options)
  return T.unsafe(self)._SS(*para, **options)
end
_S(*para, **options) click to toggle source
# File lib/sheep_ast/syntax_alias.rb, line 178
def _S(*para, **options)
  elem = []
  elem.instance_eval {
    def <<(elem)
      if elem.is_a? Enumerable
        T.unsafe(self).concat(elem)
      else
        T.unsafe(self).push(elem)
      end
    end
  }
  return elem
end
_SS(*para, **options) click to toggle source
# File lib/sheep_ast/syntax_alias.rb, line 202
def _SS(*para, **options)
  return para
end
any(tag = nil) click to toggle source
# File lib/sheep_ast/syntax_alias.rb, line 159
def any(tag = nil)
  tag.nil? ? E(:r, '.*') : E(:r, '.*', tag)
end
cpp_comment() click to toggle source
# File lib/sheep_ast/syntax_alias.rb, line 154
def cpp_comment
  E(:e, '//')
end
crlf() click to toggle source
# File lib/sheep_ast/syntax_alias.rb, line 134
def crlf
  E(:e, "\r\n")
end
eof() click to toggle source
# File lib/sheep_ast/syntax_alias.rb, line 144
def eof
  E(:e, '__sheep_eof__')
end
idx(*par, **options) click to toggle source
# File lib/sheep_ast/syntax_alias.rb, line 164
def idx(*par, **options)
  T.unsafe(IndexCondition).new(*par, **options)
end
lf() click to toggle source
# File lib/sheep_ast/syntax_alias.rb, line 139
def lf
  E(:e, "\n")
end
space() click to toggle source
# File lib/sheep_ast/syntax_alias.rb, line 149
def space
  E(:e, ' ')
end