Module: Fdlint::Parser::JS::Stat::Switch
- Included in:
- Stat
- Defined in:
- lib/fdlint/parser/js/stat/switch.rb
Instance Method Summary collapse
- #parse_stat_caseblock ⇒ Object
- #parse_stat_caseclause ⇒ Object
- #parse_stat_caseclauses ⇒ Object
- #parse_stat_defaultclause ⇒ Object
- #parse_stat_switch ⇒ Object
Instance Method Details
#parse_stat_caseblock ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/fdlint/parser/js/stat/switch.rb', line 18 def parse_stat_caseblock log 'parse stat caseblock' pos = skip /\{/ case_clauses = check(/case\b/) ? parse_stat_caseclauses : nil default_clause = check(/default\b/) ? parse_stat_defaultclause : nil bottom_case_clauses = check(/case\b/) ? parse_stat_caseclauses : nil skip /\}/ create_element CaseBlockStatement, case_clauses, default_clause, bottom_case_clauses, pos end |
#parse_stat_caseclause ⇒ Object
37 38 39 40 41 42 43 44 45 |
# File 'lib/fdlint/parser/js/stat/switch.rb', line 37 def parse_stat_caseclause log 'parse stat caseclause' pos = skip /case/ expr = parse_expression skip /:/ stats = parse_statement_list create_element Statement, 'caseclause', expr, stats, pos end |
#parse_stat_caseclauses ⇒ Object
31 32 33 34 35 |
# File 'lib/fdlint/parser/js/stat/switch.rb', line 31 def parse_stat_caseclauses log 'parse stat caseclauses' stats = batch(:parse_stat_caseclause, /default\b|\}/) create_element Elements, stats end |
#parse_stat_defaultclause ⇒ Object
47 48 49 50 51 52 53 |
# File 'lib/fdlint/parser/js/stat/switch.rb', line 47 def parse_stat_defaultclause log 'parse stat defaultclause' pos = skip /default\s*:/ stats = parse_statement_list create_element Statement, 'defaultclause', stats, nil, pos end |
#parse_stat_switch ⇒ Object
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/fdlint/parser/js/stat/switch.rb', line 7 def parse_stat_switch log 'parse stat switch' pos = skip /switch\s*\(/ expression = parse_expression skip /\)/ block = parse_stat_caseblock create_element SwitchStatement, expression, block, pos end |