Class: Speculations::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/speculations/parser.rb,
lib/speculations/parser/state/bef.rb,
lib/speculations/parser/state/exa.rb,
lib/speculations/parser/state/inc.rb,
lib/speculations/parser/state/out.rb

Defined Under Namespace

Modules: State Classes: Context

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#filenameObject (readonly)

Returns the value of attribute filename.



6
7
8
# File 'lib/speculations/parser.rb', line 6

def filename
  @filename
end

#inputObject (readonly)

Returns the value of attribute input.



6
7
8
# File 'lib/speculations/parser.rb', line 6

def input
  @input
end

#orig_filenameObject (readonly)

Returns the value of attribute orig_filename.



6
7
8
# File 'lib/speculations/parser.rb', line 6

def orig_filename
  @orig_filename
end

#rootObject (readonly)

Returns the value of attribute root.



6
7
8
# File 'lib/speculations/parser.rb', line 6

def root
  @root
end

#stateObject (readonly)

Returns the value of attribute state.



6
7
8
# File 'lib/speculations/parser.rb', line 6

def state
  @state
end

Class Method Details

.parsersObject



8
9
10
11
12
13
14
15
# File 'lib/speculations/parser.rb', line 8

def self.parsers
   @__parsers__ ||= {
     bef: State::Bef,
     exa: State::Exa,
     inc: State::Inc,
     out: State::Out
   }
end

Instance Method Details

#parse_from_file(file, orig_filename = nil) ⇒ Object



17
18
19
20
21
22
23
24
25
# File 'lib/speculations/parser.rb', line 17

def parse_from_file file, orig_filename = nil
  @filename = file
  @orig_filename = orig_filename || file
  @input = File
    .new(file)
    .each_line(chomp: true)
    .lazy
  parse!
end