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.



70
71
72
# File 'lib/rprec/dsl.rb', line 70

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:



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

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:



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

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)


116
117
118
# File 'lib/rprec/dsl.rb', line 116

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)


124
125
126
# File 'lib/rprec/dsl.rb', line 124

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)


140
141
142
# File 'lib/rprec/dsl.rb', line 140

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)


108
109
110
# File 'lib/rprec/dsl.rb', line 108

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)


100
101
102
# File 'lib/rprec/dsl.rb', line 100

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)


92
93
94
# File 'lib/rprec/dsl.rb', line 92

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)


84
85
86
# File 'lib/rprec/dsl.rb', line 84

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)


132
133
134
# File 'lib/rprec/dsl.rb', line 132

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