ceml 0.7.13 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. data/Makefile +1 -1
  2. data/VERSION +1 -1
  3. data/ceml.gemspec +62 -50
  4. data/guide/guide.html +69 -14
  5. data/guide/guide.md +74 -15
  6. data/guide/guide.pdf +0 -0
  7. data/lib/ceml/driver.rb +0 -181
  8. data/lib/ceml/lang/basic_instruction.rb +49 -0
  9. data/lib/ceml/{casting_statement.rb → lang/casting_statement.rb} +19 -9
  10. data/lib/ceml/{instruction_statements.rb → lang/instruction_statements.rb} +5 -16
  11. data/lib/ceml/{script.rb → lang/script.rb} +53 -43
  12. data/lib/ceml/lang/tt/casting.rb +432 -0
  13. data/lib/ceml/lang/tt/casting.treetop +29 -0
  14. data/lib/ceml/lang/tt/instructions.rb +1130 -0
  15. data/lib/ceml/lang/tt/instructions.treetop +86 -0
  16. data/lib/ceml/lang/tt/lexer.rb +1804 -0
  17. data/lib/ceml/{tt → lang/tt}/lexer.treetop +70 -7
  18. data/lib/ceml/lang/tt/scripts.rb +647 -0
  19. data/lib/ceml/{tt → lang/tt}/scripts.treetop +2 -2
  20. data/lib/ceml/lang.rb +10 -0
  21. data/lib/ceml/models/audition.rb +65 -0
  22. data/lib/ceml/models/bundle.rb +64 -0
  23. data/lib/ceml/models/cast.rb +108 -0
  24. data/lib/ceml/models/castable.rb +81 -0
  25. data/lib/ceml/{incident.rb → models/incident.rb} +63 -15
  26. data/lib/ceml/models/incident_model.rb +100 -0
  27. data/lib/ceml/models/incident_role_slot.rb +16 -0
  28. data/lib/ceml/models/player.rb +80 -0
  29. data/lib/ceml/models/queue.rb +12 -0
  30. data/lib/ceml/models/waiting_room.rb +40 -0
  31. data/lib/ceml/models.rb +16 -0
  32. data/lib/ceml/processor.rb +162 -0
  33. data/lib/ceml.rb +7 -14
  34. data/test/askchain.ceml +6 -0
  35. data/test/compliment.ceml +4 -0
  36. data/test/dialogues/accept.ceml +24 -0
  37. data/test/dialogues/basic_seed.ceml +26 -0
  38. data/test/dialogues/jordan.ceml +121 -0
  39. data/test/helper.rb +44 -39
  40. data/test/jane.ceml +48 -0
  41. data/test/{test_casting.rb → lang/test_casting.rb} +5 -0
  42. data/test/lang/test_instructions.rb +42 -0
  43. data/test/{test_scripts.rb → lang/test_scripts.rb} +3 -2
  44. data/test/sync.ceml +6 -0
  45. data/test/test_castable.rb +20 -0
  46. data/test/test_dialogues.rb +58 -0
  47. data/test/test_incident.rb +64 -127
  48. metadata +54 -30
  49. data/.gitignore +0 -23
  50. data/lib/ceml/confluence.rb +0 -63
  51. data/lib/ceml/role.rb +0 -61
  52. data/lib/ceml/tt/casting.treetop +0 -65
  53. data/lib/ceml/tt/instructions.treetop +0 -91
  54. data/test/test_instructions.rb +0 -27
  55. data/test/test_release.rb +0 -78
