Class: RPrec::DSL::PrecDSL

Inherits:
Object
  • Object
show all
Defined in:
lib/rprec/dsl.rb

Overview

PrecDSL is a context of blocks of the RPrec::DSL#prec method.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializePrecDSL

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of PrecDSL.



65
66
67
# File 'lib/rprec/dsl.rb', line 65

def initialize
  @ops = []
end

Instance Attribute Details

#opsArray<RPrec::Op> (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:



73
74
75
# File 'lib/rprec/dsl.rb', line 73

def ops
  @ops
end

Class Method Details

.build(name, succs, &block) ⇒ RPrec::

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

  • name (Symbol)
  • succs (Array<Symbol>)
  • block (Proc)

Returns:



58
59
60
61
62
# File 'lib/rprec/dsl.rb', line 58

def self.build(name, succs, &block)
  context = PrecDSL.new
  context.instance_eval(&block) if block
  Prec.new(name, succs, context.ops)
end

Instance Method Details

#closed(key, *parts, &build) ⇒ void

This method returns an undefined value.

Parameters:

  • key (String)
  • parts (Array<String, Symbol>)
  • build (Proc)


111
112
113
# File 'lib/rprec/dsl.rb', line 111

def closed(key, *parts, &build)
  @ops << Op.new(:closed, key, parts, build)
end

#left_assoc(key, *parts, &build) ⇒ void

This method returns an undefined value.

Parameters:

  • key (String)
  • parts (Array<String, Symbol>)
  • build (Proc)


119
120
121
# File 'lib/rprec/dsl.rb', line 119

def left_assoc(key, *parts, &build)
  @ops << Op.new(:left_assoc, key, parts, build)
end

#non_assoc(key, *parts, &build) ⇒ void

This method returns an undefined value.

Parameters:

  • key (String)
  • parts (Array<String, Symbol>)
  • build (Proc)


135
136
137
# File 'lib/rprec/dsl.rb', line 135

def non_assoc(key, *parts, &build)
  @ops << Op.new(:non_assoc, key, parts, build)
end

#non_assoc_postfix(key, *parts, &build) ⇒ void

This method returns an undefined value.

Parameters:

  • key (String)
  • parts (Array<String, Symbol>)
  • build (Proc)


103
104
105
# File 'lib/rprec/dsl.rb', line 103

def non_assoc_postfix(key, *parts, &build)
  @ops << Op.new(:non_assoc_postfix, key, parts, build)
end

#non_assoc_prefix(key, *parts, &build) ⇒ void

This method returns an undefined value.

Parameters:

  • key (String)
  • parts (Array<String, Symbol>)
  • build (Proc)


95
96
97
# File 'lib/rprec/dsl.rb', line 95

def non_assoc_prefix(key, *parts, &build)
  @ops << Op.new(:non_assoc_prefix, key, parts, build)
end

#postfix(key, *parts, &build) ⇒ void

This method returns an undefined value.

Parameters:

  • key (String)
  • parts (Array<String, Symbol>)
  • build (Proc)


87
88
89
# File 'lib/rprec/dsl.rb', line 87

def postfix(key, *parts, &build)
  @ops << Op.new(:postfix, key, parts, build)
end

#prefix(key, *parts, &build) ⇒ void

This method returns an undefined value.

Parameters:

  • key (String)
  • parts (Array<String, Symbol>)
  • build (Proc)


79
80
81
# File 'lib/rprec/dsl.rb', line 79

def prefix(key, *parts, &build)
  @ops << Op.new(:prefix, key, parts, build)
end

#right_assoc(key, *parts, &build) ⇒ void

This method returns an undefined value.

Parameters:

  • key (String)
  • parts (Array<String, Symbol>)
  • build (Proc)


127
128
129
# File 'lib/rprec/dsl.rb', line 127

def right_assoc(key, *parts, &build)
  @ops << Op.new(:right_assoc, key, parts, build)
end