tripper 0.0.3d

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 (210) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +17 -0
  3. data/Gemfile +4 -0
  4. data/LICENSE.txt +22 -0
  5. data/README.md +29 -0
  6. data/Rakefile +1 -0
  7. data/TODO +26 -0
  8. data/lib/generators/USAGE +8 -0
  9. data/lib/generators/tripper.rb +51 -0
  10. data/lib/generators/tripper/commonalities/commonalities.rb +226 -0
  11. data/lib/generators/tripper/detect_changes/detect_changes_generator.rb +173 -0
  12. data/lib/generators/tripper/detect_changes/model.rb +226 -0
  13. data/lib/generators/tripper/detect_changes/templates/migration.rb +7 -0
  14. data/lib/generators/tripper/detect_changes/templates/model/belongs_to.rb +1 -0
  15. data/lib/generators/tripper/detect_changes/templates/model/has_one.rb +1 -0
  16. data/lib/generators/tripper/detect_changes/templates/model/validates.rb +2 -0
  17. data/lib/generators/tripper/from_community/from_community_generator.rb +95 -0
  18. data/lib/generators/tripper/from_community/templates/actions/create.rb +8 -0
  19. data/lib/generators/tripper/from_community/templates/actions/destroy.rb +5 -0
  20. data/lib/generators/tripper/from_community/templates/actions/edit.rb +3 -0
  21. data/lib/generators/tripper/from_community/templates/actions/index.rb +3 -0
  22. data/lib/generators/tripper/from_community/templates/actions/new.rb +3 -0
  23. data/lib/generators/tripper/from_community/templates/actions/show.rb +3 -0
  24. data/lib/generators/tripper/from_community/templates/actions/update.rb +8 -0
  25. data/lib/generators/tripper/from_community/templates/controller.rb +3 -0
  26. data/lib/generators/tripper/from_community/templates/fixtures.yml +9 -0
  27. data/lib/generators/tripper/from_community/templates/helper.rb +2 -0
  28. data/lib/generators/tripper/from_community/templates/migration.rb +30 -0
  29. data/lib/generators/tripper/from_community/templates/model.rb +54 -0
  30. data/lib/generators/tripper/from_community/templates/tests/rspec/actions/create.rb +11 -0
  31. data/lib/generators/tripper/from_community/templates/tests/rspec/actions/destroy.rb +6 -0
  32. data/lib/generators/tripper/from_community/templates/tests/rspec/actions/edit.rb +4 -0
  33. data/lib/generators/tripper/from_community/templates/tests/rspec/actions/index.rb +4 -0
  34. data/lib/generators/tripper/from_community/templates/tests/rspec/actions/new.rb +4 -0
  35. data/lib/generators/tripper/from_community/templates/tests/rspec/actions/show.rb +4 -0
  36. data/lib/generators/tripper/from_community/templates/tests/rspec/actions/update.rb +11 -0
  37. data/lib/generators/tripper/from_community/templates/tests/rspec/controller.rb +8 -0
  38. data/lib/generators/tripper/from_community/templates/tests/rspec/model.rb +7 -0
  39. data/lib/generators/tripper/from_community/templates/tests/shoulda/actions/create.rb +13 -0
  40. data/lib/generators/tripper/from_community/templates/tests/shoulda/actions/destroy.rb +8 -0
  41. data/lib/generators/tripper/from_community/templates/tests/shoulda/actions/edit.rb +6 -0
  42. data/lib/generators/tripper/from_community/templates/tests/shoulda/actions/index.rb +6 -0
  43. data/lib/generators/tripper/from_community/templates/tests/shoulda/actions/new.rb +6 -0
  44. data/lib/generators/tripper/from_community/templates/tests/shoulda/actions/show.rb +6 -0
  45. data/lib/generators/tripper/from_community/templates/tests/shoulda/actions/update.rb +13 -0
  46. data/lib/generators/tripper/from_community/templates/tests/shoulda/controller.rb +5 -0
  47. data/lib/generators/tripper/from_community/templates/tests/shoulda/model.rb +7 -0
  48. data/lib/generators/tripper/from_community/templates/tests/testunit/actions/create.rb +11 -0
  49. data/lib/generators/tripper/from_community/templates/tests/testunit/actions/destroy.rb +6 -0
  50. data/lib/generators/tripper/from_community/templates/tests/testunit/actions/edit.rb +4 -0
  51. data/lib/generators/tripper/from_community/templates/tests/testunit/actions/index.rb +4 -0
  52. data/lib/generators/tripper/from_community/templates/tests/testunit/actions/new.rb +4 -0
  53. data/lib/generators/tripper/from_community/templates/tests/testunit/actions/show.rb +4 -0
  54. data/lib/generators/tripper/from_community/templates/tests/testunit/actions/update.rb +11 -0
  55. data/lib/generators/tripper/from_community/templates/tests/testunit/controller.rb +5 -0
  56. data/lib/generators/tripper/from_community/templates/tests/testunit/model.rb +7 -0
  57. data/lib/generators/tripper/from_community/templates/views/erb/_form.html.erb +16 -0
  58. data/lib/generators/tripper/from_community/templates/views/erb/edit.html.erb +14 -0
  59. data/lib/generators/tripper/from_community/templates/views/erb/index.html.erb +29 -0
  60. data/lib/generators/tripper/from_community/templates/views/erb/new.html.erb +7 -0
  61. data/lib/generators/tripper/from_community/templates/views/erb/show.html.erb +25 -0
  62. data/lib/generators/tripper/from_community/templates/views/haml/_form.html.haml +9 -0
  63. data/lib/generators/tripper/from_community/templates/views/haml/edit.html.haml +14 -0
  64. data/lib/generators/tripper/from_community/templates/views/haml/index.html.haml +25 -0
  65. data/lib/generators/tripper/from_community/templates/views/haml/new.html.haml +7 -0
  66. data/lib/generators/tripper/from_community/templates/views/haml/show.html.haml +20 -0
  67. data/lib/generators/tripper/layout/USAGE +18 -0
  68. data/lib/generators/tripper/layout/layout_generator.rb +29 -0
  69. data/lib/generators/tripper/layout/templates/error_messages_helper.rb +23 -0
  70. data/lib/generators/tripper/layout/templates/layout.html.erb +19 -0
  71. data/lib/generators/tripper/layout/templates/layout.html.haml +21 -0
  72. data/lib/generators/tripper/layout/templates/layout_helper.rb +22 -0
  73. data/lib/generators/tripper/layout/templates/stylesheet.css +83 -0
  74. data/lib/generators/tripper/layout/templates/stylesheet.sass +73 -0
  75. data/lib/generators/tripper/obj_constraint.rb +23 -0
  76. data/lib/generators/tripper/predicate.rb +12 -0
  77. data/lib/generators/tripper/sync_with_community/model.rb +260 -0
  78. data/lib/generators/tripper/sync_with_community/sync_with_community_generator.rb +310 -0
  79. data/lib/generators/tripper/sync_with_community/templates/migration.rb +7 -0
  80. data/lib/generators/tripper/sync_with_community/templates/model/belongs_to.rb +1 -0
  81. data/lib/generators/tripper/sync_with_community/templates/model/has_one.rb +1 -0
  82. data/lib/generators/tripper/sync_with_community/templates/model/validates.rb +2 -0
  83. data/lib/generators/tripper/templates/actions/create.rb +8 -0
  84. data/lib/generators/tripper/templates/actions/destroy.rb +5 -0
  85. data/lib/generators/tripper/templates/actions/edit.rb +3 -0
  86. data/lib/generators/tripper/templates/actions/index.rb +3 -0
  87. data/lib/generators/tripper/templates/actions/new.rb +3 -0
  88. data/lib/generators/tripper/templates/actions/show.rb +3 -0
  89. data/lib/generators/tripper/templates/actions/update.rb +8 -0
  90. data/lib/generators/tripper/templates/controller.rb +3 -0
  91. data/lib/generators/tripper/templates/fixtures.yml +9 -0
  92. data/lib/generators/tripper/templates/helper.rb +2 -0
  93. data/lib/generators/tripper/templates/migration.rb +30 -0
  94. data/lib/generators/tripper/templates/model.rb +54 -0
  95. data/lib/generators/tripper/templates/tests/rspec/actions/create.rb +11 -0
  96. data/lib/generators/tripper/templates/tests/rspec/actions/destroy.rb +6 -0
  97. data/lib/generators/tripper/templates/tests/rspec/actions/edit.rb +4 -0
  98. data/lib/generators/tripper/templates/tests/rspec/actions/index.rb +4 -0
  99. data/lib/generators/tripper/templates/tests/rspec/actions/new.rb +4 -0
  100. data/lib/generators/tripper/templates/tests/rspec/actions/show.rb +4 -0
  101. data/lib/generators/tripper/templates/tests/rspec/actions/update.rb +11 -0
  102. data/lib/generators/tripper/templates/tests/rspec/controller.rb +8 -0
  103. data/lib/generators/tripper/templates/tests/rspec/model.rb +7 -0
  104. data/lib/generators/tripper/templates/tests/shoulda/actions/create.rb +13 -0
  105. data/lib/generators/tripper/templates/tests/shoulda/actions/destroy.rb +8 -0
  106. data/lib/generators/tripper/templates/tests/shoulda/actions/edit.rb +6 -0
  107. data/lib/generators/tripper/templates/tests/shoulda/actions/index.rb +6 -0
  108. data/lib/generators/tripper/templates/tests/shoulda/actions/new.rb +6 -0
  109. data/lib/generators/tripper/templates/tests/shoulda/actions/show.rb +6 -0
  110. data/lib/generators/tripper/templates/tests/shoulda/actions/update.rb +13 -0
  111. data/lib/generators/tripper/templates/tests/shoulda/controller.rb +5 -0
  112. data/lib/generators/tripper/templates/tests/shoulda/model.rb +7 -0
  113. data/lib/generators/tripper/templates/tests/testunit/actions/create.rb +11 -0
  114. data/lib/generators/tripper/templates/tests/testunit/actions/destroy.rb +6 -0
  115. data/lib/generators/tripper/templates/tests/testunit/actions/edit.rb +4 -0
  116. data/lib/generators/tripper/templates/tests/testunit/actions/index.rb +4 -0
  117. data/lib/generators/tripper/templates/tests/testunit/actions/new.rb +4 -0
  118. data/lib/generators/tripper/templates/tests/testunit/actions/show.rb +4 -0
  119. data/lib/generators/tripper/templates/tests/testunit/actions/update.rb +11 -0
  120. data/lib/generators/tripper/templates/tests/testunit/controller.rb +5 -0
  121. data/lib/generators/tripper/templates/tests/testunit/model.rb +7 -0
  122. data/lib/generators/tripper/templates/views/erb/_form.html.erb +16 -0
  123. data/lib/generators/tripper/templates/views/erb/edit.html.erb +14 -0
  124. data/lib/generators/tripper/templates/views/erb/index.html.erb +29 -0
  125. data/lib/generators/tripper/templates/views/erb/new.html.erb +7 -0
  126. data/lib/generators/tripper/templates/views/erb/show.html.erb +25 -0
  127. data/lib/generators/tripper/templates/views/haml/_form.html.haml +9 -0
  128. data/lib/generators/tripper/templates/views/haml/edit.html.haml +14 -0
  129. data/lib/generators/tripper/templates/views/haml/index.html.haml +25 -0
  130. data/lib/generators/tripper/templates/views/haml/new.html.haml +7 -0
  131. data/lib/generators/tripper/templates/views/haml/show.html.haml +20 -0
  132. data/lib/tripper.rb +1 -0
  133. data/lib/tripper/GOSPLDB/config/database.yml +6 -0
  134. data/lib/tripper/GOSPLDB/config_db.rb +9 -0
  135. data/lib/tripper/GOSPLDB/console +2 -0
  136. data/lib/tripper/GOSPLDB/gospl_db_classes.rb +343 -0
  137. data/lib/tripper/GOSPLDB/play_around.rb +4 -0
  138. data/lib/tripper/GOSPLDB/rakefile.rb +88 -0
  139. data/lib/tripper/GOSPLDBToORMDB/gospl_db_to_orm_db.rb +88 -0
  140. data/lib/tripper/ORMDB/config/database.yml +6 -0
  141. data/lib/tripper/ORMDB/config_db.rb +9 -0
  142. data/lib/tripper/ORMDB/console +2 -0
  143. data/lib/tripper/ORMDB/db/migrations/0_create_orm_object_table.rb +17 -0
  144. data/lib/tripper/ORMDB/db/migrations/10_create_no_lot_constraint_table.rb +17 -0
  145. data/lib/tripper/ORMDB/db/migrations/11_create_value_constraint_table.rb +14 -0
  146. data/lib/tripper/ORMDB/db/migrations/12_create_value_constraint_value_table.rb +16 -0
  147. data/lib/tripper/ORMDB/db/migrations/13_create_value_range_table.rb +15 -0
  148. data/lib/tripper/ORMDB/db/migrations/14_create_frequency_constraint_table.rb +16 -0
  149. data/lib/tripper/ORMDB/db/migrations/15_create_value_table.rb +15 -0
  150. data/lib/tripper/ORMDB/db/migrations/16_create_ring_constraint_table.rb +14 -0
  151. data/lib/tripper/ORMDB/db/migrations/17_create_orm_schema_table.rb +21 -0
  152. data/lib/tripper/ORMDB/db/migrations/18_create_uniqueness_constraint_table.rb +15 -0
  153. data/lib/tripper/ORMDB/db/migrations/1_create_no_lot_table.rb +18 -0
  154. data/lib/tripper/ORMDB/db/migrations/2_create_lot_table.rb +18 -0
  155. data/lib/tripper/ORMDB/db/migrations/3_create_object_role_table.rb +18 -0
  156. data/lib/tripper/ORMDB/db/migrations/4_create_reference_table.rb +17 -0
  157. data/lib/tripper/ORMDB/db/migrations/5_create_predicate_table.rb +18 -0
  158. data/lib/tripper/ORMDB/db/migrations/6_create_object_role_constraint_table.rb +18 -0
  159. data/lib/tripper/ORMDB/db/migrations/7_create_subtype_table.rb +17 -0
  160. data/lib/tripper/ORMDB/db/migrations/8_create_mandatory_constraint_table.rb +15 -0
  161. data/lib/tripper/ORMDB/db/migrations/9_create_constraint_table.rb +15 -0
  162. data/lib/tripper/ORMDB/db/orm_ml.sqlite3 +0 -0
  163. data/lib/tripper/ORMDB/db/orm_ml.sqlite3.backup +0 -0
  164. data/lib/tripper/ORMDB/db/orm_ml.sqlite3.juli28-2013 +0 -0
  165. data/lib/tripper/ORMDB/db/orm_ml.sqlite3.old +0 -0
  166. data/lib/tripper/ORMDB/db/schema.rb +58 -0
  167. data/lib/tripper/ORMDB/erd.pdf +0 -0
  168. data/lib/tripper/ORMDB/migrate_db.rb +21 -0
  169. data/lib/tripper/ORMDB/orm_db_classes.rb +423 -0
  170. data/lib/tripper/ORMDB/populate.rb +4 -0
  171. data/lib/tripper/ORMDB/rakefile.rb +88 -0
  172. data/lib/tripper/model_parsers/attribute_parser/AttributeParser.g +50 -0
  173. data/lib/tripper/model_parsers/attribute_parser/AttributeParser.tokens +13 -0
  174. data/lib/tripper/model_parsers/attribute_parser/AttributeParserLexer.rb +538 -0
  175. data/lib/tripper/model_parsers/attribute_parser/AttributeParserParser.rb +412 -0
  176. data/lib/tripper/model_parsers/attribute_parser/playing_around.rb +14 -0
  177. data/lib/tripper/model_parsers/belongs_to/BelongsToParser.g +63 -0
  178. data/lib/tripper/model_parsers/belongs_to/BelongsToParser.tokens +21 -0
  179. data/lib/tripper/model_parsers/belongs_to/BelongsToParserLexer.rb +667 -0
  180. data/lib/tripper/model_parsers/belongs_to/BelongsToParserParser.rb +552 -0
  181. data/lib/tripper/model_parsers/belongs_to/playing_around.rb +9 -0
  182. data/lib/tripper/model_parsers/database_fields_parser/DatabaseFieldsParser.g +47 -0
  183. data/lib/tripper/model_parsers/database_fields_parser/DatabaseFieldsParser.tokens +14 -0
  184. data/lib/tripper/model_parsers/database_fields_parser/DatabaseFieldsParserLexer.rb +513 -0
  185. data/lib/tripper/model_parsers/database_fields_parser/DatabaseFieldsParserParser.rb +279 -0
  186. data/lib/tripper/model_parsers/database_fields_parser/playing_around.rb +14 -0
  187. data/lib/tripper/model_parsers/has_and_belongs_to_many/HasAndBelongsToManyParser.g +92 -0
  188. data/lib/tripper/model_parsers/has_and_belongs_to_many/HasAndBelongsToManyParser.tokens +25 -0
  189. data/lib/tripper/model_parsers/has_and_belongs_to_many/HasAndBelongsToManyParserLexer.rb +787 -0
  190. data/lib/tripper/model_parsers/has_and_belongs_to_many/HasAndBelongsToManyParserParser.rb +1024 -0
  191. data/lib/tripper/model_parsers/has_and_belongs_to_many/playing_around.rb +9 -0
  192. data/lib/tripper/model_parsers/has_many/HasManyParser.g +77 -0
  193. data/lib/tripper/model_parsers/has_many/HasManyParser.tokens +23 -0
  194. data/lib/tripper/model_parsers/has_many/HasManyParserLexer.rb +710 -0
  195. data/lib/tripper/model_parsers/has_many/HasManyParserParser.rb +788 -0
  196. data/lib/tripper/model_parsers/has_many/playing_around.rb +9 -0
  197. data/lib/tripper/model_parsers/has_one/HasOneParser.g +63 -0
  198. data/lib/tripper/model_parsers/has_one/HasOneParser.tokens +21 -0
  199. data/lib/tripper/model_parsers/has_one/HasOneParserLexer.rb +664 -0
  200. data/lib/tripper/model_parsers/has_one/HasOneParserParser.rb +552 -0
  201. data/lib/tripper/model_parsers/has_one/playing_around.rb +9 -0
  202. data/lib/tripper/model_parsers/validates/ValidatesParser.g +68 -0
  203. data/lib/tripper/model_parsers/validates/ValidatesParser.tokens +35 -0
  204. data/lib/tripper/model_parsers/validates/ValidatesParserLexer.rb +899 -0
  205. data/lib/tripper/model_parsers/validates/ValidatesParserParser.rb +869 -0
  206. data/lib/tripper/model_parsers/validates/playing_around.rb +9 -0
  207. data/lib/tripper/rails.rb +8 -0
  208. data/lib/tripper/version.rb +3 -0
  209. data/tripper.gemspec +33 -0
  210. metadata +408 -0
