rley 0.8.00 → 0.8.05
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +47 -3
- data/CHANGELOG.md +32 -4
- data/examples/NLP/pico_en_demo.rb +2 -2
- data/examples/data_formats/JSON/README.md +34 -0
- data/examples/data_formats/JSON/sample01.json +3 -0
- data/examples/data_formats/JSON/sample01.svg +36 -0
- data/examples/data_formats/JSON/sample02.json +6 -0
- data/examples/data_formats/JSON/sample02.svg +128 -0
- data/examples/data_formats/JSON/sample03.json +88 -0
- data/examples/general/calc_iter1/README.md +26 -0
- data/examples/general/calc_iter2/README.md +55 -0
- data/examples/general/general_examples.md +37 -0
- data/examples/tokenizer/README.md +46 -0
- data/examples/tokenizer/loxxy_raw_scanner.rex +98 -0
- data/examples/tokenizer/loxxy_raw_scanner.rex.rb +256 -0
- data/examples/tokenizer/loxxy_tokenizer.rb +94 -0
- data/examples/tokenizer/run_tokenizer.rb +29 -0
- data/lib/rley/constants.rb +1 -1
- data/lib/rley/lexical/literal.rb +29 -0
- data/lib/rley/lexical/token.rb +7 -4
- data/lib/rley/notation/all_notation_nodes.rb +3 -1
- data/lib/rley/notation/ast_builder.rb +185 -191
- data/lib/rley/notation/ast_node.rb +5 -5
- data/lib/rley/notation/ast_visitor.rb +3 -1
- data/lib/rley/notation/grammar.rb +1 -1
- data/lib/rley/notation/grammar_builder.rb +87 -33
- data/lib/rley/notation/grouping_node.rb +1 -1
- data/lib/rley/notation/parser.rb +56 -56
- data/lib/rley/notation/sequence_node.rb +3 -3
- data/lib/rley/notation/symbol_node.rb +2 -2
- data/lib/rley/notation/tokenizer.rb +3 -15
- data/lib/rley/parse_rep/ast_base_builder.rb +35 -4
- data/lib/rley/parser/gfg_chart.rb +5 -4
- data/lib/rley/parser/gfg_earley_parser.rb +1 -1
- data/lib/rley/syntax/base_grammar_builder.rb +8 -2
- data/lib/rley/syntax/match_closest.rb +7 -7
- data/lib/rley.rb +1 -1
- data/spec/rley/lexical/literal_spec.rb +33 -0
- data/spec/rley/lexical/token_spec.rb +15 -4
- data/spec/rley/notation/grammar_builder_spec.rb +57 -50
- data/spec/rley/notation/parser_spec.rb +183 -184
- data/spec/rley/notation/tokenizer_spec.rb +98 -104
- data/spec/rley/parser/dangling_else_spec.rb +20 -20
- data/spec/rley/parser/gfg_chart_spec.rb +0 -1
- data/spec/rley/parser/gfg_earley_parser_spec.rb +166 -147
- data/spec/rley/parser/gfg_parsing_spec.rb +2 -2
- data/spec/rley/syntax/base_grammar_builder_spec.rb +7 -8
- data/spec/rley/syntax/grammar_spec.rb +6 -9
- data/spec/rley/syntax/match_closest_spec.rb +4 -4
- metadata +19 -9
- data/lib/rley/parser/parse_tracer.rb +0 -103
- data/lib/rley/syntax/literal.rb +0 -20
- data/lib/rley/syntax/verbatim_symbol.rb +0 -27
- data/spec/rley/syntax/literal_spec.rb +0 -31
- data/spec/rley/syntax/verbatim_symbol_spec.rb +0 -38
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a94c23265bf2996856da4d4b1fc6f2749873626951d30bacec9f1ca7619d4d4f
|
4
|
+
data.tar.gz: fc6a6ae19388b532dc711915a9c33ffc455a602ea9e6a1ae13e53522bc0616d0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9b25f6a34e4e5603d4b88f5cf3220e998d9e0c38ffef204ebbf4a8eacaf57853c2bb9bc2bb5a3765440aaed41ee5a4883edadc533c6df0dc907b58457b085469
|
7
|
+
data.tar.gz: 57c3021f24eb5764fef2be6bdd58a9cda1c9b9343737c357d6c1e1862beceaf041ed9eee9fb625cf9acc9492bac0fcb6a6ac8cd9dc464dcf2096fccd5b51e6e9
|
data/.rubocop.yml
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
AllCops:
|
2
2
|
Exclude:
|
3
3
|
- 'exp/**/*'
|
4
|
-
- 'demo/**/*'
|
5
4
|
|
6
5
|
Gemspec/DateAssignment:
|
7
6
|
Enabled: true
|
@@ -50,6 +49,9 @@ Layout/IndentationConsistency:
|
|
50
49
|
Layout/HeredocIndentation:
|
51
50
|
Enabled: false
|
52
51
|
|
52
|
+
Layout/LineEndStringConcatenationIndentation:
|
53
|
+
Enabled: true
|
54
|
+
|
53
55
|
Layout/MultilineHashBraceLayout:
|
54
56
|
Enabled: true
|
55
57
|
|
@@ -78,9 +80,15 @@ Layout/TrailingEmptyLines:
|
|
78
80
|
Layout/TrailingWhitespace:
|
79
81
|
Enabled: true
|
80
82
|
|
83
|
+
Lint/AmbiguousOperatorPrecedence:
|
84
|
+
Enabled: true
|
85
|
+
|
81
86
|
Lint/AmbiguousAssignment:
|
82
87
|
Enabled: true
|
83
88
|
|
89
|
+
Lint/AmbiguousRange:
|
90
|
+
Enabled: true
|
91
|
+
|
84
92
|
Lint/DeprecatedConstants:
|
85
93
|
Enabled: true
|
86
94
|
|
@@ -96,6 +104,12 @@ Lint/EmptyBlock:
|
|
96
104
|
Lint/EmptyClass:
|
97
105
|
Enabled: false
|
98
106
|
|
107
|
+
Lint/EmptyInPattern:
|
108
|
+
Enabled: true
|
109
|
+
|
110
|
+
Lint/IncompatibleIoSelectWithFiberScheduler:
|
111
|
+
Enabled: true
|
112
|
+
|
99
113
|
Lint/LambdaWithoutLiteralBlock:
|
100
114
|
Enabled: true
|
101
115
|
|
@@ -117,6 +131,9 @@ Lint/RaiseException:
|
|
117
131
|
Lint/RedundantDirGlobSort:
|
118
132
|
Enabled: true
|
119
133
|
|
134
|
+
Lint/RequireRelativeSelfPath:
|
135
|
+
Enabled: true
|
136
|
+
|
120
137
|
Lint/RescueException:
|
121
138
|
Enabled: true
|
122
139
|
|
@@ -192,6 +209,9 @@ Naming/ClassAndModuleCamelCase:
|
|
192
209
|
Naming/BlockParameterName:
|
193
210
|
Enabled: true
|
194
211
|
|
212
|
+
Naming/InclusiveLanguage:
|
213
|
+
Enabled: true
|
214
|
+
|
195
215
|
Naming/MethodParameterName:
|
196
216
|
Enabled: false
|
197
217
|
|
@@ -201,8 +221,8 @@ Naming/MethodName:
|
|
201
221
|
Naming/VariableName:
|
202
222
|
Enabled: false
|
203
223
|
|
204
|
-
|
205
|
-
Enabled:
|
224
|
+
Security/IoMethods:
|
225
|
+
Enabled: true
|
206
226
|
|
207
227
|
Style/Alias:
|
208
228
|
Enabled: true
|
@@ -276,12 +296,18 @@ Style/HashTransformValues:
|
|
276
296
|
Style/IfUnlessModifier:
|
277
297
|
Enabled: false
|
278
298
|
|
299
|
+
Style/InPatternThen:
|
300
|
+
Enabled: true
|
301
|
+
|
279
302
|
Style/InverseMethods:
|
280
303
|
Enabled: false
|
281
304
|
|
282
305
|
Style/MissingRespondToMissing:
|
283
306
|
Enabled: false
|
284
307
|
|
308
|
+
Style/MultilineInPatternThen:
|
309
|
+
Enabled: true
|
310
|
+
|
285
311
|
Style/NegatedIfElseCondition:
|
286
312
|
Enabled: true
|
287
313
|
|
@@ -291,9 +317,18 @@ Style/Next:
|
|
291
317
|
Style/NilLambda:
|
292
318
|
Enabled: true
|
293
319
|
|
320
|
+
Style/NumberedParameters:
|
321
|
+
Enabled: true
|
322
|
+
|
323
|
+
Style/NumberedParametersLimit:
|
324
|
+
Enabled: true
|
325
|
+
|
294
326
|
Style/NumericLiterals:
|
295
327
|
Enabled: false
|
296
328
|
|
329
|
+
Style/QuotedSymbols:
|
330
|
+
Enabled: true
|
331
|
+
|
297
332
|
Style/RaiseArgs:
|
298
333
|
Enabled: true
|
299
334
|
|
@@ -306,11 +341,17 @@ Style/RedundantReturn:
|
|
306
341
|
Style/RedundantSelf:
|
307
342
|
Enabled: true
|
308
343
|
|
344
|
+
Style/RedundantSelfAssignmentBranch:
|
345
|
+
Enabled: true
|
346
|
+
|
309
347
|
Style/RegexpLiteral:
|
310
348
|
Enabled: false
|
311
349
|
|
312
350
|
Style/PercentLiteralDelimiters:
|
313
351
|
Enabled: false
|
352
|
+
|
353
|
+
Style/SelectByRegexp:
|
354
|
+
Enabled: true
|
314
355
|
|
315
356
|
Style/StderrPuts:
|
316
357
|
Enabled: false
|
@@ -367,6 +408,9 @@ Lint/TopLevelReturnWithArgument:
|
|
367
408
|
Lint/UnreachableLoop:
|
368
409
|
Enabled: true
|
369
410
|
|
411
|
+
Style/AccessorGrouping:
|
412
|
+
Enabled: true
|
413
|
+
|
370
414
|
Style/ArrayCoercion:
|
371
415
|
Enabled: true
|
372
416
|
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,31 @@
|
|
1
|
+
### 0.8.05 / 2021-10-04
|
2
|
+
- Added example of generated scanner. Unused class removal, code re-styling to please `Rubocop`
|
3
|
+
|
4
|
+
* [NEW] Folder `example\tokenizer` contains an example with a scanner that was generated.
|
5
|
+
* [NEW] Class `Rley::Lexical::Literal` a specialization of Token class for literal tokens.
|
6
|
+
* [CHANGE] File `.rubocp.yml` updated to take into account new 1.21 and 1.22 cops.
|
7
|
+
* [DELETED] Class `Rley::Parser::ParserTracer` this class was no more in use.
|
8
|
+
* [DELETED] Class `Rley::Syntax::Literal` this class was unused.
|
9
|
+
* [DELETED] Class `Rley::Syntax::VerbatimSymbol` this class was unused.
|
10
|
+
|
11
|
+
### 0.8.03 / 2021-08-27
|
12
|
+
- Added missing method in `ASTBaseBuilder` class
|
13
|
+
|
14
|
+
* [FIX] Added method `ParseRep::ASTBaseBuilder#reduce_children`.
|
15
|
+
|
16
|
+
### 0.8.02 / 2021-08-23
|
17
|
+
- Code restyling to please Rubocop 1.19.1
|
18
|
+
|
19
|
+
* [CHANGE] File `.rubocp.yml` updated to take into account new cops.
|
20
|
+
* [CHANGE] File `*.rb` files updated to fix Rubocop findings
|
21
|
+
|
22
|
+
|
23
|
+
### 0.8.01 / 2021-08-22
|
24
|
+
- Unused/redundant file removal. Fix in rule generation
|
25
|
+
|
26
|
+
* [CHANGE] Removal of files in repository that were redundant/useless.
|
27
|
+
* [FIX] The rule ordering was broken by the rules implicitly generated by Rlry
|
28
|
+
|
1
29
|
### 0.8.00 / 2021-08-15
|
2
30
|
- New grammar builder that accepts ? * + modifiers
|
3
31
|
|
@@ -15,10 +43,10 @@
|
|
15
43
|
- [FIX] Method `GFGParsing#nullable_rule`: issue with nullable productions having at least one member in their rhs.
|
16
44
|
|
17
45
|
### 0.7.04 / 2019-08-17
|
18
|
-
- Rley recognizer is about 25% faster than previous version. Kudos to the people
|
19
|
-
behind the *magic_frozen_string_literal* gem.
|
46
|
+
- Rley recognizer is about 25% faster than previous version. Kudos to the people
|
47
|
+
behind the *magic_frozen_string_literal* gem.
|
20
48
|
- Code refactoring to use string frozen magic comments (as a consequence, Rley runs only on Rubies 2.3 or newer).
|
21
|
-
- Code restyling to please rubocop 0.7.40.
|
49
|
+
- Code restyling to please rubocop 0.7.40.
|
22
50
|
- [CHANGE] Class `ParseEntrySet`: minor code optimization
|
23
51
|
- [CHANGE] File `README.md` removed allusion to Ruby 2.0.x up to 2.2.x.
|
24
52
|
- [CHANGE] File `README.md` added Ruby 2.6.x up as supported version.
|
@@ -103,7 +131,7 @@ behind the *magic_frozen_string_literal* gem.
|
|
103
131
|
* [FIX] Code re-styling to remove most style offenses found by Rubocop 0.52.1
|
104
132
|
|
105
133
|
### 0.6.00 / 2018-02-25
|
106
|
-
Version bump. Highlights: new programming interface through facade object, improved AST generation.
|
134
|
+
Version bump. Highlights: new programming interface through facade object, improved AST generation.
|
107
135
|
* [NEW] Class `Rley::Engine`: Implementation of Facade design pattern to reach more convenient interface.
|
108
136
|
* [NEW] Class `Rley::ParseRep::ASTBaseBuilder` Abstract class that simplifies the creation of custom AST (Abstract Syntax Tree)
|
109
137
|
* [NEW] Module `Rley::ParseRep` hosts the classes for building parse representations (parse trees and forests)
|
@@ -26,8 +26,8 @@ engine.build_grammar do
|
|
26
26
|
rule 'S' => 'NP VP'
|
27
27
|
rule 'NP' => 'Proper-Noun'
|
28
28
|
rule 'NP' => 'Determiner Noun'
|
29
|
-
rule 'NP' => 'Determiner Noun PP'
|
30
|
-
rule 'VP' => 'Verb NP'
|
29
|
+
rule 'NP' => 'Determiner Noun PP'
|
30
|
+
rule 'VP' => 'Verb NP'
|
31
31
|
rule 'VP' => 'Verb NP PP'
|
32
32
|
rule 'PP' => 'Preposition NP'
|
33
33
|
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
## Demo JSON parser
|
2
|
+
|
3
|
+
### Source files
|
4
|
+
This sample project consists of the following files:
|
5
|
+
- **cli_opt.rb** containing the utility class `CLIOptions` that retrieves the
|
6
|
+
command-line options.
|
7
|
+
|
8
|
+
- **json_ast_builder.rb** containing the class `JSONASTBuilder` that creates
|
9
|
+
the abstract syntax trees (AST) representation for a given parse result.
|
10
|
+
|
11
|
+
- **json_ast_nodes.rb** containing the node classs for implementing the AST.
|
12
|
+
The nodes are augmented with methods that allow the re-use of some formatters
|
13
|
+
designed initially for CST (Concrete Syntax Tree). The nodes have a 'to_ruby'
|
14
|
+
method that enable a conversion of the input JSON text into Ruby representation.
|
15
|
+
|
16
|
+
- **JSON_demo.rb** a demo command-line program.
|
17
|
+
It parses the JSON file specified in the command-line and outputs the parse tree
|
18
|
+
into different formats. For more details, run the command-line: `JSON_demo.rb --help`
|
19
|
+
|
20
|
+
- **JSON_grammar.rb** implementing the class `JSONGrammar`.
|
21
|
+
The grammar is a list of (production) rules that specifies the syntax of JSON data.
|
22
|
+
A little examination of the grammar will reveal interesting grammar features such as:
|
23
|
+
* Recursive rules (e.g. terminal in left-side of rule also appears in right-hand side)
|
24
|
+
|
25
|
+
- **JSON_lexer.rb** implementing the class `JSONLexer`.
|
26
|
+
The purpose of the lexer is to break the JSON source text into a sequence of tokens.
|
27
|
+
|
28
|
+
- **JSON_parser.rb** implementing a `JSONParser` class.
|
29
|
+
The parser processes the tokens stream from the lexer and delivers its results
|
30
|
+
|
31
|
+
|
32
|
+
- sample0x.json files of various degree of complexity.
|
33
|
+
|
34
|
+
- sample0x.svg files that are syntax tree diagrams obtained by feeding [RSyntaxTree](http://yohasebe.com/rsyntaxtree/) with the output of JSON_demo.rb. Remark: the website works best with not too complex parse trees.
|
@@ -0,0 +1,36 @@
|
|
1
|
+
<?xml version="1.0" standalone="no"?>
|
2
|
+
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
|
3
|
+
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
4
|
+
<svg width="469.5" height="502" version="1.1" xmlns="http://www.w3.org/2000/svg">
|
5
|
+
<text style='fill: green; font-size: 16px;' x='296.53125' y='490'> John Doe</text>
|
6
|
+
<text style='fill: green; font-size: 16px;' x='109.53125' y='424'> name</text>
|
7
|
+
<text style='fill: green; font-size: 16px;' x='221.2421875' y='424'> :</text>
|
8
|
+
<text style='fill: blue; font-size: 16px;' x='309.3828125' y='424'>string</text>
|
9
|
+
<polygon style='fill: white; stroke: black; stroke-width:1;' points='361 467 297 467 329 431' />
|
10
|
+
<text style='fill: blue; font-size: 16px;' x='109.796875' y='358'>string</text>
|
11
|
+
<line style='stroke:black; stroke-width:1;' x1='130' y1='401' x2='130' y2='365' />
|
12
|
+
<text style='fill: blue; font-size: 16px;' x='164.796875' y='358'>name-separator</text>
|
13
|
+
<line style='stroke:black; stroke-width:1;' x1='223' y1='401' x2='223' y2='365' />
|
14
|
+
<text style='fill: blue; font-size: 16px;' x='309.75' y='358'>value</text>
|
15
|
+
<line style='stroke:black; stroke-width:1;' x1='329' y1='401' x2='329' y2='365' />
|
16
|
+
<text style='fill: green; font-size: 16px;' x='46.5078125' y='292'> {</text>
|
17
|
+
<text style='fill: blue; font-size: 16px;' x='198.40234375' y='292'>member</text>
|
18
|
+
<line style='stroke:black; stroke-width:1;' x1='130' y1='335' x2='229' y2='299' />
|
19
|
+
<line style='stroke:black; stroke-width:1;' x1='223' y1='335' x2='229' y2='299' />
|
20
|
+
<line style='stroke:black; stroke-width:1;' x1='329' y1='335' x2='229' y2='299' />
|
21
|
+
<text style='fill: green; font-size: 16px;' x='412.4375' y='292'> }</text>
|
22
|
+
<text style='fill: blue; font-size: 16px;' x='5.0' y='226'>begin-object</text>
|
23
|
+
<line style='stroke:black; stroke-width:1;' x1='50' y1='269' x2='50' y2='233' />
|
24
|
+
<text style='fill: blue; font-size: 16px;' x='185.58984375' y='226'>member-list</text>
|
25
|
+
<line style='stroke:black; stroke-width:1;' x1='229' y1='269' x2='229' y2='233' />
|
26
|
+
<text style='fill: blue; font-size: 16px;' x='376.96875' y='226'>end-object</text>
|
27
|
+
<line style='stroke:black; stroke-width:1;' x1='416' y1='269' x2='416' y2='233' />
|
28
|
+
<text style='fill: blue; font-size: 16px;' x='209.984375' y='160'>object</text>
|
29
|
+
<line style='stroke:black; stroke-width:1;' x1='50' y1='203' x2='233' y2='167' />
|
30
|
+
<line style='stroke:black; stroke-width:1;' x1='229' y1='203' x2='233' y2='167' />
|
31
|
+
<line style='stroke:black; stroke-width:1;' x1='416' y1='203' x2='233' y2='167' />
|
32
|
+
<text style='fill: blue; font-size: 16px;' x='213.25' y='94'>value</text>
|
33
|
+
<line style='stroke:black; stroke-width:1;' x1='233' y1='137' x2='233' y2='101' />
|
34
|
+
<text style='fill: blue; font-size: 16px;' x='197.03125' y='28'>JSON-text</text>
|
35
|
+
<line style='stroke:black; stroke-width:1;' x1='233' y1='71' x2='233' y2='35' />
|
36
|
+
</svg>
|
@@ -0,0 +1,128 @@
|
|
1
|
+
<?xml version="1.0" standalone="no"?>
|
2
|
+
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
|
3
|
+
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
4
|
+
<svg width="2060.15625" height="766" version="1.1" xmlns="http://www.w3.org/2000/svg">
|
5
|
+
<text style='fill: green; font-size: 16px;' x='1597.078125' y='754'> home</text>
|
6
|
+
<text style='fill: green; font-size: 16px;' x='320.75' y='688'> 1</text>
|
7
|
+
<text style='fill: blue; font-size: 16px;' x='1597.265625' y='688'>string</text>
|
8
|
+
<line style='stroke:black; stroke-width:1;' x1='1617' y1='731' x2='1617' y2='695' />
|
9
|
+
<text style='fill: green; font-size: 16px;' x='1825.0' y='688'> green</text>
|
10
|
+
<text style='fill: green; font-size: 16px;' x='122.84375' y='622'> id</text>
|
11
|
+
<text style='fill: green; font-size: 16px;' x='220.7109375' y='622'> :</text>
|
12
|
+
<text style='fill: blue; font-size: 16px;' x='296.0' y='622'>number</text>
|
13
|
+
<line style='stroke:black; stroke-width:1;' x1='325' y1='665' x2='325' y2='629' />
|
14
|
+
<text style='fill: green; font-size: 16px;' x='685.109375' y='622'> A green door</text>
|
15
|
+
<text style='fill: blue; font-size: 16px;' x='1597.6328125' y='622'>value</text>
|
16
|
+
<line style='stroke:black; stroke-width:1;' x1='1617' y1='665' x2='1617' y2='629' />
|
17
|
+
<text style='fill: green; font-size: 16px;' x='1750.75' y='622'> ,</text>
|
18
|
+
<text style='fill: blue; font-size: 16px;' x='1825.984375' y='622'>string</text>
|
19
|
+
<line style='stroke:black; stroke-width:1;' x1='1846' y1='665' x2='1846' y2='629' />
|
20
|
+
<text style='fill: blue; font-size: 16px;' x='109.53125' y='556'>string</text>
|
21
|
+
<line style='stroke:black; stroke-width:1;' x1='129' y1='599' x2='129' y2='563' />
|
22
|
+
<text style='fill: blue; font-size: 16px;' x='164.265625' y='556'>name-separator</text>
|
23
|
+
<line style='stroke:black; stroke-width:1;' x1='223' y1='599' x2='223' y2='563' />
|
24
|
+
<text style='fill: blue; font-size: 16px;' x='305.0546875' y='556'>value</text>
|
25
|
+
<line style='stroke:black; stroke-width:1;' x1='325' y1='599' x2='325' y2='563' />
|
26
|
+
<text style='fill: green; font-size: 16px;' x='498.109375' y='556'> name</text>
|
27
|
+
<text style='fill: green; font-size: 16px;' x='609.8203125' y='556'> :</text>
|
28
|
+
<text style='fill: blue; font-size: 16px;' x='712.2421875' y='556'>string</text>
|
29
|
+
<polygon style='fill: white; stroke: black; stroke-width:1;' points='779 599 686 599 732 563' />
|
30
|
+
<text style='fill: green; font-size: 16px;' x='1119.0078125' y='556'> 12.50</text>
|
31
|
+
<text style='fill: green; font-size: 16px;' x='1538.2578125' y='556'> [</text>
|
32
|
+
<text style='fill: blue; font-size: 16px;' x='1575.671875' y='556'>array-items</text>
|
33
|
+
<line style='stroke:black; stroke-width:1;' x1='1617' y1='599' x2='1617' y2='563' />
|
34
|
+
<text style='fill: blue; font-size: 16px;' x='1695.0' y='556'>value-separator</text>
|
35
|
+
<line style='stroke:black; stroke-width:1;' x1='1752' y1='599' x2='1752' y2='563' />
|
36
|
+
<text style='fill: blue; font-size: 16px;' x='1826.3515625' y='556'>value</text>
|
37
|
+
<line style='stroke:black; stroke-width:1;' x1='1846' y1='599' x2='1846' y2='563' />
|
38
|
+
<text style='fill: green; font-size: 16px;' x='1914.8671875' y='556'> ]</text>
|
39
|
+
<text style='fill: blue; font-size: 16px;' x='195.921875' y='490'>member</text>
|
40
|
+
<line style='stroke:black; stroke-width:1;' x1='129' y1='533' x2='227' y2='497' />
|
41
|
+
<line style='stroke:black; stroke-width:1;' x1='223' y1='533' x2='227' y2='497' />
|
42
|
+
<line style='stroke:black; stroke-width:1;' x1='325' y1='533' x2='227' y2='497' />
|
43
|
+
<text style='fill: green; font-size: 16px;' x='423.859375' y='490'> ,</text>
|
44
|
+
<text style='fill: blue; font-size: 16px;' x='498.375' y='490'>string</text>
|
45
|
+
<line style='stroke:black; stroke-width:1;' x1='518' y1='533' x2='518' y2='497' />
|
46
|
+
<text style='fill: blue; font-size: 16px;' x='553.375' y='490'>name-separator</text>
|
47
|
+
<line style='stroke:black; stroke-width:1;' x1='612' y1='533' x2='612' y2='497' />
|
48
|
+
<text style='fill: blue; font-size: 16px;' x='712.609375' y='490'>value</text>
|
49
|
+
<line style='stroke:black; stroke-width:1;' x1='732' y1='533' x2='732' y2='497' />
|
50
|
+
<text style='fill: green; font-size: 16px;' x='926.921875' y='490'> price</text>
|
51
|
+
<text style='fill: green; font-size: 16px;' x='1035.2890625' y='490'> :</text>
|
52
|
+
<text style='fill: blue; font-size: 16px;' x='1110.578125' y='490'>number</text>
|
53
|
+
<line style='stroke:black; stroke-width:1;' x1='1139' y1='533' x2='1139' y2='497' />
|
54
|
+
<text style='fill: blue; font-size: 16px;' x='1499.15625' y='490'>begin-array</text>
|
55
|
+
<line style='stroke:black; stroke-width:1;' x1='1541' y1='533' x2='1541' y2='497' />
|
56
|
+
<text style='fill: blue; font-size: 16px;' x='1690.03125' y='490'>array-items</text>
|
57
|
+
<line style='stroke:black; stroke-width:1;' x1='1617' y1='533' x2='1731' y2='497' />
|
58
|
+
<line style='stroke:black; stroke-width:1;' x1='1752' y1='533' x2='1731' y2='497' />
|
59
|
+
<line style='stroke:black; stroke-width:1;' x1='1846' y1='533' x2='1731' y2='497' />
|
60
|
+
<text style='fill: blue; font-size: 16px;' x='1881.703125' y='490'>end-array</text>
|
61
|
+
<line style='stroke:black; stroke-width:1;' x1='1917' y1='533' x2='1917' y2='497' />
|
62
|
+
<text style='fill: blue; font-size: 16px;' x='183.109375' y='424'>member-list</text>
|
63
|
+
<line style='stroke:black; stroke-width:1;' x1='227' y1='467' x2='227' y2='431' />
|
64
|
+
<text style='fill: blue; font-size: 16px;' x='368.109375' y='424'>value-separator</text>
|
65
|
+
<line style='stroke:black; stroke-width:1;' x1='426' y1='467' x2='426' y2='431' />
|
66
|
+
<text style='fill: blue; font-size: 16px;' x='594.12109375' y='424'>member</text>
|
67
|
+
<line style='stroke:black; stroke-width:1;' x1='518' y1='467' x2='625' y2='431' />
|
68
|
+
<line style='stroke:black; stroke-width:1;' x1='612' y1='467' x2='625' y2='431' />
|
69
|
+
<line style='stroke:black; stroke-width:1;' x1='732' y1='467' x2='625' y2='431' />
|
70
|
+
<text style='fill: green; font-size: 16px;' x='849.859375' y='424'> ,</text>
|
71
|
+
<text style='fill: blue; font-size: 16px;' x='924.109375' y='424'>string</text>
|
72
|
+
<line style='stroke:black; stroke-width:1;' x1='944' y1='467' x2='944' y2='431' />
|
73
|
+
<text style='fill: blue; font-size: 16px;' x='978.84375' y='424'>name-separator</text>
|
74
|
+
<line style='stroke:black; stroke-width:1;' x1='1037' y1='467' x2='1037' y2='431' />
|
75
|
+
<text style='fill: blue; font-size: 16px;' x='1119.6328125' y='424'>value</text>
|
76
|
+
<line style='stroke:black; stroke-width:1;' x1='1139' y1='467' x2='1139' y2='431' />
|
77
|
+
<text style='fill: green; font-size: 16px;' x='1317.6875' y='424'> tags</text>
|
78
|
+
<text style='fill: green; font-size: 16px;' x='1423.8671875' y='424'> :</text>
|
79
|
+
<text style='fill: blue; font-size: 16px;' x='1709.4296875' y='424'>array</text>
|
80
|
+
<line style='stroke:black; stroke-width:1;' x1='1541' y1='467' x2='1729' y2='431' />
|
81
|
+
<line style='stroke:black; stroke-width:1;' x1='1731' y1='467' x2='1729' y2='431' />
|
82
|
+
<line style='stroke:black; stroke-width:1;' x1='1917' y1='467' x2='1729' y2='431' />
|
83
|
+
<text style='fill: blue; font-size: 16px;' x='382.208984375' y='358'>member-list</text>
|
84
|
+
<line style='stroke:black; stroke-width:1;' x1='227' y1='401' x2='426' y2='365' />
|
85
|
+
<line style='stroke:black; stroke-width:1;' x1='426' y1='401' x2='426' y2='365' />
|
86
|
+
<line style='stroke:black; stroke-width:1;' x1='625' y1='401' x2='426' y2='365' />
|
87
|
+
<text style='fill: blue; font-size: 16px;' x='794.109375' y='358'>value-separator</text>
|
88
|
+
<line style='stroke:black; stroke-width:1;' x1='852' y1='401' x2='852' y2='365' />
|
89
|
+
<text style='fill: blue; font-size: 16px;' x='1010.5' y='358'>member</text>
|
90
|
+
<line style='stroke:black; stroke-width:1;' x1='944' y1='401' x2='1042' y2='365' />
|
91
|
+
<line style='stroke:black; stroke-width:1;' x1='1037' y1='401' x2='1042' y2='365' />
|
92
|
+
<line style='stroke:black; stroke-width:1;' x1='1139' y1='401' x2='1042' y2='365' />
|
93
|
+
<text style='fill: green; font-size: 16px;' x='1238.4375' y='358'> ,</text>
|
94
|
+
<text style='fill: blue; font-size: 16px;' x='1312.6875' y='358'>string</text>
|
95
|
+
<line style='stroke:black; stroke-width:1;' x1='1333' y1='401' x2='1333' y2='365' />
|
96
|
+
<text style='fill: blue; font-size: 16px;' x='1367.421875' y='358'>name-separator</text>
|
97
|
+
<line style='stroke:black; stroke-width:1;' x1='1426' y1='401' x2='1426' y2='365' />
|
98
|
+
<text style='fill: blue; font-size: 16px;' x='1709.390625' y='358'>value</text>
|
99
|
+
<line style='stroke:black; stroke-width:1;' x1='1729' y1='401' x2='1729' y2='365' />
|
100
|
+
<text style='fill: green; font-size: 16px;' x='46.5078125' y='292'> {</text>
|
101
|
+
<text style='fill: blue; font-size: 16px;' x='689.9482421875' y='292'>member-list</text>
|
102
|
+
<line style='stroke:black; stroke-width:1;' x1='426' y1='335' x2='734' y2='299' />
|
103
|
+
<line style='stroke:black; stroke-width:1;' x1='852' y1='335' x2='734' y2='299' />
|
104
|
+
<line style='stroke:black; stroke-width:1;' x1='1042' y1='335' x2='734' y2='299' />
|
105
|
+
<text style='fill: blue; font-size: 16px;' x='1182.6875' y='292'>value-separator</text>
|
106
|
+
<line style='stroke:black; stroke-width:1;' x1='1240' y1='335' x2='1240' y2='299' />
|
107
|
+
<text style='fill: blue; font-size: 16px;' x='1499.66796875' y='292'>member</text>
|
108
|
+
<line style='stroke:black; stroke-width:1;' x1='1333' y1='335' x2='1531' y2='299' />
|
109
|
+
<line style='stroke:black; stroke-width:1;' x1='1426' y1='335' x2='1531' y2='299' />
|
110
|
+
<line style='stroke:black; stroke-width:1;' x1='1729' y1='335' x2='1531' y2='299' />
|
111
|
+
<text style='fill: green; font-size: 16px;' x='2003.09375' y='292'> }</text>
|
112
|
+
<text style='fill: blue; font-size: 16px;' x='5.0' y='226'>begin-object</text>
|
113
|
+
<line style='stroke:black; stroke-width:1;' x1='50' y1='269' x2='50' y2='233' />
|
114
|
+
<text style='fill: blue; font-size: 16px;' x='1088.40185546875' y='226'>member-list</text>
|
115
|
+
<line style='stroke:black; stroke-width:1;' x1='734' y1='269' x2='1132' y2='233' />
|
116
|
+
<line style='stroke:black; stroke-width:1;' x1='1240' y1='269' x2='1132' y2='233' />
|
117
|
+
<line style='stroke:black; stroke-width:1;' x1='1531' y1='269' x2='1132' y2='233' />
|
118
|
+
<text style='fill: blue; font-size: 16px;' x='1967.625' y='226'>end-object</text>
|
119
|
+
<line style='stroke:black; stroke-width:1;' x1='2006' y1='269' x2='2006' y2='233' />
|
120
|
+
<text style='fill: blue; font-size: 16px;' x='1005.3125' y='160'>object</text>
|
121
|
+
<line style='stroke:black; stroke-width:1;' x1='50' y1='203' x2='1028' y2='167' />
|
122
|
+
<line style='stroke:black; stroke-width:1;' x1='1132' y1='203' x2='1028' y2='167' />
|
123
|
+
<line style='stroke:black; stroke-width:1;' x1='2006' y1='203' x2='1028' y2='167' />
|
124
|
+
<text style='fill: blue; font-size: 16px;' x='1008.578125' y='94'>value</text>
|
125
|
+
<line style='stroke:black; stroke-width:1;' x1='1028' y1='137' x2='1028' y2='101' />
|
126
|
+
<text style='fill: blue; font-size: 16px;' x='992.359375' y='28'>JSON-text</text>
|
127
|
+
<line style='stroke:black; stroke-width:1;' x1='1028' y1='71' x2='1028' y2='35' />
|
128
|
+
</svg>
|
@@ -0,0 +1,88 @@
|
|
1
|
+
{"web-app": {
|
2
|
+
"servlet": [
|
3
|
+
{
|
4
|
+
"servlet-name": "cofaxCDS",
|
5
|
+
"servlet-class": "org.cofax.cds.CDSServlet",
|
6
|
+
"init-param": {
|
7
|
+
"configGlossary:installationAt": "Philadelphia, PA",
|
8
|
+
"configGlossary:adminEmail": "ksm@pobox.com",
|
9
|
+
"configGlossary:poweredBy": "Cofax",
|
10
|
+
"configGlossary:poweredByIcon": "/images/cofax.gif",
|
11
|
+
"configGlossary:staticPath": "/content/static",
|
12
|
+
"templateProcessorClass": "org.cofax.WysiwygTemplate",
|
13
|
+
"templateLoaderClass": "org.cofax.FilesTemplateLoader",
|
14
|
+
"templatePath": "templates",
|
15
|
+
"templateOverridePath": "",
|
16
|
+
"defaultListTemplate": "listTemplate.htm",
|
17
|
+
"defaultFileTemplate": "articleTemplate.htm",
|
18
|
+
"useJSP": false,
|
19
|
+
"jspListTemplate": "listTemplate.jsp",
|
20
|
+
"jspFileTemplate": "articleTemplate.jsp",
|
21
|
+
"cachePackageTagsTrack": 200,
|
22
|
+
"cachePackageTagsStore": 200,
|
23
|
+
"cachePackageTagsRefresh": 60,
|
24
|
+
"cacheTemplatesTrack": 100,
|
25
|
+
"cacheTemplatesStore": 50,
|
26
|
+
"cacheTemplatesRefresh": 15,
|
27
|
+
"cachePagesTrack": 200,
|
28
|
+
"cachePagesStore": 100,
|
29
|
+
"cachePagesRefresh": 10,
|
30
|
+
"cachePagesDirtyRead": 10,
|
31
|
+
"searchEngineListTemplate": "forSearchEnginesList.htm",
|
32
|
+
"searchEngineFileTemplate": "forSearchEngines.htm",
|
33
|
+
"searchEngineRobotsDb": "WEB-INF/robots.db",
|
34
|
+
"useDataStore": true,
|
35
|
+
"dataStoreClass": "org.cofax.SqlDataStore",
|
36
|
+
"redirectionClass": "org.cofax.SqlRedirection",
|
37
|
+
"dataStoreName": "cofax",
|
38
|
+
"dataStoreDriver": "com.microsoft.jdbc.sqlserver.SQLServerDriver",
|
39
|
+
"dataStoreUrl": "jdbc:microsoft:sqlserver://LOCALHOST:1433;DatabaseName=goon",
|
40
|
+
"dataStoreUser": "sa",
|
41
|
+
"dataStorePassword": "dataStoreTestQuery",
|
42
|
+
"dataStoreTestQuery": "SET NOCOUNT ON;select test='test';",
|
43
|
+
"dataStoreLogFile": "/usr/local/tomcat/logs/datastore.log",
|
44
|
+
"dataStoreInitConns": 10,
|
45
|
+
"dataStoreMaxConns": 100,
|
46
|
+
"dataStoreConnUsageLimit": 100,
|
47
|
+
"dataStoreLogLevel": "debug",
|
48
|
+
"maxUrlLength": 500}},
|
49
|
+
{
|
50
|
+
"servlet-name": "cofaxEmail",
|
51
|
+
"servlet-class": "org.cofax.cds.EmailServlet",
|
52
|
+
"init-param": {
|
53
|
+
"mailHost": "mail1",
|
54
|
+
"mailHostOverride": "mail2"}},
|
55
|
+
{
|
56
|
+
"servlet-name": "cofaxAdmin",
|
57
|
+
"servlet-class": "org.cofax.cds.AdminServlet"},
|
58
|
+
|
59
|
+
{
|
60
|
+
"servlet-name": "fileServlet",
|
61
|
+
"servlet-class": "org.cofax.cds.FileServlet"},
|
62
|
+
{
|
63
|
+
"servlet-name": "cofaxTools",
|
64
|
+
"servlet-class": "org.cofax.cms.CofaxToolsServlet",
|
65
|
+
"init-param": {
|
66
|
+
"templatePath": "toolstemplates/",
|
67
|
+
"log": 1,
|
68
|
+
"logLocation": "/usr/local/tomcat/logs/CofaxTools.log",
|
69
|
+
"logMaxSize": "",
|
70
|
+
"dataLog": 1,
|
71
|
+
"dataLogLocation": "/usr/local/tomcat/logs/dataLog.log",
|
72
|
+
"dataLogMaxSize": "",
|
73
|
+
"removePageCache": "/content/admin/remove?cache=pages&id=",
|
74
|
+
"removeTemplateCache": "/content/admin/remove?cache=templates&id=",
|
75
|
+
"fileTransferFolder": "/usr/local/tomcat/webapps/content/fileTransferFolder",
|
76
|
+
"lookInContext": 1,
|
77
|
+
"adminGroupID": 4,
|
78
|
+
"betaServer": true}}],
|
79
|
+
"servlet-mapping": {
|
80
|
+
"cofaxCDS": "/",
|
81
|
+
"cofaxEmail": "/cofaxutil/aemail/*",
|
82
|
+
"cofaxAdmin": "/admin/*",
|
83
|
+
"fileServlet": "/static/*",
|
84
|
+
"cofaxTools": "/tools/*"},
|
85
|
+
|
86
|
+
"taglib": {
|
87
|
+
"taglib-uri": "cofax.tld",
|
88
|
+
"taglib-location": "/WEB-INF/tlds/cofax.tld"}}}
|
@@ -0,0 +1,26 @@
|
|
1
|
+
## Demo calculator (iteration 1)
|
2
|
+
|
3
|
+
### Source files
|
4
|
+
This sample project consists of the following files:
|
5
|
+
- **calc_ast_builder.rb** containing the class `CalcASTBuilder` that creates
|
6
|
+
the abstract syntax trees (AST) representation for a given parse result.
|
7
|
+
|
8
|
+
- **calc_ast_nodes.rb** containing the node classes for implementing the AST.
|
9
|
+
The nodes have a 'interpret' method that computes of the numeric value of the
|
10
|
+
node.
|
11
|
+
|
12
|
+
- **calc_demo.rb** a demo command-line program.
|
13
|
+
It parses the expression in the command-line and outputs the numeric result
|
14
|
+
For more details, run the command-line: `calc_demo.rb`
|
15
|
+
|
16
|
+
- **calc_grammar.rb** implementing the class `CalcGrammar`.
|
17
|
+
The grammar is a list of (production) rules that specifies the syntax of math
|
18
|
+
expression. A little examination of the grammar will reveal interesting
|
19
|
+
grammar features such as:
|
20
|
+
* Recursive rules (e.g. terminal in left-side of rule also appears in right-hand side)
|
21
|
+
|
22
|
+
- **calc_lexer.rb** implementing the class `CalcLexer`.
|
23
|
+
The purpose of the lexer is to break the math expression into a sequence of tokens.
|
24
|
+
|
25
|
+
- **calc_parser.rb** implementing a `CalcParser` class.
|
26
|
+
The parser processes the tokens stream from the lexer and delivers its results
|
@@ -0,0 +1,55 @@
|
|
1
|
+
## Demo calculator (iteration 2)
|
2
|
+
Compared to the first iteration, this calculator supports:
|
3
|
+
- the exponentiation operator '**',
|
4
|
+
- the unary '-' operator (sign change),
|
5
|
+
- the PI and E constants,
|
6
|
+
- and several functions from Ruby's Math module.
|
7
|
+
|
8
|
+
|
9
|
+
It also prints out:
|
10
|
+
- The Concrete Syntax Tree (CST), a complete but verbose parse tree representation
|
11
|
+
- The Abstract Syntax Tree (AST), a customized parse tree representation that is more
|
12
|
+
convenient for further processing (here calculation.).
|
13
|
+
|
14
|
+
BUILT-IN OPERATORS AND FUNCTIONS
|
15
|
+
---------------------------------
|
16
|
+
Operators: `+`, `-`, `*`, `/`, `**`
|
17
|
+
Numeric constants: `PI` (= 3.14159...), `E` (= 2.71828...)
|
18
|
+
Functions from Ruby's Math module:
|
19
|
+
`sqrt` (square root), `cbrt` (cubic root),
|
20
|
+
`exp` (exponential), `ln` (natural or neperian logarithm), `log10` (logarithm in base 10)
|
21
|
+
Trigonometric functions: `sin`, `cos`, `tan`
|
22
|
+
Inverse trigonometric functions: `asin`, `acos`, `atan`
|
23
|
+
|
24
|
+
|
25
|
+
### Source files
|
26
|
+
This sample project consists of the following files:
|
27
|
+
- **calc_ast_builder.rb** containing the class `CalcASTBuilder` that creates
|
28
|
+
the abstract syntax trees (AST) representation for a given parse result.
|
29
|
+
|
30
|
+
- **calc_ast_nodes.rb** containing the node classes for implementing the AST.
|
31
|
+
The nodes have a 'interpret' method that computes of the numeric value of the
|
32
|
+
node.
|
33
|
+
|
34
|
+
- **calc_demo.rb** a demo command-line program.
|
35
|
+
It parses the expression in the command-line and outputs the numeric result
|
36
|
+
For more details, run the command-line: `calc_demo.rb`
|
37
|
+
|
38
|
+
- **calc_grammar.rb** implementing the class `CalcGrammar`.
|
39
|
+
The grammar is a list of (production) rules that specifies the syntax of math
|
40
|
+
expression. A little examination of the grammar will reveal interesting
|
41
|
+
grammar features such as:
|
42
|
+
* Recursive rules (e.g. terminal in left-side of rule also appears in right-hand side)
|
43
|
+
|
44
|
+
- **calc_lexer.rb** implementing the class `CalcLexer`.
|
45
|
+
The purpose of the lexer is to break the math expression into a sequence of tokens.
|
46
|
+
|
47
|
+
- **calc_parser.rb** implementing a `CalcParser` class.
|
48
|
+
The parser processes the tokens stream from the lexer and delivers its results
|
49
|
+
|
50
|
+
- **sample_result.txt** a sample text containing the output of calculator for the expression:
|
51
|
+
2 * 3 + (1 + 3 ** 2). It illustrates the huge difference in size and nesting between the CST
|
52
|
+
(Concrete Syntax Tree) and the AST (Abstract Syntax Tree) representations. The generation of CSTs
|
53
|
+
comes out-of-the-box with **Rley**. Creating ASTs requires customization. Here, the class for the
|
54
|
+
AST nodes of the AST are defined in the **calc_ast_nodes.rb** and the methods for assembling the
|
55
|
+
AST from the grammar rules are implemented in the `CalcASTBuilder` class.
|