activefacts 0.7.3 → 0.8.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (94) hide show
  1. data/LICENSE +19 -0
  2. data/Manifest.txt +24 -2
  3. data/Rakefile +25 -3
  4. data/bin/afgen +1 -1
  5. data/bin/cql +13 -2
  6. data/css/offline.css +3 -0
  7. data/css/orm2.css +24 -0
  8. data/css/print.css +8 -0
  9. data/css/style-print.css +357 -0
  10. data/css/style.css +387 -0
  11. data/download.html +85 -0
  12. data/examples/CQL/Address.cql +3 -3
  13. data/examples/CQL/Blog.cql +13 -14
  14. data/examples/CQL/CompanyDirectorEmployee.cql +4 -4
  15. data/examples/CQL/Death.cql +3 -2
  16. data/examples/CQL/Genealogy.cql +13 -11
  17. data/examples/CQL/Marriage.cql +2 -2
  18. data/examples/CQL/Metamodel.cql +136 -93
  19. data/examples/CQL/MultiInheritance.cql +2 -2
  20. data/examples/CQL/OilSupply.cql +14 -10
  21. data/examples/CQL/Orienteering.cql +22 -19
  22. data/examples/CQL/PersonPlaysGame.cql +3 -2
  23. data/examples/CQL/SchoolActivities.cql +4 -2
  24. data/examples/CQL/SimplestUnary.cql +1 -1
  25. data/examples/CQL/SubtypePI.cql +6 -7
  26. data/examples/CQL/Warehousing.cql +16 -19
  27. data/examples/CQL/unit.cql +584 -0
  28. data/examples/index.html +276 -0
  29. data/examples/intro.html +497 -0
  30. data/examples/local.css +20 -0
  31. data/index.html +96 -0
  32. data/lib/activefacts/api/concept.rb +48 -46
  33. data/lib/activefacts/api/constellation.rb +43 -23
  34. data/lib/activefacts/api/entity.rb +2 -2
  35. data/lib/activefacts/api/instance.rb +6 -2
  36. data/lib/activefacts/api/instance_index.rb +5 -0
  37. data/lib/activefacts/api/value.rb +8 -2
  38. data/lib/activefacts/api/vocabulary.rb +15 -10
  39. data/lib/activefacts/cql/CQLParser.treetop +109 -88
  40. data/lib/activefacts/cql/Concepts.treetop +32 -10
  41. data/lib/activefacts/cql/Context.treetop +34 -0
  42. data/lib/activefacts/cql/Expressions.treetop +9 -9
  43. data/lib/activefacts/cql/FactTypes.treetop +30 -31
  44. data/lib/activefacts/cql/Language/English.treetop +50 -0
  45. data/lib/activefacts/cql/LexicalRules.treetop +2 -1
  46. data/lib/activefacts/cql/Terms.treetop +117 -0
  47. data/lib/activefacts/cql/ValueTypes.treetop +152 -0
  48. data/lib/activefacts/cql/compiler.rb +1718 -0
  49. data/lib/activefacts/cql/parser.rb +124 -57
  50. data/lib/activefacts/generate/absorption.rb +1 -1
  51. data/lib/activefacts/generate/cql.rb +111 -100
  52. data/lib/activefacts/generate/cql/html.rb +5 -5
  53. data/lib/activefacts/generate/oo.rb +3 -3
  54. data/lib/activefacts/generate/ordered.rb +51 -19
  55. data/lib/activefacts/generate/ruby.rb +10 -8
  56. data/lib/activefacts/generate/sql/mysql.rb +14 -10
  57. data/lib/activefacts/generate/sql/server.rb +29 -24
  58. data/lib/activefacts/input/cql.rb +9 -1264
  59. data/lib/activefacts/input/orm.rb +213 -200
  60. data/lib/activefacts/persistence/columns.rb +11 -10
  61. data/lib/activefacts/persistence/index.rb +15 -18
  62. data/lib/activefacts/persistence/reference.rb +17 -17
  63. data/lib/activefacts/persistence/tables.rb +50 -51
  64. data/lib/activefacts/version.rb +1 -1
  65. data/lib/activefacts/vocabulary/extensions.rb +79 -8
  66. data/lib/activefacts/vocabulary/metamodel.rb +183 -114
  67. data/spec/absorption_ruby_spec.rb +99 -0
  68. data/spec/absorption_spec.rb +3 -4
  69. data/spec/api/constellation.rb +1 -1
  70. data/spec/api/entity_type.rb +3 -1
  71. data/spec/api/instance.rb +4 -2
  72. data/spec/api/roles.rb +8 -6
  73. data/spec/api_spec.rb +1 -2
  74. data/spec/cql/context_spec.rb +71 -0
  75. data/spec/cql/samples_spec.rb +154 -0
  76. data/spec/cql/unit_spec.rb +375 -0
  77. data/spec/cql_cql_spec.rb +31 -21
  78. data/spec/cql_mysql_spec.rb +70 -0
  79. data/spec/cql_parse_spec.rb +15 -9
  80. data/spec/cql_ruby_spec.rb +27 -13
  81. data/spec/cql_sql_spec.rb +42 -16
  82. data/spec/cql_symbol_tables_spec.rb +2 -3
  83. data/spec/cqldump_spec.rb +7 -7
  84. data/spec/helpers/file_matcher.rb +39 -0
  85. data/spec/norma_cql_spec.rb +20 -12
  86. data/spec/norma_ruby_spec.rb +6 -3
  87. data/spec/norma_sql_spec.rb +6 -3
  88. data/spec/norma_tables_spec.rb +6 -4
  89. data/spec/spec_helper.rb +27 -8
  90. data/status.html +69 -0
  91. data/why.html +60 -0
  92. metadata +34 -11
  93. data/lib/activefacts/cql/DataTypes.treetop +0 -81
  94. data/spec/cql_unit_spec.rb +0 -330
