Module: Fdlint::Parser::JS::Stat::Iter

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

Overview

循环语句

Instance Method Summary collapse

Instance Method Details

#parse_stat_dowhileObject



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

def parse_stat_dowhile
  log 'parse stat dowhile'

  pos = skip /do/
  body = parse_statement

  skip /while\s*\(/
  condition = parse_expression
  skip /\)/ 
  
  create_element DowhileStatement, body, condition, pos
end

#parse_stat_forObject



33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/fdlint/parser/js/stat/iter.rb', line 33

def parse_stat_for
  log 'parse stat for'

  pos = skip /for/
  
  con_pos = skip /\(/
  first, is_var = parse_stat_for_con_first
  type, second, third = parse_stat_for_con_other(first, is_var)
  skip /\)/

  condition = create_element ForConditionElement, type, first, second, third, con_pos
  body = parse_statement
  create_element ForStatement, condition, body, pos
end

#parse_stat_whileObject



22
23
24
25
26
27
28
29
30
31
# File 'lib/fdlint/parser/js/stat/iter.rb', line 22

def parse_stat_while
  log 'parse stat while'

  pos = skip /while\s*\(/
  condition = parse_expression
  skip /\)/
  body = parse_statement

  create_element WhileStatement, condition, body, pos
end