@@ -0,0 +1,412 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # /Users/rivmeche/Google Drive/vub/_Thesis/code/tripper/lib/tripper/model_parsers/attribute_parser/AttributeParser.g
4
+ # --
5
+ # Generated using ANTLR version: 3.2.1-SNAPSHOT Jul 31, 2010 19:34:52
6
+ # Ruby runtime library version: 1.8.11
7
+ # Input grammar file: /Users/rivmeche/Google Drive/vub/_Thesis/code/tripper/lib/tripper/model_parsers/attribute_parser/AttributeParser.g
8
+ # Generated at: 2013-05-05 11:42:33
9
+ #
10
+
11
+ # ~~~> start load path setup
12
+ this_directory = File.expand_path( File.dirname( __FILE__ ) )
13
+ $LOAD_PATH.unshift( this_directory ) unless $LOAD_PATH.include?( this_directory )
14
+
15
+ antlr_load_failed = proc do
16
+ load_path = $LOAD_PATH.map { |dir| ' - ' << dir }.join( $/ )
17
+ raise LoadError, <<-END.strip!
18
+
19
+ Failed to load the ANTLR3 runtime library (version 1.8.11):
20
+
21
+ Ensure the library has been installed on your system and is available
22
+ on the load path. If rubygems is available on your system, this can
23
+ be done with the command:
24
+
25
+ gem install antlr3
26
+
27
+ Current load path:
28
+ #{ load_path }
29
+
30
+ END
31
+ end
32
+
33
+ defined?( ANTLR3 ) or begin
34
+
35
+ # 1: try to load the ruby antlr3 runtime library from the system path
36
+ require 'antlr3'
37
+
38
+ rescue LoadError
39
+
40
+ # 2: try to load rubygems if it isn't already loaded
41
+ defined?( Gem ) or begin
42
+ require 'rubygems'
43
+ rescue LoadError
44
+ antlr_load_failed.call
45
+ end
46
+
47
+ # 3: try to activate the antlr3 gem
48
+ begin
49
+ Gem.activate( 'antlr3', '~> 1.8.11' )
50
+ rescue Gem::LoadError
51
+ antlr_load_failed.call
52
+ end
53
+
54
+ require 'antlr3'
55
+
56
+ end
57
+ # <~~~ end load path setup
58
+
59
+ # - - - - - - begin action @parser::header - - - - - -
60
+ # /Users/rivmeche/Google Drive/vub/_Thesis/code/tripper/lib/tripper/model_parsers/attribute_parser/AttributeParser.g
61
+
62
+
63
+ def strip_quotes str
64
+ return str[1,(str.length)-2]
65
+ end
66
+
67
+ # - - - - - - end action @parser::header - - - - - - -
68
+
69
+
70
+ module AttributeParser
71
+ # TokenData defines all of the token type integer values
72
+ # as constants, which will be included in all
73
+ # ANTLR-generated recognizers.
74
+ const_defined?( :TokenData ) or TokenData = ANTLR3::TokenScheme.new
75
+
76
+ module TokenData
77
+
78
+ # define the token constants
79
+ define_tokens( :ACTUALSTRING => 10, :HC => 6, :T__12 => 12, :T__11 => 11,
80
+ :T__13 => 13, :ATTRIBUTE => 5, :WHITESPACE => 9, :LC => 7,
81
+ :DIGIT => 8, :COMMENT => 4, :EOF => -1 )
82
+
83
+ # register the proper human-readable name or literal value
84
+ # for each token type
85
+ #
86
+ # this is necessary because anonymous tokens, which are
87
+ # created from literal values in the grammar, do not
88
+ # have descriptive names
89
+ register_names( "COMMENT", "ATTRIBUTE", "HC", "LC", "DIGIT", "WHITESPACE",
90
+ "ACTUALSTRING", "'attr_accessible'", "','", "':'" )
91
+
92
+ end
93
+
94
+
95
+ class Parser < ANTLR3::Parser
96
+ @grammar_home = AttributeParser
97
+
98
+ RULE_METHODS = [ :comment, :attr_accessible, :attributes, :attribute ].freeze
99
+
100
+
101
+ include TokenData
102
+
103
+ begin
104
+ generated_using( "/Users/rivmeche/Google Drive/vub/_Thesis/code/tripper/lib/tripper/model_parsers/attribute_parser/AttributeParser.g", "3.2.1-SNAPSHOT Jul 31, 2010 19:34:52", "1.8.11" )
105
+ rescue NoMethodError => error
106
+ # ignore
107
+ end
108
+
109
+ def initialize( input, options = {} )
110
+ super( input, options )
111
+
112
+
113
+ end
114
+
115
+ attr_accessor :attributes
116
+
117
+ # - - - - - - - - - - - - Rules - - - - - - - - - - - - -
118
+
119
+ #
120
+ # parser rule comment
121
+ #
122
+ # (in /Users/rivmeche/Google Drive/vub/_Thesis/code/tripper/lib/tripper/model_parsers/attribute_parser/AttributeParser.g)
123
+ # 15:1: comment : COMMENT ;
124
+ #
125
+ def comment
126
+ # -> uncomment the next line to manually enable rule tracing
127
+ # trace_in( __method__, 1 )
128
+
129
+ begin
130
+ # at line 15:10: COMMENT
131
+ match( COMMENT, TOKENS_FOLLOWING_COMMENT_IN_comment_34 )
132
+
133
+ rescue ANTLR3::Error::RecognitionError => re
134
+ report_error(re)
135
+ recover(re)
136
+
137
+ ensure
138
+ # -> uncomment the next line to manually enable rule tracing
139
+ # trace_out( __method__, 1 )
140
+
141
+ end
142
+
143
+ return
144
+ end
145
+
146
+
147
+ #
148
+ # parser rule attr_accessible
149
+ #
150
+ # (in /Users/rivmeche/Google Drive/vub/_Thesis/code/tripper/lib/tripper/model_parsers/attribute_parser/AttributeParser.g)
151
+ # 17:1: attr_accessible returns [expr] : ( (c= COMMENT )* | 'attr_accessible' ( attributes )* ( attribute )? ( comment )? ) ;
152
+ #
153
+ def attr_accessible
154
+ # -> uncomment the next line to manually enable rule tracing
155
+ # trace_in( __method__, 2 )
156
+ expr = nil
157
+ c = nil
158
+
159
+ begin
160
+ # at line 17:33: ( (c= COMMENT )* | 'attr_accessible' ( attributes )* ( attribute )? ( comment )? )
161
+ # at line 17:33: ( (c= COMMENT )* | 'attr_accessible' ( attributes )* ( attribute )? ( comment )? )
162
+ alt_5 = 2
163
+ look_5_0 = @input.peek( 1 )
164
+
165
+ if ( look_5_0 == EOF || look_5_0 == COMMENT )
166
+ alt_5 = 1
167
+ elsif ( look_5_0 == T__11 )
168
+ alt_5 = 2
169
+ else
170
+ raise NoViableAlternative( "", 5, 0 )
171
+ end
172
+ case alt_5
173
+ when 1
174
+ # at line 17:34: (c= COMMENT )*
175
+ # at line 17:34: (c= COMMENT )*
176
+ while true # decision 1
177
+ alt_1 = 2
178
+ look_1_0 = @input.peek( 1 )
179
+
180
+ if ( look_1_0 == COMMENT )
181
+ alt_1 = 1
182
+
183
+ end
184
+ case alt_1
185
+ when 1
186
+ # at line 17:35: c= COMMENT
187
+ c = match( COMMENT, TOKENS_FOLLOWING_COMMENT_IN_attr_accessible_49 )
188
+
189
+ else
190
+ break # out of loop for decision 1
191
+ end
192
+ end # loop for decision 1
193
+
194
+ when 2
195
+ # at line 17:49: 'attr_accessible' ( attributes )* ( attribute )? ( comment )?
196
+ match( T__11, TOKENS_FOLLOWING_T__11_IN_attr_accessible_55 )
197
+ # at line 17:67: ( attributes )*
198
+ while true # decision 2
199
+ alt_2 = 2
200
+ alt_2 = @dfa2.predict( @input )
201
+ case alt_2
202
+ when 1
203
+ # at line 17:67: attributes
204
+ @state.following.push( TOKENS_FOLLOWING_attributes_IN_attr_accessible_57 )
205
+ attributes
206
+ @state.following.pop
207
+
208
+ else
209
+ break # out of loop for decision 2
210
+ end
211
+ end # loop for decision 2
212
+ # at line 17:79: ( attribute )?
213
+ alt_3 = 2
214
+ look_3_0 = @input.peek( 1 )
215
+
216
+ if ( look_3_0 == T__13 )
217
+ alt_3 = 1
218
+ end
219
+ case alt_3
220
+ when 1
221
+ # at line 17:79: attribute
222
+ @state.following.push( TOKENS_FOLLOWING_attribute_IN_attr_accessible_60 )
223
+ attribute
224
+ @state.following.pop
225
+
226
+ end
227
+ # at line 17:90: ( comment )?
228
+ alt_4 = 2
229
+ look_4_0 = @input.peek( 1 )
230
+
231
+ if ( look_4_0 == COMMENT )
232
+ alt_4 = 1
233
+ end
234
+ case alt_4
235
+ when 1
236
+ # at line 17:90: comment
237
+ @state.following.push( TOKENS_FOLLOWING_comment_IN_attr_accessible_63 )
238
+ comment
239
+ @state.following.pop
240
+
241
+ end
242
+
243
+ end
244
+ # --> action
245
+
246
+ @attributes = [] unless @attributes
247
+ expr = @attributes
248
+
249
+ # <-- action
250
+
251
+ rescue ANTLR3::Error::RecognitionError => re
252
+ report_error(re)
253
+ recover(re)
254
+
255
+ ensure
256
+ # -> uncomment the next line to manually enable rule tracing
257
+ # trace_out( __method__, 2 )
258
+
259
+ end
260
+
261
+ return expr
262
+ end
263
+
264
+
265
+ #
266
+ # parser rule attributes
267
+ #
268
+ # (in /Users/rivmeche/Google Drive/vub/_Thesis/code/tripper/lib/tripper/model_parsers/attribute_parser/AttributeParser.g)
269
+ # 24:1: attributes : attribute ',' ;
270
+ #
271
+ def attributes
272
+ # -> uncomment the next line to manually enable rule tracing
273
+ # trace_in( __method__, 3 )
274
+
275
+ begin
276
+ # at line 24:13: attribute ','
277
+ @state.following.push( TOKENS_FOLLOWING_attribute_IN_attributes_75 )
278
+ attribute
279
+ @state.following.pop
280
+ match( T__12, TOKENS_FOLLOWING_T__12_IN_attributes_77 )
281
+
282
+ rescue ANTLR3::Error::RecognitionError => re
283
+ report_error(re)
284
+ recover(re)
285
+
286
+ ensure
287
+ # -> uncomment the next line to manually enable rule tracing
288
+ # trace_out( __method__, 3 )
289
+
290
+ end
291
+
292
+ return
293
+ end
294
+
295
+
296
+ #
297
+ # parser rule attribute
298
+ #
299
+ # (in /Users/rivmeche/Google Drive/vub/_Thesis/code/tripper/lib/tripper/model_parsers/attribute_parser/AttributeParser.g)
300
+ # 27:1: attribute : ( ':' )+ a= ATTRIBUTE ;
301
+ #
302
+ def attribute
303
+ # -> uncomment the next line to manually enable rule tracing
304
+ # trace_in( __method__, 4 )
305
+ a = nil
306
+
307
+ begin
308
+ # at line 28:4: ( ':' )+ a= ATTRIBUTE
309
+ # at file 28:4: ( ':' )+
310
+ match_count_6 = 0
311
+ while true
312
+ alt_6 = 2
313
+ look_6_0 = @input.peek( 1 )
314
+
315
+ if ( look_6_0 == T__13 )
316
+ alt_6 = 1
317
+
318
+ end
319
+ case alt_6
320
+ when 1
321
+ # at line 28:5: ':'
322
+ match( T__13, TOKENS_FOLLOWING_T__13_IN_attribute_88 )
323
+
324
+ else
325
+ match_count_6 > 0 and break
326
+ eee = EarlyExit(6)
327
+
328
+
329
+ raise eee
330
+ end
331
+ match_count_6 += 1
332
+ end
333
+
334
+ a = match( ATTRIBUTE, TOKENS_FOLLOWING_ATTRIBUTE_IN_attribute_94 )
335
+ # --> action
336
+
337
+ @attributes = [] unless @attributes
338
+ @attributes << a.text
339
+
340
+ # <-- action
341
+
342
+ rescue ANTLR3::Error::RecognitionError => re
343
+ report_error(re)
344
+ recover(re)
345
+
346
+ ensure
347
+ # -> uncomment the next line to manually enable rule tracing
348
+ # trace_out( __method__, 4 )
349
+
350
+ end
351
+
352
+ return
353
+ end
354
+
355
+
356
+
357
+ # - - - - - - - - - - DFA definitions - - - - - - - - - - -
358
+ class DFA2 < ANTLR3::DFA
359
+ EOT = unpack( 5, -1 )
360
+ EOF = unpack( 1, 2, 2, -1, 1, 2, 1, -1 )
361
+ MIN = unpack( 1, 4, 1, 5, 1, -1, 1, 4, 1, -1 )
362
+ MAX = unpack( 2, 13, 1, -1, 1, 12, 1, -1 )
363
+ ACCEPT = unpack( 2, -1, 1, 2, 1, -1, 1, 1 )
364
+ SPECIAL = unpack( 5, -1 )
365
+ TRANSITION = [
366
+ unpack( 1, 2, 8, -1, 1, 1 ),
367
+ unpack( 1, 3, 7, -1, 1, 1 ),
368
+ unpack( ),
369
+ unpack( 1, 2, 7, -1, 1, 4 ),
370
+ unpack( )
371
+ ].freeze
372
+
373
+ ( 0 ... MIN.length ).zip( MIN, MAX ) do | i, a, z |
374
+ if a > 0 and z < 0
375
+ MAX[ i ] %= 0x10000
376
+ end
377
+ end
378
+
379
+ @decision = 2
380
+
381
+
382
+ def description
383
+ <<-'__dfa_description__'.strip!
384
+ ()* loopback of 17:67: ( attributes )*
385
+ __dfa_description__
386
+ end
387
+ end
388
+
389
+
390
+ private
391
+
392
+ def initialize_dfas
393
+ super rescue nil
394
+ @dfa2 = DFA2.new( self, 2 )
395
+
396
+ end
397
+ TOKENS_FOLLOWING_COMMENT_IN_comment_34 = Set[ 1 ]
398
+ TOKENS_FOLLOWING_COMMENT_IN_attr_accessible_49 = Set[ 1, 4 ]
399
+ TOKENS_FOLLOWING_T__11_IN_attr_accessible_55 = Set[ 1, 4, 13 ]
400
+ TOKENS_FOLLOWING_attributes_IN_attr_accessible_57 = Set[ 1, 4, 13 ]
401
+ TOKENS_FOLLOWING_attribute_IN_attr_accessible_60 = Set[ 1, 4 ]
402
+ TOKENS_FOLLOWING_comment_IN_attr_accessible_63 = Set[ 1 ]
403
+ TOKENS_FOLLOWING_attribute_IN_attributes_75 = Set[ 12 ]
404
+ TOKENS_FOLLOWING_T__12_IN_attributes_77 = Set[ 1 ]
405
+ TOKENS_FOLLOWING_T__13_IN_attribute_88 = Set[ 5, 13 ]
406
+ TOKENS_FOLLOWING_ATTRIBUTE_IN_attribute_94 = Set[ 1 ]
407
+
408
+ end # class Parser < ANTLR3::Parser
409
+
410
+ at_exit { Parser.main( ARGV ) } if __FILE__ == $0
411
+ end
412
+
@@ -0,0 +1,14 @@
1
+ require './AttributeParserParser'
2
+ require './AttributeParserLexer'
3
+ # input = ANTLR3::StringStream.new( "attr_accessible :hour, :minute, :second" )
4
+ # lexer = AttributeParser::Lexer.new(input)
5
+ # tokens = ANTLR3::CommonTokenStream.new(lexer)
6
+ parser = AttributeParser::Parser.new("attr_accessible :hour, :minute, :second")
7
+ a= parser.attr_accessible
8
+ puts a
9
+ # input = ANTLR3::StringStream.new( "attr_accessible :tes, :bla, :blo" )
10
+ # lexer = AttributeParser::Lexer.new(input)
11
+ # tokens = ANTLR3::CommonTokenStream.new(lexer)
12
+ parser = AttributeParser::Parser.new("attr_accessible :tes, :bla, :blo")
13
+ a= parser.attr_accessible
14
+ puts a
@@ -0,0 +1,63 @@
1
+ grammar BelongsToParser;
2
+
3
+ options {
4
+ language = Ruby;
5
+ }
6
+
7
+ @header {
8
+ def strip_quotes str
9
+ return str[1,(str.length)-2]
10
+ end
11
+
12
+ @@attribute = nil
13
+ @@class_name = nil
14
+ }
15
+
16
+ @members {
17
+ attr_accessor :attribute, :class_name
18
+ }
19
+
20
+ comment: COMMENT;
21
+
22
+ belongs_to returns [expr]: ((c=COMMENT)* | 'belongs_to' attribute class_name? comment?)
23
+ {
24
+ $expr = {attribute: @attribute, class_name: @class_name} unless $c
25
+ }
26
+ ;
27
+
28
+ class_name: ',' (class_name_old_syntax | class_name_new_syntax);
29
+
30
+ class_name_old_syntax: ':' 'class_name' '=>' class_name_word
31
+ ;
32
+
33
+ class_name_word: (('\'' a=ATTRIBUTE '\'') | ('"' a=ATTRIBUTE '"') | (':' a=ATTRIBUTE))
34
+ {
35
+ @class_name = $a.text
36
+ }
37
+ ;
38
+
39
+ class_name_new_syntax: 'class_name' ':' class_name_word;
40
+
41
+
42
+ attribute: ('\'' a=ATTRIBUTE '\'') | ('"' a=ATTRIBUTE '"') | (':' a=ATTRIBUTE)
43
+ {
44
+ @attribute = $a.text
45
+ }
46
+ ;
47
+
48
+ //string: STRING;
49
+
50
+ /*------------------------------------------------------------------
51
+ * LEXER RULES
52
+ *------------------------------------------------------------------*/
53
+ //LITERAL: (HC|LC)(HC|LC|'_')*;
54
+ ATTRIBUTE: (HC|LC)(HC|LC|DIGIT|'_')*;
55
+ //LITERAL: (HC|LC)(HC|LC|DIGIT|'_'|'-')*;
56
+ //NUMERICCONSTANT: ('-')? DIGIT+ ('.' DIGIT+)?;
57
+ //STRING: '\'' ACTUALSTRING '\'';
58
+ WHITESPACE: ( '\t' | ' ' | '\r' | '\n'| '\u000C' )+ { $channel = HIDDEN; };
59
+ COMMENT: '#' ~('\n'|'\r')*;
60
+ fragment ACTUALSTRING: ~('\\'|'\'')*;
61
+ fragment DIGIT: '0'..'9';
62
+ fragment HC: 'A'..'Z';
63
+ fragment LC: 'a'..'z';