Skip to content

Commit b50b162

Browse files
committed
fix critics
1 parent 8b896d8 commit b50b162

File tree

7 files changed

+126
-91
lines changed

7 files changed

+126
-91
lines changed

repository/EarleyAnalyzer/JEAnalysisAEGrammarTest.class.st

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
11
Class {
2-
#name : #JEAnalysisAEGrammarTest,
3-
#superclass : #TestCase,
2+
#name : 'JEAnalysisAEGrammarTest',
3+
#superclass : 'TestCase',
44
#instVars : [
55
'grammar'
66
],
7-
#category : #'EarleyAnalyzer-Tests'
7+
#category : 'EarleyAnalyzer-Tests',
8+
#package : 'EarleyAnalyzer',
9+
#tag : 'Tests'
810
}
911

10-
{ #category : #initialization }
12+
{ #category : 'running' }
1113
JEAnalysisAEGrammarTest >> setUp [
14+
15+
super setUp.
1216
grammar := JEExemplar AE
1317
]
1418

15-
{ #category : #tests }
19+
{ #category : 'tests' }
1620
JEAnalysisAEGrammarTest >> testAnalizeAcceptsExpression [
1721
| stats chart |
1822
stats := grammar analyzeAccepts: 'a+a*a'.
@@ -27,8 +31,9 @@ JEAnalysisAEGrammarTest >> testAnalizeAcceptsExpression [
2731
self assert: chart sixth size equals: 9
2832
]
2933

30-
{ #category : #tests }
34+
{ #category : 'tests' }
3135
JEAnalysisAEGrammarTest >> testAnalizeParseExpression [
36+
3237
| stats chart forest |
3338
stats := grammar analyzeParse: 'a+a*a'.
3439
self assert: (stats at: 'accepts').
@@ -44,5 +49,4 @@ JEAnalysisAEGrammarTest >> testAnalizeParseExpression [
4449
self assert: forest isNotNil.
4550
self deny: forest isAmbiguous.
4651
self assert: forest numberOfTrees equals: 1
47-
4852
]

repository/EarleyAnalyzer/JEAnalysisBKGrammarTest.class.st

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
11
Class {
2-
#name : #JEAnalysisBKGrammarTest,
3-
#superclass : #TestCase,
2+
#name : 'JEAnalysisBKGrammarTest',
3+
#superclass : 'TestCase',
44
#instVars : [
55
'grammar'
66
],
7-
#category : #'EarleyAnalyzer-Tests'
7+
#category : 'EarleyAnalyzer-Tests',
8+
#package : 'EarleyAnalyzer',
9+
#tag : 'Tests'
810
}
911

10-
{ #category : #initialization }
12+
{ #category : 'running' }
1113
JEAnalysisBKGrammarTest >> setUp [
14+
15+
super setUp.
1216
grammar := JEExemplar BK
1317
]
1418

15-
{ #category : #tests }
19+
{ #category : 'tests' }
1620
JEAnalysisBKGrammarTest >> testAnalizeAccepts1X [
1721
| stats chart |
1822
stats := grammar analyzeAccepts: 'x'.
@@ -22,7 +26,7 @@ JEAnalysisBKGrammarTest >> testAnalizeAccepts1X [
2226
self assert: chart second size equals: 13
2327
]
2428

25-
{ #category : #tests }
29+
{ #category : 'tests' }
2630
JEAnalysisBKGrammarTest >> testAnalizeAccepts2X [
2731
| stats chart |
2832
stats := grammar analyzeAccepts: 'xx'.
@@ -33,7 +37,7 @@ JEAnalysisBKGrammarTest >> testAnalizeAccepts2X [
3337
self assert: chart third size equals: 13
3438
]
3539

36-
{ #category : #tests }
40+
{ #category : 'tests' }
3741
JEAnalysisBKGrammarTest >> testAnalizeAccepts3X [
3842
| stats chart |
3943
stats := grammar analyzeAccepts: 'xxx'.
@@ -45,7 +49,7 @@ JEAnalysisBKGrammarTest >> testAnalizeAccepts3X [
4549
self assert: chart fourth size equals: 13
4650
]
4751

48-
{ #category : #tests }
52+
{ #category : 'tests' }
4953
JEAnalysisBKGrammarTest >> testAnalizeAccepts4X [
5054
| stats chart |
5155
stats := grammar analyzeAccepts: 'xxxx'.
@@ -58,7 +62,7 @@ JEAnalysisBKGrammarTest >> testAnalizeAccepts4X [
5862
self assert: chart fifth size equals: 13
5963
]
6064

61-
{ #category : #tests }
65+
{ #category : 'tests' }
6266
JEAnalysisBKGrammarTest >> testAnalizeAcceptsEpsilon [
6367
| stats chart |
6468
stats := grammar analyzeAccepts: ''.

repository/EarleyAnalyzer/JEAnalyticalForestParser.class.st

Lines changed: 34 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,39 +2,43 @@
22
to help in analize Earley's forest parser.
33
"
44
Class {
5-
#name : #JEAnalyticalForestParser,
6-
#superclass : #JEForestParser,
7-
#category : #'EarleyAnalyzer-Core'
5+
#name : 'JEAnalyticalForestParser',
6+
#superclass : 'JEForestParser',
7+
#category : 'EarleyAnalyzer-Core',
8+
#package : 'EarleyAnalyzer',
9+
#tag : 'Core'
810
}
911

10-
{ #category : #public }
12+
{ #category : 'public' }
1113
JEAnalyticalForestParser >> parse: words [
1214
"it returns some stats"
1315

14-
^ [ | chart forest |
15-
chart := self evaluate: words.
16-
forest := chart last
17-
like: (grammar startRule dotAtEnd startedAt: chart first)
18-
ifFound: [ :found | JEParseForest given: (self newForestFrom: found) of: grammar ]
19-
ifNone: [ JEFailure failedAtLast: chart last ].
20-
OrderedDictionary
21-
newFrom:
22-
{('chart' -> chart).
23-
('accepts' -> true).
24-
('forest' -> forest).
25-
('chart stats'
26-
->
27-
(OrderedDictionary
28-
newFrom:
29-
{('each column size' -> (chart collect: [ :each | each size ])).
30-
('total item count' -> (chart collect: [ :each | each size ]) sum)})).
31-
('words size' -> words size)} ]
32-
on: JEFailure
33-
do: [ :ex |
34-
Dictionary
35-
newFrom:
36-
{('expected symbols' -> ex expectedSymbols).
37-
('position' -> ex position).
38-
('accepts' -> false).
39-
('message' -> ex messageText)} ]
16+
^ [
17+
| chart forest |
18+
chart := self evaluate: words.
19+
forest := chart last
20+
like:
21+
(grammar startRule dotAtEnd startedAt: chart first)
22+
ifFound: [ :found |
23+
JEParseForest
24+
given: (self newForestFrom: found)
25+
of: grammar ]
26+
ifNone: [ JEFailure failedAtLast: chart last ].
27+
OrderedDictionary newFrom: {
28+
('chart' -> chart).
29+
('accepts' -> true).
30+
('forest' -> forest).
31+
('chart stats' -> (OrderedDictionary newFrom: {
32+
('each column size'
33+
-> (chart collect: [ :each | each size ])).
34+
('total item count'
35+
-> (chart collect: [ :each | each size ]) sum) })).
36+
('words size' -> words size) } ]
37+
on: JEFailure
38+
do: [ :ex |
39+
Dictionary newFrom: {
40+
('expected symbols' -> ex expectedSymbols).
41+
('position' -> ex position).
42+
('accepts' -> false).
43+
('message' -> ex messageText) } ]
4044
]

repository/EarleyAnalyzer/JEAnalyticalRecognizer.class.st

Lines changed: 40 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -4,80 +4,79 @@ collect some stats.
44
55
"
66
Class {
7-
#name : #JEAnalyticalRecognizer,
8-
#superclass : #JERecognizer,
7+
#name : 'JEAnalyticalRecognizer',
8+
#superclass : 'JERecognizer',
99
#instVars : [
1010
'addCount',
1111
'moveDotForwardCount',
1212
'completeCount',
1313
'predictCount',
1414
'scanCount'
1515
],
16-
#category : #'EarleyAnalyzer-Core'
16+
#category : 'EarleyAnalyzer-Core',
17+
#package : 'EarleyAnalyzer',
18+
#tag : 'Core'
1719
}
1820

19-
{ #category : #public }
21+
{ #category : 'public' }
2022
JEAnalyticalRecognizer >> accepts: words [
2123
"it returns some stats"
2224

23-
^ [ | chart |
24-
chart := self evaluate: words.
25-
OrderedDictionary
26-
newFrom:
27-
{('chart' -> chart).
28-
('accepts'
29-
-> (chart last includes: (grammar startRule dotAtEnd startedAt: chart first))).
30-
('chart stats'
31-
->
32-
(OrderedDictionary
33-
newFrom:
34-
{('each column size' -> (chart collect: [ :each | each size ])).
35-
('total item count' -> (chart collect: [ :each | each size ]) sum)})).
36-
('column stats'
37-
->
38-
(OrderedDictionary
39-
newFrom:
40-
{('moveDotForward send count' -> moveDotForwardCount).
41-
('add send count' -> addCount).
42-
('total message send count' -> (moveDotForwardCount + addCount))})).
43-
('complete count' -> completeCount).
44-
('predict count' -> predictCount).
45-
('scan count' -> scanCount).
46-
('total operation count' -> (completeCount + predictCount + scanCount)).
47-
('words size' -> (words size))} ]
48-
on: JEFailure
49-
do: [ :ex |
50-
Dictionary
51-
newFrom:
52-
{('expected symbols' -> ex expectedSymbols).
53-
('position' -> ex position).
54-
('accepts' -> false).
55-
('message' -> ex messageText)} ]
25+
^ [
26+
| chart |
27+
chart := self evaluate: words.
28+
OrderedDictionary newFrom: {
29+
('chart' -> chart).
30+
('accepts' -> (chart last includes:
31+
(grammar startRule dotAtEnd startedAt: chart first))).
32+
('chart stats' -> (OrderedDictionary newFrom: {
33+
('each column size'
34+
-> (chart collect: [ :each | each size ])).
35+
('total item count'
36+
-> (chart collect: [ :each | each size ]) sum) })).
37+
('column stats' -> (OrderedDictionary newFrom: {
38+
('moveDotForward send count' -> moveDotForwardCount).
39+
('add send count' -> addCount).
40+
('total message send count'
41+
-> (moveDotForwardCount + addCount)) })).
42+
('complete count' -> completeCount).
43+
('predict count' -> predictCount).
44+
('scan count' -> scanCount).
45+
('total operation count'
46+
-> (completeCount + predictCount + scanCount)).
47+
('words size' -> words size) } ]
48+
on: JEFailure
49+
do: [ :ex |
50+
Dictionary newFrom: {
51+
('expected symbols' -> ex expectedSymbols).
52+
('position' -> ex position).
53+
('accepts' -> false).
54+
('message' -> ex messageText) } ]
5655
]
5756

58-
{ #category : #'private operations' }
57+
{ #category : 'private operations' }
5958
JEAnalyticalRecognizer >> complete: item [
6059
super complete: item.
6160
moveDotForwardCount := moveDotForwardCount
6261
+ item predictionItemsWithSymbolAtDotIsHead size.
6362
completeCount := completeCount + 1
6463
]
6564

66-
{ #category : #initialization }
65+
{ #category : 'initialization' }
6766
JEAnalyticalRecognizer >> initialize [
6867
super initialize.
6968
addCount := moveDotForwardCount := 0.
7069
completeCount := predictCount := scanCount := 0
7170
]
7271

73-
{ #category : #'private operations' }
72+
{ #category : 'private operations' }
7473
JEAnalyticalRecognizer >> predict: item [
7574
super predict: item.
7675
addCount := addCount + (grammar alternativesOf: item symbolAtDot) size.
7776
predictCount := predictCount + 1
7877
]
7978

80-
{ #category : #'private operations' }
79+
{ #category : 'private operations' }
8180
JEAnalyticalRecognizer >> scan: item with: word at: column [
8281
super scan: item with: word at: column.
8382
moveDotForwardCount := moveDotForwardCount + 1.
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
Extension { #name : #JEGrammar }
1+
Extension { #name : 'JEGrammar' }
22

3-
{ #category : #'*EarleyAnalyzer' }
3+
{ #category : '*EarleyAnalyzer' }
44
JEGrammar >> analyzeAccepts: words [
55
^ (JEAnalyticalRecognizer given: self) accepts: words
66
]
77

8-
{ #category : #'*EarleyAnalyzer' }
8+
{ #category : '*EarleyAnalyzer' }
99
JEGrammar >> analyzeParse: words [
1010
^ (JEAnalyticalForestParser given: self) parse: words
1111
]
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
"
2+
Please describe the package using the class comment of the included manifest class. The manifest class also includes other additional metadata for the package. These meta data are used by other tools such as the SmalllintManifestChecker and the critics Browser
3+
"
4+
Class {
5+
#name : 'ManifestEarleyAnalyzer',
6+
#superclass : 'PackageManifest',
7+
#category : 'EarleyAnalyzer-Manifest',
8+
#package : 'EarleyAnalyzer',
9+
#tag : 'Manifest'
10+
}
11+
12+
{ #category : 'code-critics' }
13+
ManifestEarleyAnalyzer class >> ruleImplementedNotSentRuleV1FalsePositive [
14+
15+
<ignoreForCoverage>
16+
^ #(#(#(#RGMethodDefinition #(#JEAnalysisAEGrammarTest #setUp #false)) #'2025-08-30T19:55:36.673617-03:00') #(#(#RGMethodDefinition #(#JEAnalyticalRecognizer #initialize #false)) #'2025-08-30T19:55:36.673579-03:00') #(#(#RGMethodDefinition #(#JEAnalyticalRecognizer #predict: #false)) #'2025-08-30T19:55:36.673187-03:00') #(#(#RGMethodDefinition #(#JEAnalyticalRecognizer #scan:with:at: #false)) #'2025-08-30T19:55:36.673552-03:00') #(#(#RGMethodDefinition #(#JEAnalysisBKGrammarTest #setUp #false)) #'2025-08-30T19:55:36.672773-03:00') #(#(#RGMethodDefinition #(#JEAnalyticalRecognizer #complete: #false)) #'2025-08-30T19:55:36.673487-03:00') )
17+
]
18+
19+
{ #category : 'code-critics' }
20+
ManifestEarleyAnalyzer class >> ruleUncommonMessageSendRuleV1FalsePositive [
21+
22+
<ignoreForCoverage>
23+
^ #(#(#(#RGMethodDefinition #(#JEAnalysisAEGrammarTest #setUp #false)) #'2025-08-30T19:55:36.702418-03:00') #(#(#RGMethodDefinition #(#JEAnalysisBKGrammarTest #setUp #false)) #'2025-08-30T19:55:36.70235-03:00') )
24+
]
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Package { #name : #EarleyAnalyzer }
1+
Package { #name : 'EarleyAnalyzer' }

0 commit comments

Comments
 (0)