@@ -2,7 +2,8 @@
2
2
  # ActiveFacts tests: Parse all CQL files and check the generated Ruby.
3
3
  # Copyright (c) 2008 Clifford Heath. Read the LICENSE file.
4
4
  #
5
- require 'rubygems'
5
+
6
+ require 'spec/spec_helper'
6
7
  require 'stringio'
7
8
  require 'activefacts/vocabulary'
8
9
  require 'activefacts/support'
@@ -35,8 +36,10 @@ describe "NORMA Loader with SQL output" do
35
36
  sql_text = sql(vocabulary)
36
37
  File.open(actual_file, "w") { |f| f.write sql_text }
37
38
 
38
- pending unless File.exists? expected_file
39
- sql_text.should == File.open(expected_file) {|f| f.read }
39
+ pending("expected output file #{expected_file} not found") unless File.exists? expected_file
40
+
41
+ expected_text = File.open(expected_file) {|f| f.read }
42
+ sql_text.should_not differ_from(expected_text)
40
43
  File.delete(actual_file) # It succeeded, we don't need the file.
41
44
  end
42
45
  end
@@ -6,7 +6,7 @@
6
6
  #
7
7
  # Copyright (c) 2008 Clifford Heath. Read the LICENSE file.
8
8
  #
9
- require 'rubygems'
9
+
10
10
  require 'stringio'
11
11
  require 'activefacts/vocabulary'
12
12
  require 'activefacts/persistence'
