Module: Fdlint::Parser::JS::Stat::If

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

Instance Method Summary collapse

Instance Method Details

#parse_stat_ifObject



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

def parse_stat_if
  log 'parse stat if'

  pos = skip /if\s*\(/
  condition = parse_expression
  skip /\)/

  true_part = parse_statement
  false_part = if check /else\b/
    skip /else/
    parse_statement
  end
  
  create_element IfStatement, condition, true_part, false_part, pos
end