Class: Siren::Parser

Inherits:
Object
  • Object
show all
Includes:
Walker
Defined in:
lib/siren/parser.rb

Constant Summary collapse

ESCAPEE =
{
  '"'   => '"',
  '\\'  => '\\',
  '/'   => '/',
  'b'   => '\b',
  'f'   => '\f',
  'n'   => '\n',
  'r'   => '\r',
  't'   => '\t'
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Walker

#walk

Instance Attribute Details

#atObject (readonly)

The index of the current character



19
20
21
# File 'lib/siren/parser.rb', line 19

def at
  @at
end

#chObject (readonly)

The index of the current character



19
20
21
# File 'lib/siren/parser.rb', line 19

def ch
  @ch
end

Instance Method Details

#parse(source, &reviver) ⇒ Object



22
23
24
25
26
27
28
29
30
# File 'lib/siren/parser.rb', line 22

def parse(source, &reviver)
  @text = source.dup
  @at, @ch = 0, ' '
  result = value!
  white!
  error! "Syntax error" if @ch
  
  walk(result, &reviver)
end