@@ -19,13 +19,15 @@ include ActiveFacts::Metamodel
19
19
  Exceptions = {
20
20
  "Blog" => ["Author", "Comment", "Paragraph", "Post", "Topic"],
21
21
  "JoinEquality" => ["Event", "Seat", "Ticket", "Venue"],
22
- "Metamodel" => ["AllowedRange", "Constraint", "Derivation", "Fact", "FactType", "Feature", "Instance", "Join", "ParamValue", "Reading", "Role", "RoleRef", "RoleSequence", "RoleValue", "SetComparisonRoles", "Unit", "ValueRestriction"],
23
- "MetamodelTerms" => ["AllowedRange", "Concept", "Constraint", "Derivation", "Fact", "FactType", "Import", "Instance", "Join", "ParamValue", "Reading", "Role", "RoleRef", "RoleSequence", "RoleValue", "SetComparisonRoles", "Term", "Unit", "ValueRestriction"],
22
+ "Metamodel" => ["AllowedRange", "Concept", "Constraint", "ContextAccordingTo", "ContextAgreedBy", "ContextNote", "Derivation", "Fact", "FactType", "Instance", "Join", "ParamValue", "Reading", "Role", "RoleRef", "RoleSequence", "RoleValue", "SetComparisonRoles", "Unit", "ValueRestriction" ],
23
+ "MetamodelTerms" => ["AllowedRange", "Constraint", "ContextAccordingTo", "ContextAgreedBy", "ContextNote", "Derivation", "Fact", "FactType", "Instance", "Join", "ParamValue", "Reading", "Role", "RoleRef", "RoleSequence", "RoleValue", "SetComparisonRoles", "Term", "Unit", "ValueRestriction"],
24
24
  "OilSupply" => ["AcceptableSubstitutes", "Month", "ProductionForecast", "RegionalDemand", "TransportRoute"],
25
25
  "Orienteering" => ["Club", "Entry", "Event", "EventControl", "EventScoringMethod", "Map", "Person", "Punch", "PunchPlacement", "Series", "Visit"],
26
26
  "SeparateSubtype" => ["Claim", "VehicleIncident"],
27
27
  "Warehousing" => ["Bin", "DirectOrderMatch", "DispatchItem", "Party", "Product", "PurchaseOrder", "PurchaseOrderItem", "ReceivedItem", "SalesOrder", "SalesOrderItem", "TransferRequest", "Warehouse"],
28
- "RedundantDependency" => ["Address", "LegislativeDistrict", "StateOrProvince"],
28
+ "Portfolio" => ["AnnualDepreciation", "Attachment", "Collateral", "DepreciationSchedule", "Disposal", "Expenditure", "OwnedItem", "Revenue", "Transaction", "Valuation"],
29
+ "OrienteeringER" => ["Club", "Event", "EventControl", "EventCourse", "Map", "SeriesEvent"],
30
+ "RedundantDependency" => ["Address", "Politician", "StateOrProvince"],
29
31
  }
30
32
 
31
33
  def extract_created_tables_from_sql sql_file
data/spec/spec_helper.rb CHANGED
@@ -1,10 +1,29 @@
1
- begin
2
- require 'spec'
3
- rescue LoadError
4
- require 'rubygems'
5
- gem 'rspec'
6
- require 'spec'
1
+ #
2
+ # A Custom Matcher for RSpec that shows the difference between two multi-line strings.
3
+ #
4
+ # Usage:
5
+ # actual_text.should_not differ_from(expected_text)
6
+ #
7
+
8
+ require 'spec/helpers/file_matcher.rb'
9
+
10
+ class String
11
+ def strip_comments()
12
+ c_comment = %r{/\*((?!\*/).)*\*/}m
13
+ gsub(c_comment, '').gsub(%r{\n\n+},"\n")
14
+ end
7
15
  end
8
16
 
