activefacts 1.6.0 → 1.7.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (169) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +14 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +4 -0
  5. data/Gemfile +14 -0
  6. data/LICENSE.txt +21 -0
  7. data/README.md +60 -0
  8. data/Rakefile +3 -80
  9. data/activefacts.gemspec +36 -0
  10. data/bin/afgen +4 -2
  11. data/bin/cql +5 -1
  12. data/lib/activefacts.rb +3 -12
  13. data/lib/activefacts/{vocabulary/query_evaluator.rb → query/evaluator.rb} +0 -0
  14. data/lib/activefacts/version.rb +2 -2
  15. metadata +48 -296
  16. data/History.txt +0 -4
  17. data/LICENSE +0 -19
  18. data/Manifest.txt +0 -165
  19. data/README.rdoc +0 -81
  20. data/css/offline.css +0 -3
  21. data/css/orm2.css +0 -124
  22. data/css/print.css +0 -8
  23. data/css/style-print.css +0 -357
  24. data/css/style.css +0 -387
  25. data/download.html +0 -110
  26. data/examples/CQL/Address.cql +0 -44
  27. data/examples/CQL/Blog.cql +0 -54
  28. data/examples/CQL/CompanyDirectorEmployee.cql +0 -56
  29. data/examples/CQL/Death.cql +0 -17
  30. data/examples/CQL/Diplomacy.cql +0 -48
  31. data/examples/CQL/Genealogy.cql +0 -98
  32. data/examples/CQL/Insurance.cql +0 -320
  33. data/examples/CQL/Marriage.cql +0 -18
  34. data/examples/CQL/Metamodel.cql +0 -493
  35. data/examples/CQL/Monogamy.cql +0 -24
  36. data/examples/CQL/MultiInheritance.cql +0 -22
  37. data/examples/CQL/NonRoleId.cql +0 -14
  38. data/examples/CQL/OddIdentifier.cql +0 -18
  39. data/examples/CQL/OilSupply.cql +0 -53
  40. data/examples/CQL/OneToOnes.cql +0 -17
  41. data/examples/CQL/Orienteering.cql +0 -111
  42. data/examples/CQL/PersonPlaysGame.cql +0 -18
  43. data/examples/CQL/RedundantDependency.cql +0 -34
  44. data/examples/CQL/SchoolActivities.cql +0 -33
  45. data/examples/CQL/SeparateSubtype.cql +0 -30
  46. data/examples/CQL/ServiceDirector.cql +0 -276
  47. data/examples/CQL/SimplestUnary.cql +0 -12
  48. data/examples/CQL/Supervision.cql +0 -34
  49. data/examples/CQL/WaiterTips.cql +0 -33
  50. data/examples/CQL/Warehousing.cql +0 -101
  51. data/examples/CQL/WindowInRoomInBldg.cql +0 -28
  52. data/examples/CQL/unit.cql +0 -474
  53. data/examples/index.html +0 -420
  54. data/examples/intro.html +0 -327
  55. data/examples/local.css +0 -24
  56. data/index.html +0 -111
  57. data/lib/activefacts/cql.rb +0 -35
  58. data/lib/activefacts/cql/CQLParser.treetop +0 -158
  59. data/lib/activefacts/cql/Context.treetop +0 -48
  60. data/lib/activefacts/cql/Expressions.treetop +0 -67
  61. data/lib/activefacts/cql/FactTypes.treetop +0 -358
  62. data/lib/activefacts/cql/Language/English.treetop +0 -315
  63. data/lib/activefacts/cql/LexicalRules.treetop +0 -253
  64. data/lib/activefacts/cql/ObjectTypes.treetop +0 -210
  65. data/lib/activefacts/cql/Rakefile +0 -14
  66. data/lib/activefacts/cql/Terms.treetop +0 -183
  67. data/lib/activefacts/cql/ValueTypes.treetop +0 -202
  68. data/lib/activefacts/cql/compiler.rb +0 -156
  69. data/lib/activefacts/cql/compiler/clause.rb +0 -1137
  70. data/lib/activefacts/cql/compiler/constraint.rb +0 -581
  71. data/lib/activefacts/cql/compiler/entity_type.rb +0 -457
  72. data/lib/activefacts/cql/compiler/expression.rb +0 -443
  73. data/lib/activefacts/cql/compiler/fact.rb +0 -390
  74. data/lib/activefacts/cql/compiler/fact_type.rb +0 -421
  75. data/lib/activefacts/cql/compiler/query.rb +0 -106
  76. data/lib/activefacts/cql/compiler/shared.rb +0 -161
  77. data/lib/activefacts/cql/compiler/value_type.rb +0 -174
  78. data/lib/activefacts/cql/nodes.rb +0 -49
  79. data/lib/activefacts/cql/parser.rb +0 -241
  80. data/lib/activefacts/dependency_analyser.rb +0 -182
  81. data/lib/activefacts/generate/absorption.rb +0 -70
  82. data/lib/activefacts/generate/composition.rb +0 -118
  83. data/lib/activefacts/generate/cql.rb +0 -714
  84. data/lib/activefacts/generate/dm.rb +0 -279
  85. data/lib/activefacts/generate/help.rb +0 -64
  86. data/lib/activefacts/generate/helpers/inject.rb +0 -16
  87. data/lib/activefacts/generate/helpers/oo.rb +0 -162
  88. data/lib/activefacts/generate/helpers/ordered.rb +0 -605
  89. data/lib/activefacts/generate/helpers/rails.rb +0 -57
  90. data/lib/activefacts/generate/html/glossary.rb +0 -461
  91. data/lib/activefacts/generate/json.rb +0 -337
  92. data/lib/activefacts/generate/null.rb +0 -32
  93. data/lib/activefacts/generate/rails/models.rb +0 -246
  94. data/lib/activefacts/generate/rails/schema.rb +0 -216
  95. data/lib/activefacts/generate/records.rb +0 -46
  96. data/lib/activefacts/generate/ruby.rb +0 -133
  97. data/lib/activefacts/generate/sql/mysql.rb +0 -280
  98. data/lib/activefacts/generate/sql/server.rb +0 -273
  99. data/lib/activefacts/generate/stats.rb +0 -69
  100. data/lib/activefacts/generate/text.rb +0 -27
  101. data/lib/activefacts/generate/topics.rb +0 -265
  102. data/lib/activefacts/generate/traits/datavault.rb +0 -241
  103. data/lib/activefacts/generate/traits/oo.rb +0 -73
  104. data/lib/activefacts/generate/traits/ordered.rb +0 -33
  105. data/lib/activefacts/generate/traits/ruby.rb +0 -210
  106. data/lib/activefacts/generate/transform/datavault.rb +0 -266
  107. data/lib/activefacts/generate/transform/surrogate.rb +0 -214
  108. data/lib/activefacts/generate/version.rb +0 -26
  109. data/lib/activefacts/input/cql.rb +0 -43
  110. data/lib/activefacts/input/orm.rb +0 -1636
  111. data/lib/activefacts/mapping/rails.rb +0 -132
  112. data/lib/activefacts/persistence.rb +0 -15
  113. data/lib/activefacts/persistence/columns.rb +0 -446
  114. data/lib/activefacts/persistence/foreignkey.rb +0 -187
  115. data/lib/activefacts/persistence/index.rb +0 -240
  116. data/lib/activefacts/persistence/object_type.rb +0 -198
  117. data/lib/activefacts/persistence/reference.rb +0 -434
  118. data/lib/activefacts/persistence/tables.rb +0 -380
  119. data/lib/activefacts/registry.rb +0 -11
  120. data/lib/activefacts/support.rb +0 -132
  121. data/lib/activefacts/vocabulary.rb +0 -9
  122. data/lib/activefacts/vocabulary/extensions.rb +0 -1348
  123. data/lib/activefacts/vocabulary/metamodel.rb +0 -570
  124. data/lib/activefacts/vocabulary/verbaliser.rb +0 -804
  125. data/script/txt2html +0 -71
  126. data/spec/absorption_spec.rb +0 -95
  127. data/spec/cql/comparison_spec.rb +0 -89
  128. data/spec/cql/context_spec.rb +0 -94
  129. data/spec/cql/contractions_spec.rb +0 -224
  130. data/spec/cql/deontic_spec.rb +0 -88
  131. data/spec/cql/entity_type_spec.rb +0 -320
  132. data/spec/cql/expressions_spec.rb +0 -66
  133. data/spec/cql/fact_type_matching_spec.rb +0 -338
  134. data/spec/cql/french_spec.rb +0 -21
  135. data/spec/cql/parser/bad_literals_spec.rb +0 -86
  136. data/spec/cql/parser/constraints_spec.rb +0 -19
  137. data/spec/cql/parser/entity_types_spec.rb +0 -106
  138. data/spec/cql/parser/expressions_spec.rb +0 -199
  139. data/spec/cql/parser/fact_types_spec.rb +0 -44
  140. data/spec/cql/parser/literals_spec.rb +0 -312
  141. data/spec/cql/parser/pragmas_spec.rb +0 -89
  142. data/spec/cql/parser/value_types_spec.rb +0 -42
  143. data/spec/cql/role_matching_spec.rb +0 -148
  144. data/spec/cql/samples_spec.rb +0 -244
  145. data/spec/cql_cql_spec.rb +0 -73
  146. data/spec/cql_dm_spec.rb +0 -136
  147. data/spec/cql_mysql_spec.rb +0 -69
  148. data/spec/cql_parse_spec.rb +0 -34
  149. data/spec/cql_ruby_spec.rb +0 -73
  150. data/spec/cql_sql_spec.rb +0 -72
  151. data/spec/cql_symbol_tables_spec.rb +0 -261
  152. data/spec/cqldump_spec.rb +0 -170
  153. data/spec/helpers/array_matcher.rb +0 -23
  154. data/spec/helpers/ctrl_c_support.rb +0 -52
  155. data/spec/helpers/diff_matcher.rb +0 -39
  156. data/spec/helpers/file_matcher.rb +0 -34
  157. data/spec/helpers/parse_to_ast_matcher.rb +0 -80
  158. data/spec/helpers/string_matcher.rb +0 -30
  159. data/spec/helpers/test_parser.rb +0 -15
  160. data/spec/norma_cql_spec.rb +0 -66
  161. data/spec/norma_ruby_spec.rb +0 -62
  162. data/spec/norma_ruby_sql_spec.rb +0 -107
  163. data/spec/norma_sql_spec.rb +0 -57
  164. data/spec/norma_tables_spec.rb +0 -95
  165. data/spec/ruby_api_spec.rb +0 -23
  166. data/spec/spec_helper.rb +0 -35
  167. data/spec/transform_surrogate_spec.rb +0 -59
  168. data/status.html +0 -138
  169. data/why.html +0 -60