@@ -1,91 +0,0 @@
1
- module CEML
2
- grammar Instructions
3
- include Lexer
4
-
5
- rule basic_statement
6
- (ask_stmt / tell_stmt / assign_stmt / record_stmt / set_stmt / sync_stmt / release_stmt) {
7
-
8
- def delay
9
- if parent.respond_to? :later and not parent.later.empty?
10
- parent.later.duration.seconds
11
- end
12
- end
13
-
14
- def role; id.text_value.to_sym; end
15
- def text; defined?(super) && super.text_value; end
16
- def var
17
- return varname.text_value if cmd == :record or cmd == :set or cmd == :release
18
- (!respond_to?(:about) || about.empty?) ? nil : about.varname.text_value;
19
- end
20
- def key; var || text; end
21
- def cmd; text_value.split.first.to_sym; end
22
- def cond
23
- (!respond_to?(:condition) || condition.empty?) ? nil : condition.value
24
- end
25
-
26
- def bytecode
27
- code = []
28
- code.concat [[[role], :start_delay, delay],
29
- [[role], :complete_delay]] if delay
30
- code.concat case cmd
31
- when :record; [[[role], :answered_q, {:key => key}]]
32
- when :set; [[[role], :set, {:key => key, :value => text}]]
33
- when :ask; [[[role], :ask_q, {:text => text}],
34
- [[role], :answered_q, {:key => key}]]
35
- when :tell; [[[role], :send_msg, {:text => text}]]
36
- when :assign; [[[role], :assign, {:text => text}],
37
- [[role], :complete_assign, {:text => text}]]
38
- when :release; [[[role], :release, {:tag => key, :cond => cond}]]
39
- when :sync; [[[role], :sync]]
40
- end
41
- code
42
- end
43
- }
44
- end
45
-
46
- rule instruction_stmt
47
- later:later? basic_statement
48
- end
49
-
50
- rule later
51
- duration ws 'later' ws
52
- end
53
-
54
- rule record_stmt
55
- 'record' ws id ws varname:id
56
- end
57
-
58
- rule tell_stmt
59
- 'tell' ws id ':' ws? text
60
- end
61
-
62
- rule assign_stmt
63
- 'assign' ws id ':' ws? text
64
- end
65
-
66
- rule ask_stmt
67
- 'ask' ws id about:(ws 're' ws varname:id)? ':' ws? text
68
- end
69
-
70
- rule set_stmt
71
- 'set' ws id ws varname:id ':' ws? text
72
- end
73
-
74
- rule sync_stmt
75
- 'sync' ws id
76
- end
77
-
78
- rule release_stmt
79
- 'release' ws id ws 'as' ws varname:id condition:condition?
80
- end
81
-
82
- rule condition
83
- ws type:('if' / 'else') ws thing:id {
84
- def value
85
- [type.text_value.to_sym, thing.text_value.to_sym]
86
- end
87
- }
88
- end
89
-
90
- end
91
- end
@@ -1,27 +0,0 @@
1
- require 'ceml'
2
-
3
- class TestInstructions < Test::Unit::TestCase
4
- def pi text
5
- CEML.parse(:instructions, text)
6
- end
7
-
8
- def assert_bad text
9
- assert_raise(RuntimeError){ pi text }
10
- end
11
-
12
- def test_bad
13
- assert_bad "love your mother"
14
- assert_bad "tell jim re susan: i hate you"
15
- assert_bad "tell phil"
16
- assert_bad "ask susan re clothing"
17
- assert_bad "ask susan re clothing: "
18
- end
19
-
20
- def test_instructions
21
- assert_equal "run to the kitchen", pi('tell joe: run to the kitchen').i_tell([:joe]).text
22
- assert_equal ["favorite color?", "favorite soup?"], pi(
23
- "ask joe re color: favorite color?\nask joe re soup: favorite soup?"
24
- ).i_asks([:joe]).map(&:text)
25
- end
26
-
27
- end
data/test/test_release.rb DELETED
@@ -1,78 +0,0 @@
1
- require 'ceml'
2
- require 'test/helper'
3
-
4
- class TestRelease < Test::Unit::TestCase
5
-
6
- def test_release_syntax
7
- s = CEML.parse(:script, "release all as booger")
8
- assert l=s.bytecode.find{ |line| line[1] == :release }
9
- assert_equal 'booger', l[2][:tag]
10
-
11
- s = CEML.parse(:script, "release all as booger if yes")
12
- puts s.bytecode.inspect
13
- assert l=s.bytecode.find{ |line| line[1] == :release }
14
- assert_equal 'booger', l[2][:tag]
15
- assert_equal :if, l[2][:cond][0]
16
- assert_equal :yes, l[2][:cond][1]
17
- end
18
-
19
- def test_release_and_catch
20
- s1 = "await 1 new signup\nrelease signup as confused"
21
- s2 = "await 1 confused booger\ntell booger: you're okay dude"
22
- f = scriptfam s1, s2
23
- play do
24
- ping f, :id => 'sam', :tags => ['new']
25
- told 'sam', /okay dude/
26
- end
27
- end
28
-
29
- def test_conditional_release_and_catch
30
- s1 = "await 1 new signup\nask signup re coffee: want some?\nrelease signup as confused if yes"
31
- s2 = "await 1 confused booger\ntell booger: you're okay dude"
32
- f = scriptfam s1, s2
33
- play do
34
- ping f, :id => 'sam', :tags => ['new']
35
- asked 'sam', /want/
36
- says 'sam', 'y'
37
- told 'sam', /okay dude/
38
- end
39
- end
40
-
41
-
42
- SAM_IAN_SIGNUP_SCRIPTS = <<XXXX
43
- await 1 new signup
44
- ask signup re first_name:
45
- Thanks for signing up for Infatuated!
46
- What's your first name?
47
- ask signup re code:
48
- Type in your Infatuated Match Card code now.
49
- release signup as coded
50
-
51
- await 1 coded alpha and 1 coded beta with matching code
52
- tell alpha: You are alpha |her.first_name|, beta is |buddy.first_name|
53
- tell beta: You are beta |her.first_name|, alpha is |buddy.first_name|
54
- XXXX
55
-
56
-
57
- def test_couple
58
- f = scriptfam *CEML.parse(:scripts, SAM_IAN_SIGNUP_SCRIPTS)
59
- play do
60
- ping f, :id => 'Sara', :tags => ['new']
61
- ping f, :id => 'Jon', :tags => ['new']
62
- asked 'Sara', /Thanks/
63
- says 'Sara', 'Sara'
64
-
65
- asked 'Jon', /Thanks/
66
- says 'Jon', 'Jon'
67
-
68
- asked 'Sara', /Match Card/
69
- asked 'Jon', /Match Card/
70
- says 'Sara', 'xyzzy'
71
- says 'Jon', 'xyZZy '
72
-
73
- told 'Sara', /alpha Sara, beta is Jon/
74
- told 'Jon', /beta Jon, alpha is Sara/
75
- end
76
- end
77
-
78
- end