Module: Fdlint::Parser::JS::Stat::Try

Included in:
Stat
Defined in:
lib/fdlint/parser/js/stat/try.rb

Instance Method Summary collapse

Instance Method Details

#parse_stat_tryObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/fdlint/parser/js/stat/try.rb', line 7

def parse_stat_try
  pos = skip /try/
  try_part = parse_stat_block

  catch_part = if check /catch\b/
    catch_pos = skip /catch\s*\(/
    id = parse_expr_identifier
    skip /\)/
    create_element Statement, 'catch', id, parse_stat_block, catch_pos
  end
  
  finally_part = if check /finally\b/
    skip /finally/
    parse_stat_block
  end

  create_element TryStatement, try_part, catch_part, finally_part, pos
end