@@ -1,24 +0,0 @@
1
- @charset "utf-8";
2
-
3
- .offline {
4
- display: none;
5
- }
6
-
7
- .localnav {
8
- position:fixed;
9
- left:25px;
10
- top:210px;
11
- }
12
-
13
- .hangleft {
14
- margin-left: -220px;
15
- }
16
-
17
- table.examples { border: 6px solid #e5f0f0; box-shadow: 0px 2px 5px black; -webkit-box-shadow: 1px 1px 5px black; -moz-box-shadow: 0px 2px 5px black; border-radius:0.8em; -webkit-border-radius:0.8em; -moz-border-radius:0.8em; border-collapse: separate; border-spacing: 0; }
18
- .examples td { vertical-align: top; padding: 8px 5px 8px 5px; }
19
- .examples td a:link { font-size: 0.78em; }
20
- .examples td.title span { font-size: 1.3em; }
21
- .examples td.title > a { font-weight:bold; padding: 0px 30px 0px 0px; }
22
- .examples .diagrams a { display: block; padding: 0px 0px 0px 0px; }
23
- .even { background: #e5f8f9; }
24
- .odd { }
data/index.html DELETED
@@ -1,111 +0,0 @@
1
- <!--#include virtual="/header.html" -->
2
- <!--#include virtual="navbar.html" -->
3
-
4
- <link rel="stylesheet" href="css/offline.css" media="screen" type="text/css" />
5
- <link rel="stylesheet" href="css/print.css" media="print" type="text/css" />
6
-
7
- <!-- Things to show only in the online version -->
8
- <div id="sidebar" class="online">
9
- <h3>Quotes</h3>
10
-
11
- <p><em>&ldquo;You have to get this out there, it will change <b>almost everything</b>
12
- that <b>all</b> of us actually <b>do</b>&rdquo;</em></p>
13
- <p align="right">Mark Mansour,<br>Agile Alliance Australia</p>
14
-
15
- <!--p><em>&ldquo;I've long believed there must be a way to do this, but could never
16
- work out how to start.&rdquo;</em></p>
17
- <p align="right">OSDC conference attendee</p-->
18
-
19
- <p><em>&ldquo;Epic, a major achievement. Your approach is so far ahead of the
20
- industry it's hard to believe it possible.&rdquo;</em></p>
21
- <p align="right">Richard P,<br>OSDC conference attendee</p-->
22
-
23
- <!--p><em>&ldquo;Inspirational!&rdquo;</em></p>
24
- <p align="right">Sven Dowideit</p-->
25
-
26
- </div>
27
-
28
- <div id="top" class="content">
29
- <h2>ActiveFacts</h2>
30
-
31
- <!-- Things to show only in the offline version -->
32
- <div class="localnav offline noprint">
33
- <ul>
34
- <li><a href="http://dataconstellation.com" title="Data Constellation Home">Data Constellation</a></li>
35
- <li><a href="http://dataconstellation.com/ActiveFacts" title="ActiveFacts Home Page">ActiveFacts Home</a></li>
36
- <li><a href="examples/index.html" title="Example Models">Example Models</a></li>
37
- <li><a href="examples/intro.html" title="Introduction to ORM2">Introduction to ORM2</a></li>
38
- <li><a href="http://dataconstellation.com/ActiveFacts/CQLIntroduction.html" title="The Constellation Query Language">Constellation Query Language</a></li>
39
- <li><a href="status.html" title="Project Status">Project Status</a></li>
40
- <li><a href="download.html" title="Download">Download</a></li>
41
- <!--li><a href="resources.html" title="Resources">Resources</a></li-->
42
- </ul>
43
- </div>
44
-
45
- <p>
46
- ActiveFacts is a <strong>semantic modeling toolkit</strong> that
47
- revolutionises the processes of software <strong>specification</strong>,
48
- <strong>design</strong>, and <strong>implementation</strong>. It
49
- incorporates the Constellation Query Language (CQL) and the Constellation
50
- API, which together enable your data to be designed, expressed and
51
- queried in a completely natural form for the first time. The language
52
- is so easy to learn and use because of the way it incorporates natural
53
- language expressions into a formal framework. This allows the business
54
- user (in conjunction with the programmer and database experts) to use
55
- the language to express the rules and behaviour of the business domain,
56
- in the process formulating efficient database designs without needing
57
- specialist database skills.
58
-
59
- <h3> Constellation Query Language </h3>
60
-
61
- <p> CQL achieves the seemingly impossible task of combining the
62
- precision of a <strong>formal</strong> language with the
63
- intuitive feel of natural language. It can be used both to
64
- define and query semantic models. You can write CQL models
65
- directly, use APRIMO, or import <a href="examples/intro.html"
66
- >ORM2</a> models from <a
67
- href="http://www.ormfoundation.org/files/">NORMA</a>. See
68
- some <a href="examples/">example</a> models, or read the <a
69
- href="CQLIntroduction.html">specification</a>.
70
- </p>
71
-
72
- <h3> Constellation API </h3>
73
- <p> The Constellation API goes beyond object-oriented to
74
- fact-oriented programming, introducing a new way to code
75
- transactional applications. A Constellation of related facts
76
- derived from a query can be modified only by <em>assert</em>
77
- and <em>retract</em> operations. The result is translated
78
- back to relational form and saved on demand.
79
- </p>
80
-
81
- <p>
82
- In the preferred case, each user action results in a
83
- single query, which can span deeply into and across the
84
- whole database (more than just a relational join),
85
- returning only the data required to respond to that action.
86
- Any required changes are made to the result Constellation,
87
- and a single <em>save</em> operation pushes all the changes
88
- resulting from the user's action back into the database in
89
- a single atomic action.
90
- </p>
91
-
92
- <h3> Code generators </h3>
93
- <p> The ActiveFacts code generation framework reads CQL
94
- and emits extensible and effective object models for
95
- use with the Constellation API, and efficient SQL
96
- for whatever relational database product you're using.
97
- Learn to write CQL and have a play with the open source
98
- <a href="download.html">Ruby code generator</a>.
99
- </p>
100
-
101
- <h3> APRIMO </h3>
102
- <p> APRIMO is a semantic model development environment,
103
- incorporating a Flash-based graphical designer that
104
- implements ORM2 diagrams, with direct CQL entry and
105
- even reverse engineering tools for existing databases.
106
- APRIMO is not yet publicly available.
107
- </p>
108
-
109
- </div>
110
-
111
- <!--#include virtual="/footer.html" -->
@@ -1,35 +0,0 @@
1
- #
2
- # ActiveFacts CQL loader.
3
- # Use Polyglot to patch things so you can *require* a CQL file and have it define a Ruby module.
4
- #
5
- # Copyright (c) 2009 Clifford Heath. Read the LICENSE file.
6
- #
7
- require 'rubygems'
8
- require 'polyglot'
9
- require 'stringio'
10
- require 'activefacts/support'
11
- require 'activefacts/input/cql'
12
- require 'activefacts/generate/ruby'
13
-
14
- module ActiveFacts
15
- # This class has a load method for Polyglot to tell it how to _require_ a CQL file.
16
- # The CQL file is parsed to a vocabulary constellation, which is generated
17
- # to Ruby code and eval'd, making the generated classes available.
18
- # To make this Loader available, simply
19
- # require 'activefacts/cql'
20
- class CQLLoader
21
- def self.load(file) #:nodoc:
22
- trace "Loading #{file}" do
23
- vocabulary = ActiveFacts::Input::CQL.readfile(file)
24
-
25
- ruby = StringIO.new
26
- @dumper = ActiveFacts::Generate::RUBY.new(vocabulary.constellation)
27
- @dumper.generate(ruby)
28
- ruby.rewind
29
- eval ruby.read, ::TOPLEVEL_BINDING
30
- end
31
- end
32
- end
33
-
34
- Polyglot.register('cql', CQLLoader)
35
- end
@@ -1,158 +0,0 @@
1
- #
2
- # ActiveFacts CQL Parser.
3
- # Parse rules relating to high-level CQL definitions and constraints.
4
- #
5
- # Copyright (c) 2009 Clifford Heath. Read the LICENSE file.
6
- #
7
- module ActiveFacts
8
- module CQL
9
- grammar CQL
10
- include LexicalRules
11
- include Expressions
12
- include Terms
13
- include ObjectTypes
14
- include ValueTypes
15
- include FactTypes
16
- include Context
17
-
18
- rule cql_file
19
- s seq:definition*
20
- {
21
- def definitions
22
- seq.elements.map{|e|
23
- e.value rescue $stderr.puts "Can't call value() on #{e.inspect}"
24
- }
25
- end
26
- }
27
- end
28
-
29
- # Each definition has an ast() method that returns an instance of a subclass of Compiler::Definition
30
- rule definition
31
- definition_body s
32
- {
33
- def ast
34
- definition_body.ast
35
- end
36
-
37
- def body
38
- definition_body.text_value
39
- end
40
- }
41
- end
42
-
43
- rule definition_body
44
- vocabulary_definition
45
- / import_definition
46
- / prescan # Always fails, but its side-effects are needed in the following
47
- / constraint
48
- / unit_definition # REVISIT: Move this above the prescan?
49
- / object_type
50
- / query
51
- / s ';' s { def ast; nil; end }
52
- end
53
-
54
- rule vocabulary_definition
55
- s vocabulary S vocabulary_name s ';'
56
- {
57
- def ast
58
- Compiler::Vocabulary.new(vocabulary_name.value)
59
- end
60
- }
61
- end
62
-
63
- rule vocabulary_name
64
- id
65
- { def node_type; :vocabulary; end }
66
- end
67
-
68
- rule import_definition
69
- s import S vocabulary_name alias_list ';'
70
- {
71
- def ast
72
- Compiler::Import.new(import.input.parser, vocabulary_name.value, alias_list.value)
73
- end
74
- }
75
- end
76
-
77
- # REVISIT: Need a way to define equivalent readings for fact types here (and in the metamodel)
78
- rule alias_list
79
- ( s ',' s alias S aliased_from:alias_term S as S alias_to:alias_term s )*
80
- {
81
- def value
82
- elements.inject({}){|h, e| h[e.aliased_from.value] = e.alias_to; h }
83
- end
84
- }
85
- end
86
-
87
- rule alias_term
88
- id
89
- { def node_type; :term; end }
90
- end
91
-
92
- rule constraint
93
- subset_constraint /
94
- equality_constraint /
95
- set_constraint /
96
- presence_constraint
97
- # REVISIT: / value_constraint
98
- end
99
-
100
- rule enforcement
101
- s '(' s otherwise s action s a:agent? s ')' s
102
- {
103
- def ast; Compiler::Enforcement.new(action.text_value, a.empty? ? nil : a.text_value); end
104
- }
105
- /
106
- ''
107
- {
108
- def ast; nil; end
109
- }
110
- end
111
-
112
- # An enforcement action, like SMS, email, log, alarm, etc.
113
- rule action
114
- id
115
- end
116
-
117
- # presence constraint:
118
- rule presence_constraint
119
- (each_occurs_in_clauses / either_or)
120
- {
121
- def ast
122
- Compiler::PresenceConstraint.new c, enforcement.ast, clauses_ast, role_list_ast, quantifier_ast
123
- end
124
- }
125
- end
126
-
127
- # set (exclusion, mandatory exclusion, complex equality) constraint
128
- rule set_constraint
129
- (for_each_how_many / either_or_not_both)
130
- {
131
- def ast
132
- Compiler::SetExclusionConstraint.new c, enforcement.ast, clauses_ast, role_list_ast, quantifier_ast
133
- end
134
- }
135
- end
136
-
137
- rule subset_constraint
138
- (a_only_if_b / if_b_then_a)
139
- {
140
- def ast
141
- Compiler::SubsetConstraint.new c, enforcement.ast, [clauses.ast, r2.ast]
142
- end
143
- }
144
- end
145
-
146
- rule equality_constraint
147
- if_and_only_if
148
- {
149
- def ast
150
- all_clauses = [clauses.ast, *tail.elements.map{|e| e.clauses.ast }]
151
- Compiler::SetEqualityConstraint.new c, enforcement.ast, all_clauses
152
- end
153
- }
154
- end
155
-
156
- end
157
- end
158
- end
@@ -1,48 +0,0 @@
1
- #
2
- # ActiveFacts CQL Parser.
3
- # Parse rules relating to definition context.
4
- #
5
- # Copyright (c) 2009 Clifford Heath. Read the LICENSE file.
6
- #
7
- module ActiveFacts
8
- module CQL
9
- grammar Context
10
- rule context_note
11
- '('
12
- s w:who_says? s context_type discussion agreed:(',' a:as_agreed_by)? s
13
- ')' s
14
- {
15
- def value
16
- [ w.empty? ? nil : w.value, context_type.value, discussion.text_value, agreed.empty? ? [] : agreed.a.value]
17
- end
18
- def ast
19
- who = w.empty? ? nil : w.value
20
- ag = agreed.empty? ? [] : agreed.a.value
21
- Compiler::ContextNote.new context_type.value, discussion.text_value, who, ag
22
- end
23
- }
24
- end
25
-
26
- rule who_says
27
- according_to agents s ','
28
- { def value; agents.value; end }
29
- end
30
-
31
- rule context_type
32
- because s { def value; 'because'; end } /
33
- as_opposed_to { def value; 'as_opposed_to'; end } /
34
- so_that { def value; 'so_that'; end } /
35
- to_avoid { def value; 'to_avoid'; end }
36
- end
37
-
38
- rule discussion
39
- (
40
- '(' discussion ')' / (!( [()] / ',' as_agreed_by) .)*
41
- )
42
- {
43
- def node_type; :linking; end
44
- }
45
- end
46
- end
47
- end
48
- end
@@ -1,67 +0,0 @@
1
- #
2
- # ActiveFacts CQL Parser.
3
- # Parse rules relating to Expressions
4
- #
5
- # Copyright (c) 2009 Clifford Heath. Read the LICENSE file.
6
- #
7
- module ActiveFacts
8
- module CQL
9
- grammar Expressions
10
- rule expression
11
- sum
12
- end
13
-
14
- rule sum
15
- t0:product s tail:( op:add_op s t1:product s )*
16
- {
17
- def ast
18
- if tail.elements.empty?
19
- t0.ast
20
- else
21
- Compiler::Sum.new(t0.ast, *tail.elements.map{|e| e.op.text_value == '-' ? Compiler::Negate.new(e.t1.ast) : e.t1.ast})
22
- end
23
- end
24
- }
25
- end
26
-
27
- rule add_op
28
- '+' / '-'
29
- end
30
-
31
- rule product
32
- f0:factor s tail:( op:mul_op s f1:factor s )*
33
- {
34
- def ast
35
- if tail.elements.empty?
36
- f0.ast
37
- else
38
- Compiler::Product.new(f0.ast, *tail.elements.map{|e| e.op.text_value != '*' ? Compiler::Reciprocal.new(e.op.text_value, e.f1.ast) : e.f1.ast})
39
- end
40
- end
41
- }
42
- end
43
-
44
- rule factor
45
- literal u:unit? s
46
- {
47
- def ast
48
- Compiler::Literal.new(literal.value, u.empty? ? nil : u.text_value)
49
- end
50
- }
51
- / derived_variable
52
- / !context_note '(' s sum s ')' s { def ast; sum.ast; end }
53
- end
54
-
55
- rule derived_variable
56
- derived:term s role_id:(role_name / subscript )?
57
- {
58
- def ast quantifier = nil, value_constraint = nil, literal = nil, nested_clauses = nil
59
- role_name = role_id.empty? ? nil : role_id.value
60
- derived.ast(quantifier, nil, role_name, value_constraint, literal, nested_clauses)
61
- end
62
- }
63
- end
64
-
65
- end
66
- end
67
- end