hotcell 0.0.1 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +4 -1
  3. data/.rspec +1 -0
  4. data/.rvmrc +1 -1
  5. data/.travis.yml +7 -0
  6. data/Gemfile +4 -1
  7. data/README.md +361 -2
  8. data/Rakefile +28 -6
  9. data/ext/lexerc/extconf.rb +3 -0
  10. data/ext/lexerc/lexerc.c +618 -0
  11. data/ext/lexerc/lexerc.h +20 -0
  12. data/ext/lexerc/lexerc.rl +167 -0
  13. data/hotcell.gemspec +8 -7
  14. data/lib/hotcell/commands/case.rb +59 -0
  15. data/lib/hotcell/commands/cycle.rb +38 -0
  16. data/lib/hotcell/commands/for.rb +70 -0
  17. data/lib/hotcell/commands/if.rb +51 -0
  18. data/lib/hotcell/commands/include.rb +21 -0
  19. data/lib/hotcell/commands/scope.rb +13 -0
  20. data/lib/hotcell/commands/unless.rb +23 -0
  21. data/lib/hotcell/commands.rb +13 -0
  22. data/lib/hotcell/config.rb +33 -6
  23. data/lib/hotcell/context.rb +40 -7
  24. data/lib/hotcell/errors.rb +37 -28
  25. data/lib/hotcell/extensions.rb +4 -0
  26. data/lib/hotcell/lexer.rb +19 -635
  27. data/lib/hotcell/lexerr.rb +572 -0
  28. data/lib/hotcell/lexerr.rl +137 -0
  29. data/lib/hotcell/node/assigner.rb +1 -5
  30. data/lib/hotcell/node/block.rb +17 -40
  31. data/lib/hotcell/node/command.rb +29 -22
  32. data/lib/hotcell/node/hasher.rb +1 -1
  33. data/lib/hotcell/node/summoner.rb +2 -6
  34. data/lib/hotcell/node/tag.rb +10 -7
  35. data/lib/hotcell/node.rb +12 -1
  36. data/lib/hotcell/parser.rb +474 -408
  37. data/lib/hotcell/parser.y +175 -117
  38. data/lib/hotcell/resolver.rb +44 -0
  39. data/lib/hotcell/source.rb +35 -0
  40. data/lib/hotcell/template.rb +15 -6
  41. data/lib/hotcell/version.rb +1 -1
  42. data/lib/hotcell.rb +15 -10
  43. data/spec/data/templates/simple.hc +1 -0
  44. data/spec/lib/hotcell/commands/case_spec.rb +39 -0
  45. data/spec/lib/hotcell/commands/cycle_spec.rb +29 -0
  46. data/spec/lib/hotcell/commands/for_spec.rb +65 -0
  47. data/spec/lib/hotcell/commands/if_spec.rb +35 -0
  48. data/spec/lib/hotcell/commands/include_spec.rb +39 -0
  49. data/spec/lib/hotcell/commands/scope_spec.rb +16 -0
  50. data/spec/lib/hotcell/commands/unless_spec.rb +23 -0
  51. data/spec/lib/hotcell/config_spec.rb +35 -10
  52. data/spec/lib/hotcell/context_spec.rb +58 -18
  53. data/spec/lib/hotcell/lexer_spec.rb +37 -28
  54. data/spec/lib/hotcell/node/block_spec.rb +28 -56
  55. data/spec/lib/hotcell/node/command_spec.rb +7 -31
  56. data/spec/lib/hotcell/node/tag_spec.rb +16 -0
  57. data/spec/lib/hotcell/parser_spec.rb +152 -123
  58. data/spec/lib/hotcell/resolver_spec.rb +28 -0
  59. data/spec/lib/hotcell/source_spec.rb +41 -0
  60. data/spec/lib/hotcell/template_spec.rb +47 -4
  61. data/spec/lib/hotcell_spec.rb +2 -1
  62. data/spec/spec_helper.rb +6 -2
  63. metadata +54 -24
  64. data/lib/hotcell/.DS_Store +0 -0
  65. data/lib/hotcell/lexer.rl +0 -299
  66. data/misc/rage.rl +0 -1999
  67. data/misc/unicode2ragel.rb +0 -305
@@ -1,43 +1,52 @@
1
1
  module Hotcell
2
- class Errors
3
- class ParseError < StandardError
4
- def initialize line, column
5
- @line, @column = line, column
6
- end
7
- end
2
+ class Error < StandardError
3
+ end
8
4
 
9
- class UnexpectedSymbol < ParseError
10
- def message
11
- "Unexpected symbol at #{@line}:#{@column}"
12
- end
5
+ class ParseError < Error
6
+ def initialize value, line, column
7
+ @value, @line, @column = value, line, column
8
+ super(compose_message)
13
9
  end
10
+ end
14
11
 
15
- class UnterminatedString < ParseError
16
- def message
17
- "Unterminated string starting at #{@line}:#{@column}"
18
- end
12
+ class UnexpectedSymbol < ParseError
13
+ def compose_message
14
+ "Unexpected symbol `#{@value}` at #{@line}:#{@column}"
19
15
  end
16
+ end
20
17
 
21
- # class UnterminatedRegexp < ParseError
22
- # def message
23
- # "Unterminated regexp starting at: line #{@line}, column #{@column}"
24
- # end
25
- # end
18
+ class UnterminatedString < ParseError
19
+ def compose_message
20
+ "Unterminated string `#{@value}` starting at #{@line}:#{@column}"
21
+ end
22
+ end
26
23
 
27
- class SyntaxError < StandardError
28
- def initialize message, line = nil, column = nil
29
- @message, @line, @column = message, line, column
30
- end
24
+ # class UnterminatedRegexp < ParseError
25
+ # def compose_message
26
+ # "Unterminated regexp `#{@value}` starting at #{@line}:#{@column}"
27
+ # end
28
+ # end
31
29
 
32
- def message
33
- "#{@message} at #{@line}:#{@column}"
34
- end
30
+ class SyntaxError < Error
31
+ def initialize value, line, column
32
+ @value, @line, @column = value, line, column
33
+ super(compose_message)
35
34
  end
36
35
 
37
- class BlockError < SyntaxError
36
+ def compose_message
37
+ "#{@value} at #{@line}:#{@column}"
38
38
  end
39
+ end
39
40
 
40
- class ArgumentError < SyntaxError
41
+ class UnexpectedLexem < ParseError
42
+ def compose_message
43
+ "Unexpected #{@value} at #{@line}:#{@column}"
41
44
  end
42
45
  end
46
+
47
+ class BlockError < SyntaxError
48
+ end
49
+
50
+ class ArgumentError < SyntaxError
51
+ end
43
52
  end
@@ -36,6 +36,10 @@ end
36
36
 
37
37
  Hash.class_eval do
38
38
  include Hotcell::Manipulator::Mixin
39
+
40
+ def manipulator_invoke method, *arguments
41
+ arguments.size == 0 && key?(method) ? self[method] : super
42
+ end
39
43
  end
40
44
 
41
45