9
- $:.unshift(File.dirname(__FILE__) + '/../lib')
10
- require 'activefacts'
17
+ class Array
18
+ def diff_strings(a2)
19
+ d = Diff::LCS::diff(self, a2)
20
+ d.map do |chunk|
21
+ added_at = (add = chunk.detect{|d| d.action == '+'}) && add.position+1
22
+ removed_at = (remove = chunk.detect{|d| d.action == '-'}) && remove.position+1
23
+ "Line #{added_at}/#{removed_at}:\n"+
24
+ chunk.map do |change|
25
+ "#{change.action} #{change.element}"
26
+ end*"\n"
27
+ end*"\n"
28
+ end
29
+ end
data/status.html ADDED
@@ -0,0 +1,69 @@
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
+ <div id="sidebar"></div>
6
+
7
+ <div id="top" class="content">
8
+
9
+ <a name="status"></a>
10
+ <h2 class="title">
11
+ ActiveFacts Project Status
12
+ </h2>
13
+
14
+ <p>
15
+ The Constellation Query Language has DDL support sufficient to allow
16
+ conversion of any ORM2 model. The Ruby generator is complete. The SQL
17
+ generator is complete, but with a couple of known defects in corner cases.
18
+ The generated Ruby code has only a partial implementation of the mapping
19
+ data needed to convert to and from SQL tables, and even that has to be
20
+ enabled using an option.
21
+ </p>
22
+
23
+ <p>
24
+ CQL is not yet handling imported vocabularies, example fact populations or
25
+ value type units yet. It has limited model validation facilities, and it's
26
+ not yet possible to add a new reading to an existing fact type. It's also
27
+ only parsing query syntax, with no semantic analysis or SQL generation.
28
+ </p>
29
+
30
+ <p>
31
+ The Constellation API (in Ruby) supports the generated Ruby code, allowing
32
+ any fact population to be constructed for a given vocabulary. There is
33
+ not yet any support within the API for database persistence, but that's
34
+ coming up for implementation soon.
35
+ </p>
36
+
37
+ <p>
38
+ The Metamodel is generated to Ruby from CQL or ORM2 to support the
39
+ creation and manipulation of any semantic model. Some changes are upcoming
40
+ to support a vocabulary that provides a translation of an existing
41
+ vocabulary, such as a Dutch or Japanese version of an English language
42
+ model.
43
+ </p>
44
+
45
+ <p>
46
+ ActiveFacts can currently read models from NORMA, which are in elementary
47
+ form, and it can reverse engineer the schemas of existing databases in SQL
48
+ Server, DB2, Oracle, and open-source databases not yet tested including
49
+ MySQL, PostgreSQL, etc. Reverse-engineered models are still in composite
50
+ form - the mapping to elementary form is incomplete. Reverse engineering
51
+ does not yet analyse actual data.
52
+ </p>
53
+
54
+ <p>
55
+ ActiveFacts has no database adapter infrastructure yet. The
56
+ previously-available reverse engineering tools used used the
57
+ infrastructure of ActiveRecord with DRYSql and Composite Primary Keys, but
58
+ future versions will probably just use the ActiveRecord adapters directly.
59
+ </p>
60
+
61
+ <!--p>
62
+ APRIMO allows the definition of vocabulary aspects as well as the addition
63
+ of entity and value objects and the fact types that link them. Subtyping,
64
+ data types and units, and complex constraints are still to be implemented.
65
+ </p-->
66
+
67
+ </div>
68
+
69
+ <!--#include virtual="/footer.html" -->
data/why.html ADDED
@@ -0,0 +1,60 @@
1
+ <!--#include virtual="/header.html" -->
2
+
3
+ <div class="content">
4
+ <h2>Why Semantic Modeling?</h2>
5
+
6
+ <p>
7
+ Software is not mainly about <em>how</em>, but about <em>what</em> and
8
+ <em>why</em>. Software projects fail most commonly because they build
9
+ the <em>wrong thing</em>, not because they build it wrongly. Other
10
+ forms of modeling, such as object modeling and entity relationship
11
+ modeling, attempt to capture <em>what</em>, but the models are shaped
12
+ from the start by the needs of implementation (<em>how</em>). That
13
+ shuts out the non-technical business expert, and bends the model out
14
+ of shape, losing track of <em>why</em> each feature is needed, what it
15
+ means and under what terms, the roles it plays in the overall system.
16
+ <strong>Semantic modeling</strong> incorporates and transcends both
17
+ approaches, and works in either Agile or traditional environments.
18
+ </p>
19
+
20
+ <p>
21
+ ActiveFacts uses a <strong>fact-oriented</strong> approach to
22
+ constructing models in <strong>elementary</strong> form. Every
23
+ concept, whether a business entity or a relationship, is represented
24
+ in the simplest possible form, isolated from all other concerns.
25
+ Every role that each concept plays in the system is incorporated in
26
+ simple <strong>business rules</strong> that can be effectively
27
+ verbalised in plain language, displayed on diagrams, and managed in a
28
+ system ontology (vocabulary). The elementary form is the most direct
29
+ mind-map of the business domain that can be constructed, is based on
30
+ pure logic, and is unsullied by implementation concerns. That makes it
31
+ much easier to understand and validate by all parties, especially the
32
+ business expert. Purely for its benefits in specification, semantic
33
+ modeling is revolutionary.
34
+ </p>
35
+
36
+ <p>
37
+ Because the semantic approach is based in pure logic, it can be
38
+ automatically <strong>transformed</strong> into working software,
39
+ in the form of executable code and database designs in efficient
40
+ normalised form. It's an established truth that very small changes
41
+ (even additions) in business rules can require large changes to
42
+ the structure of an database. Contrary to existing methods used
43
+ to design and access databases, semantic modeling allows you to
44
+ make radical changes in the underlying physical table structures
45
+ without the huge ramifications in your application code. The
46
+ advantages in business agility are manifold.
47
+ </p>
48
+
49
+ <!--p>
50
+ Queries in CQL span tables transparently, crossing conceptual
51
+ relationships (fact types) without explicit database joins, and
52
+ return structured data in a nested-relational form (called
53
+ constellation form). For every user action in an application, a
54
+ single query can be defined that provides all the data required to
55
+ respond to that action. There's no need to fetch this, that, and
56
+ the other. All required results are fetched at once, which
57
+ improves application structure, performance, and even concurrency.
58
+ </p-->
59
+
60
+ <!--#include virtual="/footer.html" -->
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activefacts
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.3
4
+ version: 0.8.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Clifford Heath
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-05-15 00:00:00 +10:00
12
+ date: 2009-09-24 00:00:00 +10:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -20,7 +20,7 @@ dependencies:
20
20
  requirements:
21
21
  - - ">="
22
22
  - !ruby/object:Gem::Version
23
- version: 1.2.4
23
+ version: 1.4.1
24
24
  version:
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: newgem
@@ -30,7 +30,7 @@ dependencies:
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 1.4.1
33
+ version: 1.5.2
34
34
  version:
35
35
  - !ruby/object:Gem::Dependency
36
36
  name: hoe
@@ -40,9 +40,10 @@ dependencies:
40
40
  requirements:
41
41
  - - ">="
42
42
  - !ruby/object:Gem::Version
43
- version: 1.8.0
43
+ version: 2.3.2
44
44
  version:
45
- description: |-
45
+ description: |
46
+
46
47
  ActiveFacts is a semantic modeling toolkit, comprising an implementation
47
48
  of the Constellation Query Language, the Constellation API, and code
48
49
  generators that receive CQL or ORM (Object Role Modeling files, from
@@ -60,6 +61,7 @@ description: |-
60
61
  allows creation of relational and object models that are guaranteed
61
62
  equivalent, and much more stable in the face of schema evolution than
62
63
  SQL is.
64
+
63
65
  email:
64
66
  - cjh@dataconstellation.org
65
67
  executables:
@@ -70,14 +72,20 @@ extensions:
70
72
  extra_rdoc_files:
71
73
  - History.txt
72
74
  - Manifest.txt
73
- - README.rdoc
74
75
  files:
75
76
  - History.txt
77
+ - LICENSE
76
78
  - Manifest.txt
77
79
  - README.rdoc
78
80
  - Rakefile
79
81
  - bin/afgen
80
82
  - bin/cql
83
+ - css/offline.css
84
+ - css/orm2.css
85
+ - css/print.css
86
+ - css/style-print.css
87
+ - css/style.css
88
+ - download.html
81
89
  - examples/CQL/Address.cql
82
90
  - examples/CQL/Blog.cql
83
91
  - examples/CQL/CompanyDirectorEmployee.cql
@@ -94,6 +102,11 @@ files:
94
102
  - examples/CQL/SubtypePI.cql
95
103
  - examples/CQL/Warehousing.cql
96
104
  - examples/CQL/WindowInRoomInBldg.cql
105
+ - examples/CQL/unit.cql
106
+ - examples/index.html
107
+ - examples/intro.html
108
+ - examples/local.css
109
+ - index.html
97
110
  - lib/activefacts.rb
98
111
  - lib/activefacts/api.rb
99
112
  - lib/activefacts/api/concept.rb
@@ -112,12 +125,15 @@ files:
112
125
  - lib/activefacts/cql.rb
113
126
  - lib/activefacts/cql/CQLParser.treetop
114
127
  - lib/activefacts/cql/Concepts.treetop
115
- - lib/activefacts/cql/DataTypes.treetop
128
+ - lib/activefacts/cql/Context.treetop
116
129
  - lib/activefacts/cql/Expressions.treetop
117
130
  - lib/activefacts/cql/FactTypes.treetop
118
131
  - lib/activefacts/cql/Language/English.treetop
119
132
  - lib/activefacts/cql/LexicalRules.treetop
120
133
  - lib/activefacts/cql/Rakefile
134
+ - lib/activefacts/cql/Terms.treetop
135
+ - lib/activefacts/cql/ValueTypes.treetop
136
+ - lib/activefacts/cql/compiler.rb
121
137
  - lib/activefacts/cql/parser.rb
122
138
  - lib/activefacts/generate/absorption.rb
123
139
  - lib/activefacts/generate/cql.rb
@@ -144,6 +160,7 @@ files:
144
160
  - lib/activefacts/vocabulary/extensions.rb
145
161
  - lib/activefacts/vocabulary/metamodel.rb
146
162
  - script/txt2html
163
+ - spec/absorption_ruby_spec.rb
147
164
  - spec/absorption_spec.rb
148
165
  - spec/api/autocounter.rb
149
166
  - spec/api/constellation.rb
@@ -152,19 +169,25 @@ files:
152
169
  - spec/api/roles.rb
153
170
  - spec/api/value_type.rb
154
171
  - spec/api_spec.rb
172
+ - spec/cql/context_spec.rb
173
+ - spec/cql/samples_spec.rb
174
+ - spec/cql/unit_spec.rb
155
175
  - spec/cql_cql_spec.rb
176
+ - spec/cql_mysql_spec.rb
156
177
  - spec/cql_parse_spec.rb
157
178
  - spec/cql_ruby_spec.rb
158
179
  - spec/cql_sql_spec.rb
159
180
  - spec/cql_symbol_tables_spec.rb
160
- - spec/cql_unit_spec.rb
161
181
  - spec/cqldump_spec.rb
182
+ - spec/helpers/file_matcher.rb
162
183
  - spec/norma_cql_spec.rb
163
184
  - spec/norma_ruby_spec.rb
164
185
  - spec/norma_sql_spec.rb
165
186
  - spec/norma_tables_spec.rb
166
187
  - spec/spec.opts
167
188
  - spec/spec_helper.rb
189
+ - status.html
190
+ - why.html
168
191
  has_rdoc: true
169
192
  homepage: http://dataconstellation.com/ActiveFacts/
170
193
  licenses: []
@@ -201,9 +224,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
201
224
  requirements: []
202
225
 
203
226
  rubyforge_project: cjheath@rubyforge.org
204
- rubygems_version: 1.3.3
227
+ rubygems_version: 1.3.5
205
228
  signing_key:
206
229
  specification_version: 3
207
- summary: ActiveFacts is a semantic modeling toolkit, comprising an implementation of the Constellation Query Language, the Constellation API, and code generators that receive CQL or ORM (Object Role Modeling files, from NORMA) to emit CQL, Ruby and SQL
230
+ summary: A semantic modeling and query language (CQL) and application runtime (the Constellation API)
208
231
  test_files: []
209
232
 
@@ -1,81 +0,0 @@
1
- #
2
- # ActiveFacts CQL Parser.
3
- # Parse rules relating to ValueType definitions.
4
- #
5
- # Copyright (c) 2009 Clifford Heath. Read the LICENSE file.
6
- #
7
- module ActiveFacts
8
- module CQL
9
- grammar DataTypes
10
- rule data_type
11
- s name:id
12
- ( s '=' s / written_as )
13
- base:id s
14
- '(' s tpl:type_parameter_list? ')' s
15
- u0:(!restricted u1:unit s)?
16
- r:restriction?
17
- s ';' s
18
- {
19
- def defined_type
20
- [
21
- :data_type,
22
- base.text_value,
23
- tpl.empty? ? [] : tpl.value,
24
- !u0.empty? ? u0.u1.text_value : nil,
25
- !r.empty? ? r.ranges : [],
26
- ]
27
- end
28
-
29
- def value
30
- [ name.text_value,
31
- defined_type
32
- ]
33
- end
34
- }
35
- end
36
-
37
- rule unit_definition
38
- numerator:number denominator:(s '/' s number)?
39
- baseunits:(unit+ (s '/' s unit+)?) s
40
- offset:(('+' / '-') s number)
41
- 'makes' s ('approximately' s)?
42
- singular:id plural:(s '/' s id)?
43
- (s '[' s 'ephemeral' s ']')?
44
- end
45
-
46
- rule type_parameter_list
47
- head:number s tail:( ',' s number s )*
48
- {
49
- def value
50
- [head.value] + tail.elements.map{|i| i.number.value}
51
- end
52
- }
53
- end
54
-
55
- rule unit
56
- unit_name:id ('^' '-'? [0-9])?
57
- end
58
-
59
- rule restriction
60
- restricted s to s range_list s unit?
61
- {
62
- def ranges
63
- range_list.ranges
64
- end
65
- }
66
- end
67
-
68
- rule range_list
69
- '{' s
70
- head:range s tail:( ',' s range )*
71
- '}' s
72
- {
73
- def ranges
74
- [head.value] + tail.elements.map{|e| e.range.value }
75
- end
76
- }
77
- end
78
-
79
- end
80
- end
81
- end