Portability: fixes for Smalltalk/X
* Do not use detect:ifFound: - not present in Smalltalk/X
* Removed leftover debugging code (Halt if:, ...)
* Do not use `aClass methods`, use `aClass methodDictionary values`
* Do not use #allPairsDo; - not present in Smalltalk/X
* Do not use #crShow: - not present in Smalltalk/X
* On Smalltalk?X use Filename - there's no FileReference in Smalltalk/X
* Do not use CharacterSet, use String
--- a/compiler/PPCCompiler.st Sun May 10 06:46:56 2015 +0100
+++ b/compiler/PPCCompiler.st Sun May 10 14:20:24 2015 +0100
@@ -190,9 +190,13 @@
!
codeHaltIfShiftPressed
- arguments debug ifTrue: [
- self add: 'Halt ifShiftPressed.'
+ arguments debug ifTrue: [
+ ((Smalltalk respondsTo: #isSmalltalkX) and:[Smalltalk isSmalltalkX]) ifFalse:[
+ self add: 'Halt ifShiftPressed.'
+ ]
]
+
+ "Modified: / 10-05-2015 / 07:39:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
codeNextToken
@@ -260,10 +264,17 @@
"e.g. '234znak 43 ) 2' asLegalSelector = #v234znak432"
| toUse |
- toUse := string select: [:char | char isAlphaNumeric or: [ char = $_ ] ].
+
+ toUse := string select: [:char | char isAlphaNumeric or: [ char = $_ ] ].
(toUse isEmpty or: [ toUse first isLetter not ])
ifTrue: [ toUse := 'v', toUse ].
- ^ toUse uncapitalized asSymbol.
+ toUse first isUppercase ifFalse:[
+ toUse := toUse copy.
+ toUse at: 1 put: toUse first asLowercase
+ ].
+ ^toUse
+
+ "Modified: / 10-05-2015 / 07:29:57 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
idFor: object
--- a/compiler/PPCLL1Visitor.st Sun May 10 06:46:56 2015 +0100
+++ b/compiler/PPCLL1Visitor.st Sun May 10 14:20:24 2015 +0100
@@ -20,11 +20,15 @@
].
(firsts asIdentitySet size = firsts size) ifFalse: [ ^ false ].
- firsts allPairsDo: [ :e1 :e2 |
- e1 == e2 ifFalse: [
- (e1 overlapsWith: e2) ifTrue: [ ^ false ] ].
+ firsts do:[:e1 |
+ firsts do:[:e2 |
+ e1 == e2 ifFalse: [
+ (e1 overlapsWith: e2) ifTrue: [ ^ false ] ].
+ ].
].
^ true
+
+ "Modified: / 10-05-2015 / 07:27:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
startsWithToken: node
--- a/compiler/PPCOptimizeChoices.st Sun May 10 06:46:56 2015 +0100
+++ b/compiler/PPCOptimizeChoices.st Sun May 10 14:20:24 2015 +0100
@@ -12,15 +12,23 @@
!PPCOptimizeChoices methodsFor:'as yet unclassified'!
hasCommonPrefix: nodes
- | firstSets |
+ | firstSets firstSetValues |
firstSets := IdentityDictionary new.
nodes do: [ :node |
firstSets at: node put: node firstSetWithProductions.
].
- firstSets values allPairsDo: [ :p1 :p2 | (p1 = p2) ifFalse: [ ^ false ] ].
+ firstSetValues := firstSets values.
+
+ firstSetValues do: [ :p1 |
+ firstSetValues do:[ :p2 |
+ (p1 = p2) ifFalse: [ ^ false ]
+ ].
+ ].
^ true
+
+ "Modified: / 10-05-2015 / 07:32:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
visitChoiceNode: node
--- a/compiler/PPCTokenizingCodeGenerator.st Sun May 10 06:46:56 2015 +0100
+++ b/compiler/PPCTokenizingCodeGenerator.st Sun May 10 14:20:24 2015 +0100
@@ -12,9 +12,10 @@
!PPCTokenizingCodeGenerator methodsFor:'visiting'!
visitChoiceNode: node
-" true ifTrue: [ ^ super visitChoiceNode: node ]."
+" true ifTrue: [ ^ super visitChoiceNode: node ]."
"HACK alert: We are inside token..."
- node firstSetWithTokens detect: [ :e | e isTokenNode not ] ifFound: [ ^ super visitChoiceNode: node ].
+
+ (node firstSetWithTokens contains: [ :e | e isTokenNode not ]) ifTrue: [ ^ super visitChoiceNode: node ].
node children do: [ :child |
| tokenMethodName |
@@ -43,6 +44,8 @@
].
compiler codeError: 'no choice found'.
+
+ "Modified: / 10-05-2015 / 07:37:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
visitDeterministicChoiceNode: node
--- a/compiler/PPCTokenizingVisitor.st Sun May 10 06:46:56 2015 +0100
+++ b/compiler/PPCTokenizingVisitor.st Sun May 10 14:20:24 2015 +0100
@@ -12,7 +12,6 @@
!PPCTokenizingVisitor methodsFor:'hooks'!
afterAccept: node retval: retval
- Halt if: [ node name = 'start' ].
self isRoot ifTrue: [
| tokenizerNode |
self change.
@@ -31,7 +30,8 @@
yourself
].
^ retval
-
+
+ "Modified: / 10-05-2015 / 07:27:22 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
eofToken
--- a/compiler/tests/PPCLL1VisitorTest.st Sun May 10 06:46:56 2015 +0100
+++ b/compiler/tests/PPCLL1VisitorTest.st Sun May 10 14:20:24 2015 +0100
@@ -9,6 +9,7 @@
category:'PetitCompiler-Tests-Visitors'
!
+
!PPCLL1VisitorTest methodsFor:'as yet unclassified'!
setUp
@@ -139,3 +140,10 @@
! !
+!PPCLL1VisitorTest class methodsFor:'documentation'!
+
+version_HG
+
+ ^ '$Changeset: <not expanded> $'
+! !
+
--- a/compiler/tests/PPCPrototype1OptimizingTest.st Sun May 10 06:46:56 2015 +0100
+++ b/compiler/tests/PPCPrototype1OptimizingTest.st Sun May 10 14:20:24 2015 +0100
@@ -150,13 +150,13 @@
tree := self optimize: [:ctx | nil] asParser star.
((Smalltalk respondsTo:#isSmalltalkX) and:[ Smalltalk isSmalltalkX ])
- ifTrue:[ self skip: 'not supported in St/X' ].
+ ifTrue:[ self skipIf: true description: 'not supported in St/X' ].
self assert: tree type: PPCStarNode.
self assert: tree child type: PPCPluggableNode.
self assert: tree child isMarkedForInline.
- "Modified: / 23-04-2015 / 12:19:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 10-05-2015 / 07:30:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
testInlinePredicate
--- a/compiler/tests/PPCPrototype1Test.st Sun May 10 06:46:56 2015 +0100
+++ b/compiler/tests/PPCPrototype1Test.st Sun May 10 14:20:24 2015 +0100
@@ -552,14 +552,16 @@
parser := identifier / kw.
parser := parser compileWithConfiguration: configuration.
self assert: parser class methodDictionary size = 8.
- self assert: (parser class methods anySatisfy: [ :m | m selector = #kw ]).
- self assert: (parser class methods anySatisfy: [ :m | m selector = #kw_fast ]).
+ self assert: (parser class methodDictionary values anySatisfy: [ :m | m selector = #kw ]).
+ self assert: (parser class methodDictionary values anySatisfy: [ :m | m selector = #kw_fast ]).
self assert: parser parse: 'foo'.
self assert: result inputValue = 'foo'.
self assert: parser parse: 'false'.
self assert: result inputValue = 'false'.
+
+ "Modified: / 10-05-2015 / 07:33:19 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!PPCPrototype1Test methodsFor:'tests - ids'!
--- a/compiler/tests/PPCompiledExpressionGrammarResource.st Sun May 10 06:46:56 2015 +0100
+++ b/compiler/tests/PPCompiledExpressionGrammarResource.st Sun May 10 14:20:24 2015 +0100
@@ -25,7 +25,7 @@
"Modified: / 01-05-2015 / 14:40:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
-
+
!PPCompiledExpressionGrammarResource class methodsFor:'documentation'!
version_HG
--- a/compiler/tests/extras/Make.proto Sun May 10 06:46:56 2015 +0100
+++ b/compiler/tests/extras/Make.proto Sun May 10 14:20:24 2015 +0100
@@ -129,7 +129,18 @@
# BEGINMAKEDEPEND --- do not remove this line; make depend needs it
+$(OUTDIR)PPCCompiledJavaVerificationTest.$(O) PPCCompiledJavaVerificationTest.$(H): PPCCompiledJavaVerificationTest.st $(INCLUDE_TOP)/stx/goodies/petitparser/tests/PPAbstractParserTest.$(H) $(INCLUDE_TOP)/stx/goodies/sunit/TestAsserter.$(H) $(INCLUDE_TOP)/stx/goodies/sunit/TestCase.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR)
+$(OUTDIR)PPCResources.$(O) PPCResources.$(H): PPCResources.st $(INCLUDE_TOP)/stx/goodies/sunit/TestAsserter.$(H) $(INCLUDE_TOP)/stx/goodies/sunit/TestResource.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR)
+$(OUTDIR)PPCSmalltalkTests.$(O) PPCSmalltalkTests.$(H): PPCSmalltalkTests.st $(INCLUDE_TOP)/stx/goodies/sunit/TestAsserter.$(H) $(INCLUDE_TOP)/stx/goodies/sunit/TestCase.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR)
+$(OUTDIR)PPCSmalltalkVerificationTest.$(O) PPCSmalltalkVerificationTest.$(H): PPCSmalltalkVerificationTest.st $(INCLUDE_TOP)/stx/goodies/petitparser/tests/PPAbstractParserTest.$(H) $(INCLUDE_TOP)/stx/goodies/sunit/TestAsserter.$(H) $(INCLUDE_TOP)/stx/goodies/sunit/TestCase.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR)
+$(OUTDIR)PPCompiledJavaResource.$(O) PPCompiledJavaResource.$(H): PPCompiledJavaResource.st $(INCLUDE_TOP)/stx/goodies/sunit/TestAsserter.$(H) $(INCLUDE_TOP)/stx/goodies/sunit/TestResource.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR)
+$(OUTDIR)PPCompiledSmalltalkGrammarResource.$(O) PPCompiledSmalltalkGrammarResource.$(H): PPCompiledSmalltalkGrammarResource.st $(INCLUDE_TOP)/stx/goodies/sunit/TestAsserter.$(H) $(INCLUDE_TOP)/stx/goodies/sunit/TestResource.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR)
+$(OUTDIR)PPCompiledSmalltalkGrammarTests.$(O) PPCompiledSmalltalkGrammarTests.$(H): PPCompiledSmalltalkGrammarTests.st $(INCLUDE_TOP)/stx/goodies/petitparser/tests/PPAbstractParserTest.$(H) $(INCLUDE_TOP)/stx/goodies/petitparser/tests/PPCompositeParserTest.$(H) $(INCLUDE_TOP)/stx/goodies/sunit/TestAsserter.$(H) $(INCLUDE_TOP)/stx/goodies/sunit/TestCase.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR)
+$(OUTDIR)PPTokenizedSmalltalkGrammarResource.$(O) PPTokenizedSmalltalkGrammarResource.$(H): PPTokenizedSmalltalkGrammarResource.st $(INCLUDE_TOP)/stx/goodies/sunit/TestAsserter.$(H) $(INCLUDE_TOP)/stx/goodies/sunit/TestResource.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR)
+$(OUTDIR)PPTokenizedSmalltalkGrammarTests.$(O) PPTokenizedSmalltalkGrammarTests.$(H): PPTokenizedSmalltalkGrammarTests.st $(INCLUDE_TOP)/stx/goodies/petitparser/tests/PPAbstractParserTest.$(H) $(INCLUDE_TOP)/stx/goodies/petitparser/tests/PPCompositeParserTest.$(H) $(INCLUDE_TOP)/stx/goodies/sunit/TestAsserter.$(H) $(INCLUDE_TOP)/stx/goodies/sunit/TestCase.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR)
$(OUTDIR)stx_goodies_petitparser_compiler_tests_extras.$(O) stx_goodies_petitparser_compiler_tests_extras.$(H): stx_goodies_petitparser_compiler_tests_extras.st $(INCLUDE_TOP)/stx/libbasic/LibraryDefinition.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(INCLUDE_TOP)/stx/libbasic/ProjectDefinition.$(H) $(STCHDR)
+$(OUTDIR)PPCompiledSmalltalkVerificationTest.$(O) PPCompiledSmalltalkVerificationTest.$(H): PPCompiledSmalltalkVerificationTest.st $(INCLUDE_TOP)/stx/goodies/petitparser/compiler/tests/extras/PPCSmalltalkVerificationTest.$(H) $(INCLUDE_TOP)/stx/goodies/petitparser/tests/PPAbstractParserTest.$(H) $(INCLUDE_TOP)/stx/goodies/sunit/TestAsserter.$(H) $(INCLUDE_TOP)/stx/goodies/sunit/TestCase.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR)
+$(OUTDIR)PPTokenizedSmalltalkVerificationTest.$(O) PPTokenizedSmalltalkVerificationTest.$(H): PPTokenizedSmalltalkVerificationTest.st $(INCLUDE_TOP)/stx/goodies/petitparser/compiler/tests/extras/PPCSmalltalkVerificationTest.$(H) $(INCLUDE_TOP)/stx/goodies/petitparser/tests/PPAbstractParserTest.$(H) $(INCLUDE_TOP)/stx/goodies/sunit/TestAsserter.$(H) $(INCLUDE_TOP)/stx/goodies/sunit/TestCase.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR)
# ENDMAKEDEPEND --- do not remove this line
--- a/compiler/tests/extras/Make.spec Sun May 10 06:46:56 2015 +0100
+++ b/compiler/tests/extras/Make.spec Sun May 10 14:20:24 2015 +0100
@@ -51,13 +51,35 @@
STCWARNINGS=-warnNonStandard
COMMON_CLASSES= \
+ PPCCompiledJavaVerificationTest \
+ PPCResources \
+ PPCSmalltalkTests \
+ PPCSmalltalkVerificationTest \
+ PPCompiledJavaResource \
+ PPCompiledSmalltalkGrammarResource \
+ PPCompiledSmalltalkGrammarTests \
+ PPTokenizedSmalltalkGrammarResource \
+ PPTokenizedSmalltalkGrammarTests \
stx_goodies_petitparser_compiler_tests_extras \
+ PPCompiledSmalltalkVerificationTest \
+ PPTokenizedSmalltalkVerificationTest \
COMMON_OBJS= \
+ $(OUTDIR_SLASH)PPCCompiledJavaVerificationTest.$(O) \
+ $(OUTDIR_SLASH)PPCResources.$(O) \
+ $(OUTDIR_SLASH)PPCSmalltalkTests.$(O) \
+ $(OUTDIR_SLASH)PPCSmalltalkVerificationTest.$(O) \
+ $(OUTDIR_SLASH)PPCompiledJavaResource.$(O) \
+ $(OUTDIR_SLASH)PPCompiledSmalltalkGrammarResource.$(O) \
+ $(OUTDIR_SLASH)PPCompiledSmalltalkGrammarTests.$(O) \
+ $(OUTDIR_SLASH)PPTokenizedSmalltalkGrammarResource.$(O) \
+ $(OUTDIR_SLASH)PPTokenizedSmalltalkGrammarTests.$(O) \
$(OUTDIR_SLASH)stx_goodies_petitparser_compiler_tests_extras.$(O) \
+ $(OUTDIR_SLASH)PPCompiledSmalltalkVerificationTest.$(O) \
+ $(OUTDIR_SLASH)PPTokenizedSmalltalkVerificationTest.$(O) \
--- a/compiler/tests/extras/PPCCompiledJavaVerificationTest.st Sun May 10 06:46:56 2015 +0100
+++ b/compiler/tests/extras/PPCCompiledJavaVerificationTest.st Sun May 10 14:20:24 2015 +0100
@@ -9,9 +9,6 @@
category:'PetitCompiler-Extras-Tests-Java'
!
-PPCCompiledJavaVerificationTest comment:''
-!
-
!PPCCompiledJavaVerificationTest class methodsFor:'as yet unclassified'!
resources
--- a/compiler/tests/extras/PPCResources.st Sun May 10 06:46:56 2015 +0100
+++ b/compiler/tests/extras/PPCResources.st Sun May 10 14:20:24 2015 +0100
@@ -9,8 +9,6 @@
category:'PetitCompiler-Extras-Tests-Support'
!
-PPCResources comment:''
-!
!PPCResources methodsFor:'java'!
@@ -23,7 +21,9 @@
!
javaLangMath
- ^ (FileStream fileNamed: '../java-src/java/lang/Math.java') contents
+ ^ (FileStream fileNamed: '../java-src/java/lang/Math.java') contents asString
+
+ "Modified: / 10-05-2015 / 14:11:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
javaSourcesBig
@@ -32,7 +32,9 @@
!
javaUtilTimer
- ^ (FileStream fileNamed: '../java-src/java/util/Timer.java') contents
+ ^ (FileStream fileNamed: '../java-src/java/util/Timer.java') contents asString
+
+ "Modified: / 10-05-2015 / 14:11:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
workingJavaInDirectory: directory
@@ -57,11 +59,24 @@
readDirectory: directory
| file |
- file := directory asFileReference.
- file exists ifTrue: [
+
+ ( (Smalltalk respondsTo: #isSmalltalkX) and:[ Smalltalk isSmalltalkX ] ) ifTrue:[
+ file := directory asFilename.
+ file exists ifFalse:[
+ self error: 'Directory does not exist'.
+ ].
+ ^ file recursiveDirectoryContentsAsFilenames select:[:each | each isRegularFile ]
+ ] ifFalse:[
+ "Assuming Pharo..."
+
+ file := directory asFileReference.
+ file exists ifFalse: [
+ self error: 'Directory does not exist'.
+ ].
^ file allFiles
- ].
- ^ #()
+ ]
+
+ "Modified: / 10-05-2015 / 07:54:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!PPCResources methodsFor:'smalltalk'!
@@ -92,3 +107,10 @@
^ (self smalltalkInDirectory: '../smalltalk-src/') copyFrom: 1 to: 5000.
! !
+!PPCResources class methodsFor:'documentation'!
+
+version_HG
+
+ ^ '$Changeset: <not expanded> $'
+! !
+
--- a/compiler/tests/extras/PPCSmalltalkTests.st Sun May 10 06:46:56 2015 +0100
+++ b/compiler/tests/extras/PPCSmalltalkTests.st Sun May 10 14:20:24 2015 +0100
@@ -9,9 +9,6 @@
category:'PetitCompiler-Extras-Tests-Smalltalk'
!
-PPCSmalltalkTests comment:''
-!
-
!PPCSmalltalkTests methodsFor:'as yet unclassified'!
setUp
--- a/compiler/tests/extras/PPCSmalltalkVerificationTest.st Sun May 10 06:46:56 2015 +0100
+++ b/compiler/tests/extras/PPCSmalltalkVerificationTest.st Sun May 10 14:20:24 2015 +0100
@@ -9,9 +9,6 @@
category:'PetitCompiler-Extras-Tests-Smalltalk'
!
-PPCSmalltalkVerificationTest comment:''
-!
-
!PPCSmalltalkVerificationTest class methodsFor:'as yet unclassified'!
isAbstract
--- a/compiler/tests/extras/PPCompiledJavaResource.st Sun May 10 06:46:56 2015 +0100
+++ b/compiler/tests/extras/PPCompiledJavaResource.st Sun May 10 14:20:24 2015 +0100
@@ -9,9 +9,6 @@
category:'PetitCompiler-Extras-Tests-Java'
!
-PPCompiledJavaResource comment:''
-!
-
!PPCompiledJavaResource methodsFor:'as yet unclassified'!
setUp
@@ -23,6 +20,8 @@
time := Time millisecondsToRun: [
PPJavaSyntax new compileWithConfiguration: configuration.
].
- Transcript crShow: 'Java Syntax compiled in: ', time asString, 'ms'.
+ Transcript show: 'Java Syntax compiled in: '; show: time asString; show: 'ms'; cr.
+
+ "Modified: / 10-05-2015 / 07:45:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
--- a/compiler/tests/extras/PPCompiledJavaSyntaxTest.st Sun May 10 06:46:56 2015 +0100
+++ b/compiler/tests/extras/PPCompiledJavaSyntaxTest.st Sun May 10 14:20:24 2015 +0100
@@ -9,8 +9,6 @@
category:'PetitCompiler-Extras-Tests-Java'
!
-PPCompiledJavaSyntaxTest comment:''
-!
!PPCompiledJavaSyntaxTest class methodsFor:'as yet unclassified'!
@@ -574,3 +572,10 @@
rule: #methodDeclaration
! !
+!PPCompiledJavaSyntaxTest class methodsFor:'documentation'!
+
+version_HG
+
+ ^ '$Changeset: <not expanded> $'
+! !
+
--- a/compiler/tests/extras/PPCompiledSmalltalkGrammarResource.st Sun May 10 06:46:56 2015 +0100
+++ b/compiler/tests/extras/PPCompiledSmalltalkGrammarResource.st Sun May 10 14:20:24 2015 +0100
@@ -9,9 +9,6 @@
category:'PetitCompiler-Extras-Tests-Smalltalk'
!
-PPCompiledSmalltalkGrammarResource comment:''
-!
-
!PPCompiledSmalltalkGrammarResource methodsFor:'as yet unclassified'!
setUp
@@ -22,7 +19,8 @@
time := Time millisecondsToRun: [
PPSmalltalkGrammar new compileWithConfiguration: configuration.
].
- Transcript crShow: 'Smalltalk Grammar compiled in: ', time asString, 'ms'.
-
+ Transcript show: 'Smalltalk Grammar compiled in: '; show: time asString; show: 'ms'; cr.
+
+ "Modified: / 10-05-2015 / 07:57:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
--- a/compiler/tests/extras/PPCompiledSmalltalkGrammarTests.st Sun May 10 06:46:56 2015 +0100
+++ b/compiler/tests/extras/PPCompiledSmalltalkGrammarTests.st Sun May 10 14:20:24 2015 +0100
@@ -9,9 +9,6 @@
category:'PetitCompiler-Extras-Tests-Smalltalk'
!
-PPCompiledSmalltalkGrammarTests comment:''
-!
-
!PPCompiledSmalltalkGrammarTests class methodsFor:'accessing'!
--- a/compiler/tests/extras/PPCompiledSmalltalkVerificationTest.st Sun May 10 06:46:56 2015 +0100
+++ b/compiler/tests/extras/PPCompiledSmalltalkVerificationTest.st Sun May 10 14:20:24 2015 +0100
@@ -9,8 +9,6 @@
category:'PetitCompiler-Extras-Tests-Smalltalk'
!
-PPCompiledSmalltalkVerificationTest comment:''
-!
!PPCompiledSmalltalkVerificationTest class methodsFor:'as yet unclassified'!
@@ -40,3 +38,10 @@
super testSmalltalkObject
! !
+!PPCompiledSmalltalkVerificationTest class methodsFor:'documentation'!
+
+version_HG
+
+ ^ '$Changeset: <not expanded> $'
+! !
+
--- a/compiler/tests/extras/PPTokenizedSmalltalkGrammarResource.st Sun May 10 06:46:56 2015 +0100
+++ b/compiler/tests/extras/PPTokenizedSmalltalkGrammarResource.st Sun May 10 14:20:24 2015 +0100
@@ -9,9 +9,6 @@
category:'PetitCompiler-Extras-Tests-Smalltalk'
!
-PPTokenizedSmalltalkGrammarResource comment:''
-!
-
!PPTokenizedSmalltalkGrammarResource methodsFor:'as yet unclassified'!
setUp
@@ -22,8 +19,9 @@
time := Time millisecondsToRun: [
PPSmalltalkGrammar new compileWithConfiguration: configuration.
].
- Transcript crShow: 'Smalltalk Grammar tokenized in: ', time asString, 'ms'.
-
+ Transcript show: 'Smalltalk Grammar tokenized in: '; show: time asString; show: 'ms'; cr.
+
+ "Modified: / 10-05-2015 / 07:55:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
tearDown
--- a/compiler/tests/extras/PPTokenizedSmalltalkGrammarTests.st Sun May 10 06:46:56 2015 +0100
+++ b/compiler/tests/extras/PPTokenizedSmalltalkGrammarTests.st Sun May 10 14:20:24 2015 +0100
@@ -9,9 +9,6 @@
category:'PetitCompiler-Extras-Tests-Smalltalk'
!
-PPTokenizedSmalltalkGrammarTests comment:''
-!
-
!PPTokenizedSmalltalkGrammarTests class methodsFor:'accessing'!
resources
--- a/compiler/tests/extras/PPTokenizedSmalltalkVerificationTest.st Sun May 10 06:46:56 2015 +0100
+++ b/compiler/tests/extras/PPTokenizedSmalltalkVerificationTest.st Sun May 10 14:20:24 2015 +0100
@@ -9,9 +9,6 @@
category:'PetitCompiler-Extras-Tests-Smalltalk'
!
-PPTokenizedSmalltalkVerificationTest comment:''
-!
-
!PPTokenizedSmalltalkVerificationTest class methodsFor:'as yet unclassified'!
resources
--- a/compiler/tests/extras/bc.mak Sun May 10 06:46:56 2015 +0100
+++ b/compiler/tests/extras/bc.mak Sun May 10 14:20:24 2015 +0100
@@ -76,7 +76,18 @@
# BEGINMAKEDEPEND --- do not remove this line; make depend needs it
+$(OUTDIR)PPCCompiledJavaVerificationTest.$(O) PPCCompiledJavaVerificationTest.$(H): PPCCompiledJavaVerificationTest.st $(INCLUDE_TOP)\stx\goodies\petitparser\tests\PPAbstractParserTest.$(H) $(INCLUDE_TOP)\stx\goodies\sunit\TestAsserter.$(H) $(INCLUDE_TOP)\stx\goodies\sunit\TestCase.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR)
+$(OUTDIR)PPCResources.$(O) PPCResources.$(H): PPCResources.st $(INCLUDE_TOP)\stx\goodies\sunit\TestAsserter.$(H) $(INCLUDE_TOP)\stx\goodies\sunit\TestResource.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR)
+$(OUTDIR)PPCSmalltalkTests.$(O) PPCSmalltalkTests.$(H): PPCSmalltalkTests.st $(INCLUDE_TOP)\stx\goodies\sunit\TestAsserter.$(H) $(INCLUDE_TOP)\stx\goodies\sunit\TestCase.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR)
+$(OUTDIR)PPCSmalltalkVerificationTest.$(O) PPCSmalltalkVerificationTest.$(H): PPCSmalltalkVerificationTest.st $(INCLUDE_TOP)\stx\goodies\petitparser\tests\PPAbstractParserTest.$(H) $(INCLUDE_TOP)\stx\goodies\sunit\TestAsserter.$(H) $(INCLUDE_TOP)\stx\goodies\sunit\TestCase.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR)
+$(OUTDIR)PPCompiledJavaResource.$(O) PPCompiledJavaResource.$(H): PPCompiledJavaResource.st $(INCLUDE_TOP)\stx\goodies\sunit\TestAsserter.$(H) $(INCLUDE_TOP)\stx\goodies\sunit\TestResource.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR)
+$(OUTDIR)PPCompiledSmalltalkGrammarResource.$(O) PPCompiledSmalltalkGrammarResource.$(H): PPCompiledSmalltalkGrammarResource.st $(INCLUDE_TOP)\stx\goodies\sunit\TestAsserter.$(H) $(INCLUDE_TOP)\stx\goodies\sunit\TestResource.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR)
+$(OUTDIR)PPCompiledSmalltalkGrammarTests.$(O) PPCompiledSmalltalkGrammarTests.$(H): PPCompiledSmalltalkGrammarTests.st $(INCLUDE_TOP)\stx\goodies\petitparser\tests\PPAbstractParserTest.$(H) $(INCLUDE_TOP)\stx\goodies\petitparser\tests\PPCompositeParserTest.$(H) $(INCLUDE_TOP)\stx\goodies\sunit\TestAsserter.$(H) $(INCLUDE_TOP)\stx\goodies\sunit\TestCase.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR)
+$(OUTDIR)PPTokenizedSmalltalkGrammarResource.$(O) PPTokenizedSmalltalkGrammarResource.$(H): PPTokenizedSmalltalkGrammarResource.st $(INCLUDE_TOP)\stx\goodies\sunit\TestAsserter.$(H) $(INCLUDE_TOP)\stx\goodies\sunit\TestResource.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR)
+$(OUTDIR)PPTokenizedSmalltalkGrammarTests.$(O) PPTokenizedSmalltalkGrammarTests.$(H): PPTokenizedSmalltalkGrammarTests.st $(INCLUDE_TOP)\stx\goodies\petitparser\tests\PPAbstractParserTest.$(H) $(INCLUDE_TOP)\stx\goodies\petitparser\tests\PPCompositeParserTest.$(H) $(INCLUDE_TOP)\stx\goodies\sunit\TestAsserter.$(H) $(INCLUDE_TOP)\stx\goodies\sunit\TestCase.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR)
$(OUTDIR)stx_goodies_petitparser_compiler_tests_extras.$(O) stx_goodies_petitparser_compiler_tests_extras.$(H): stx_goodies_petitparser_compiler_tests_extras.st $(INCLUDE_TOP)\stx\libbasic\LibraryDefinition.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(INCLUDE_TOP)\stx\libbasic\ProjectDefinition.$(H) $(STCHDR)
+$(OUTDIR)PPCompiledSmalltalkVerificationTest.$(O) PPCompiledSmalltalkVerificationTest.$(H): PPCompiledSmalltalkVerificationTest.st $(INCLUDE_TOP)\stx\goodies\petitparser\compiler\tests\extras\PPCSmalltalkVerificationTest.$(H) $(INCLUDE_TOP)\stx\goodies\petitparser\tests\PPAbstractParserTest.$(H) $(INCLUDE_TOP)\stx\goodies\sunit\TestAsserter.$(H) $(INCLUDE_TOP)\stx\goodies\sunit\TestCase.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR)
+$(OUTDIR)PPTokenizedSmalltalkVerificationTest.$(O) PPTokenizedSmalltalkVerificationTest.$(H): PPTokenizedSmalltalkVerificationTest.st $(INCLUDE_TOP)\stx\goodies\petitparser\compiler\tests\extras\PPCSmalltalkVerificationTest.$(H) $(INCLUDE_TOP)\stx\goodies\petitparser\tests\PPAbstractParserTest.$(H) $(INCLUDE_TOP)\stx\goodies\sunit\TestAsserter.$(H) $(INCLUDE_TOP)\stx\goodies\sunit\TestCase.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR)
# ENDMAKEDEPEND --- do not remove this line
--- a/compiler/tests/extras/libInit.cc Sun May 10 06:46:56 2015 +0100
+++ b/compiler/tests/extras/libInit.cc Sun May 10 14:20:24 2015 +0100
@@ -27,7 +27,18 @@
void _libstx_goodies_petitparser_compiler_tests_extras_Init(pass, __pRT__, snd)
OBJ snd; struct __vmData__ *__pRT__; {
__BEGIN_PACKAGE2__("libstx_goodies_petitparser_compiler_tests_extras", _libstx_goodies_petitparser_compiler_tests_extras_Init, "stx:goodies/petitparser/compiler/tests/extras");
+_PPCCompiledJavaVerificationTest_Init(pass,__pRT__,snd);
+_PPCResources_Init(pass,__pRT__,snd);
+_PPCSmalltalkTests_Init(pass,__pRT__,snd);
+_PPCSmalltalkVerificationTest_Init(pass,__pRT__,snd);
+_PPCompiledJavaResource_Init(pass,__pRT__,snd);
+_PPCompiledSmalltalkGrammarResource_Init(pass,__pRT__,snd);
+_PPCompiledSmalltalkGrammarTests_Init(pass,__pRT__,snd);
+_PPTokenizedSmalltalkGrammarResource_Init(pass,__pRT__,snd);
+_PPTokenizedSmalltalkGrammarTests_Init(pass,__pRT__,snd);
_stx_137goodies_137petitparser_137compiler_137tests_137extras_Init(pass,__pRT__,snd);
+_PPCompiledSmalltalkVerificationTest_Init(pass,__pRT__,snd);
+_PPTokenizedSmalltalkVerificationTest_Init(pass,__pRT__,snd);
__END_PACKAGE__();
--- a/compiler/tests/extras/stx_goodies_petitparser_compiler_tests_extras.st Sun May 10 06:46:56 2015 +0100
+++ b/compiler/tests/extras/stx_goodies_petitparser_compiler_tests_extras.st Sun May 10 14:20:24 2015 +0100
@@ -10,6 +10,32 @@
!
+!stx_goodies_petitparser_compiler_tests_extras class methodsFor:'accessing'!
+
+additionalClassAttributesFor: aClass
+ "Answers additional set of class attributes for given class
+ Individual project definitions may override this method, but
+ overriding method should always merge its attributes with result
+ of 'super additionalClassAttributesFor: aClass'.
+
+ Here, we add #autoload attributes to all test cases and
+ test resources, as they are not neccessary for the package
+ and should not be compiled (because of unwanted dependency
+ on stx:goodies/sunit package)
+
+ But not make them autoloaded when the package is separate
+ test-package - by conventions such package should by named
+ #'module:package/subpackage/tests'
+ "
+ (TestCase notNil and:[aClass inheritsFrom: TestCase]) ifTrue:[^#()].
+ (TestResource notNil and:[aClass inheritsFrom: TestResource]) ifTrue:[^#()].
+
+
+ ^ super additionalClassAttributesFor: aClass
+
+ "Created: / 10-05-2015 / 14:17:51 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
!stx_goodies_petitparser_compiler_tests_extras class methodsFor:'accessing - monticello'!
monticelloLastMergedVersionInfo
@@ -101,19 +127,19 @@
^ #(
"<className> or (<className> attributes...) in load order"
- (PPCCompiledJavaVerificationTest autoload)
- (PPCResources autoload)
- (PPCSmalltalkTests autoload)
- (PPCSmalltalkVerificationTest autoload)
- (PPCompiledJavaResource autoload)
+ PPCCompiledJavaVerificationTest
+ PPCResources
+ PPCSmalltalkTests
+ PPCSmalltalkVerificationTest
+ PPCompiledJavaResource
(PPCompiledJavaSyntaxTest autoload)
- (PPCompiledSmalltalkGrammarResource autoload)
- (PPCompiledSmalltalkGrammarTests autoload)
- (PPTokenizedSmalltalkGrammarResource autoload)
- (PPTokenizedSmalltalkGrammarTests autoload)
+ PPCompiledSmalltalkGrammarResource
+ PPCompiledSmalltalkGrammarTests
+ PPTokenizedSmalltalkGrammarResource
+ PPTokenizedSmalltalkGrammarTests
#'stx_goodies_petitparser_compiler_tests_extras'
- (PPCompiledSmalltalkVerificationTest autoload)
- (PPTokenizedSmalltalkVerificationTest autoload)
+ PPCompiledSmalltalkVerificationTest
+ PPTokenizedSmalltalkVerificationTest
)
!
--- a/islands/JavaParser.st Sun May 10 06:46:56 2015 +0100
+++ b/islands/JavaParser.st Sun May 10 14:20:24 2015 +0100
@@ -1,5 +1,7 @@
"{ Package: 'stx:goodies/petitparser/islands' }"
+"{ NameSpace: Smalltalk }"
+
PPCompositeParser subclass:#JavaParser
instanceVariableNames:'javaClass classDef classBody methodDef arguments methodBody
methodName block modifiers classId type throws javaClassIsland
--- a/islands/PPInputEnds.st Sun May 10 06:46:56 2015 +0100
+++ b/islands/PPInputEnds.st Sun May 10 14:20:24 2015 +0100
@@ -1,5 +1,7 @@
"{ Package: 'stx:goodies/petitparser/islands' }"
+"{ NameSpace: Smalltalk }"
+
PPParser subclass:#PPInputEnds
instanceVariableNames:''
classVariableNames:''
--- a/islands/PPIsland.st Sun May 10 06:46:56 2015 +0100
+++ b/islands/PPIsland.st Sun May 10 14:20:24 2015 +0100
@@ -1,5 +1,7 @@
"{ Package: 'stx:goodies/petitparser/islands' }"
+"{ NameSpace: Smalltalk }"
+
PPParser subclass:#PPIsland
instanceVariableNames:'island afterWaterParser beforeWaterParser context
afterWaterDelegate beforeWaterDelegate water'
--- a/islands/PPMemoizingIsland.st Sun May 10 06:46:56 2015 +0100
+++ b/islands/PPMemoizingIsland.st Sun May 10 14:20:24 2015 +0100
@@ -1,5 +1,7 @@
"{ Package: 'stx:goodies/petitparser/islands' }"
+"{ NameSpace: Smalltalk }"
+
PPIsland subclass:#PPMemoizingIsland
instanceVariableNames:'rootParser memoizationDictionaries'
classVariableNames:''
--- a/islands/PPNonEmptyParser.st Sun May 10 06:46:56 2015 +0100
+++ b/islands/PPNonEmptyParser.st Sun May 10 14:20:24 2015 +0100
@@ -1,5 +1,7 @@
"{ Package: 'stx:goodies/petitparser/islands' }"
+"{ NameSpace: Smalltalk }"
+
PPDelegateParser subclass:#PPNonEmptyParser
instanceVariableNames:''
classVariableNames:''
--- a/islands/PPWater.st Sun May 10 06:46:56 2015 +0100
+++ b/islands/PPWater.st Sun May 10 14:20:24 2015 +0100
@@ -1,5 +1,7 @@
"{ Package: 'stx:goodies/petitparser/islands' }"
+"{ NameSpace: Smalltalk }"
+
PPDelegateParser subclass:#PPWater
instanceVariableNames:'waterToken context'
classVariableNames:''
--- a/islands/RobustXmlFeedParser.st Sun May 10 06:46:56 2015 +0100
+++ b/islands/RobustXmlFeedParser.st Sun May 10 14:20:24 2015 +0100
@@ -1,5 +1,7 @@
"{ Package: 'stx:goodies/petitparser/islands' }"
+"{ NameSpace: Smalltalk }"
+
XmlFeedParser subclass:#RobustXmlFeedParser
instanceVariableNames:''
classVariableNames:''
--- a/islands/XmlFeedParser.st Sun May 10 06:46:56 2015 +0100
+++ b/islands/XmlFeedParser.st Sun May 10 14:20:24 2015 +0100
@@ -1,5 +1,7 @@
"{ Package: 'stx:goodies/petitparser/islands' }"
+"{ NameSpace: Smalltalk }"
+
PPCompositeParser subclass:#XmlFeedParser
instanceVariableNames:'item openItem itemContent closeItem openShoplist shoplistContent
closeShoplist shoplist simpleElement stringValue'
--- a/islands/stx_goodies_petitparser_islands.st Sun May 10 06:46:56 2015 +0100
+++ b/islands/stx_goodies_petitparser_islands.st Sun May 10 14:20:24 2015 +0100
@@ -1,5 +1,7 @@
"{ Package: 'stx:goodies/petitparser/islands' }"
+"{ NameSpace: Smalltalk }"
+
LibraryDefinition subclass:#stx_goodies_petitparser_islands
instanceVariableNames:''
classVariableNames:''
@@ -7,12 +9,6 @@
category:'* Projects & Packages *'
!
-!stx_goodies_petitparser_islands class methodsFor:'documentation'!
-
-extensionsVersion_HG
-
- ^ '$Changeset: <not expanded> $'
-! !
!stx_goodies_petitparser_islands class methodsFor:'accessing - monticello'!
--- a/islands/tests/FirstFollowNextTests.st Sun May 10 06:46:56 2015 +0100
+++ b/islands/tests/FirstFollowNextTests.st Sun May 10 14:20:24 2015 +0100
@@ -1,5 +1,7 @@
"{ Package: 'stx:goodies/petitparser/islands/tests' }"
+"{ NameSpace: Smalltalk }"
+
TestCase subclass:#FirstFollowNextTests
instanceVariableNames:''
classVariableNames:''
--- a/islands/tests/JavaParserTest.st Sun May 10 06:46:56 2015 +0100
+++ b/islands/tests/JavaParserTest.st Sun May 10 14:20:24 2015 +0100
@@ -1,5 +1,7 @@
"{ Package: 'stx:goodies/petitparser/islands/tests' }"
+"{ NameSpace: Smalltalk }"
+
PPCompositeParserTest subclass:#JavaParserTest
instanceVariableNames:'debugResult context'
classVariableNames:''
--- a/islands/tests/PPIslandTest.st Sun May 10 06:46:56 2015 +0100
+++ b/islands/tests/PPIslandTest.st Sun May 10 14:20:24 2015 +0100
@@ -1,5 +1,7 @@
"{ Package: 'stx:goodies/petitparser/islands/tests' }"
+"{ NameSpace: Smalltalk }"
+
PPAbstractParserTest subclass:#PPIslandTest
instanceVariableNames:'result context'
classVariableNames:''
--- a/islands/tests/PPMemoizingIslandTest.st Sun May 10 06:46:56 2015 +0100
+++ b/islands/tests/PPMemoizingIslandTest.st Sun May 10 14:20:24 2015 +0100
@@ -1,5 +1,7 @@
"{ Package: 'stx:goodies/petitparser/islands/tests' }"
+"{ NameSpace: Smalltalk }"
+
PPIslandTest subclass:#PPMemoizingIslandTest
instanceVariableNames:''
classVariableNames:''
--- a/islands/tests/RobustXmlFeedParserTest.st Sun May 10 06:46:56 2015 +0100
+++ b/islands/tests/RobustXmlFeedParserTest.st Sun May 10 14:20:24 2015 +0100
@@ -1,5 +1,7 @@
"{ Package: 'stx:goodies/petitparser/islands/tests' }"
+"{ NameSpace: Smalltalk }"
+
PPCompositeParserTest subclass:#RobustXmlFeedParserTest
instanceVariableNames:'debugResult'
classVariableNames:''
--- a/islands/tests/XmlFeedParserTest.st Sun May 10 06:46:56 2015 +0100
+++ b/islands/tests/XmlFeedParserTest.st Sun May 10 14:20:24 2015 +0100
@@ -1,5 +1,7 @@
"{ Package: 'stx:goodies/petitparser/islands/tests' }"
+"{ NameSpace: Smalltalk }"
+
PPCompositeParserTest subclass:#XmlFeedParserTest
instanceVariableNames:'debugResult'
classVariableNames:''
--- a/islands/tests/stx_goodies_petitparser_islands_tests.st Sun May 10 06:46:56 2015 +0100
+++ b/islands/tests/stx_goodies_petitparser_islands_tests.st Sun May 10 14:20:24 2015 +0100
@@ -1,5 +1,7 @@
"{ Package: 'stx:goodies/petitparser/islands/tests' }"
+"{ NameSpace: Smalltalk }"
+
LibraryDefinition subclass:#stx_goodies_petitparser_islands_tests
instanceVariableNames:''
classVariableNames:''
--- a/parsers/java/Make.proto Sun May 10 06:46:56 2015 +0100
+++ b/parsers/java/Make.proto Sun May 10 14:20:24 2015 +0100
@@ -34,7 +34,7 @@
# add the path(es) here:,
# ********** OPTIONAL: MODIFY the next lines ***
# LOCALINCLUDES=-Ifoo -Ibar
-LOCALINCLUDES= -I$(INCLUDE_TOP)/stx/goodies/petitparser -I$(INCLUDE_TOP)/stx/goodies/petitparser/tests -I$(INCLUDE_TOP)/stx/goodies/sunit -I$(INCLUDE_TOP)/stx/libbasic -I$(INCLUDE_TOP)/stx/libbasic2
+LOCALINCLUDES= -I$(INCLUDE_TOP)/stx/goodies/petitparser -I$(INCLUDE_TOP)/stx/goodies/petitparser/tests -I$(INCLUDE_TOP)/stx/goodies/sunit -I$(INCLUDE_TOP)/stx/libbasic
# if you need any additional defines for embedded C code,
--- a/parsers/java/PJPackageDeclarationNode.st Sun May 10 06:46:56 2015 +0100
+++ b/parsers/java/PJPackageDeclarationNode.st Sun May 10 14:20:24 2015 +0100
@@ -9,6 +9,7 @@
category:'PetitJava-AST'
!
+
!PJPackageDeclarationNode methodsFor:'accessing'!
nameNode
@@ -26,3 +27,10 @@
aVisitor visitPackageDeclarationNode: self
! !
+!PJPackageDeclarationNode class methodsFor:'documentation'!
+
+version_HG
+
+ ^ '$Changeset: <not expanded> $'
+! !
+
--- a/parsers/java/PJSyntaxNode.st Sun May 10 06:46:56 2015 +0100
+++ b/parsers/java/PJSyntaxNode.st Sun May 10 14:20:24 2015 +0100
@@ -9,6 +9,3 @@
category:'PetitJava-AST'
!
-PJSyntaxNode comment:''
-!
-
--- a/parsers/java/PPJavaLexicon.st Sun May 10 06:46:56 2015 +0100
+++ b/parsers/java/PPJavaLexicon.st Sun May 10 14:20:24 2015 +0100
@@ -1,1 +1,547 @@
-"{ Package: 'stx:goodies/petitparser/parsers/java' }"
"{ NameSpace: Smalltalk }"
PPCompositeParser subclass:#PPJavaLexicon
instanceVariableNames:'unicodeEscape rawInputCharacter unicodeMarker hexDigit
lineTerminator unicodeInputCharacter inputElements sub
inputElement whiteSpace comment javaToken keyword literal
separator operator identifier traditionalComment endOfLineComment
commentTail charactersInLine commentTailStar notStar
notStarNotSlash inputCharacter booleanLiteral nullLiteral
identifierChars javaLetter javaLetterOrDigit keywords
floatingPointLiteral integerLiteral characterLiteral
stringLiteral hexIntegerLiteral octalIntegerLiteral
decimalIntegerLiteral decimalNumeral integerTypeSuffix hexNumeral
octalNumeral nonZeroDigit digits hexDigits octalDigits octalDigit
hexadecimalFloatingPointLiteral decimalFloatingPointLiteral
exponentPart floatTypeSuffix exponentIndicator signedInteger sign
hexSignificand binaryExponent binaryExponentIndicator
escapeSequence singleCharacter stringCharacters stringCharacter
octalEscape zeroToThree input operators separators trueToken
falseToken nullToken'
classVariableNames:''
poolDictionaries:''
category:'PetitJava-Core'
!
PPJavaLexicon comment:'A parser with a definitions for some basic Java gramar parts
Grammar rules follow as closely as possible the specification found in "The Java Language Specification Third Edition"
URL = '
!
!PPJavaLexicon class methodsFor:'accessing'!
ignoredNames
"Answer a collection of instance-variables that should not be automatically initialized with productions, but that are used internal to the composite parser."
| newArray |
newArray := Array new: ((self namesToIgnore size) + (super ignoredNames size)).
newArray
replaceFrom: 1
to: self namesToIgnore size
with: self namesToIgnore.
newArray
replaceFrom: (self namesToIgnore size + 1)
to: newArray size
with: super ignoredNames.
^newArray
!
namesToIgnore
^#('keywords' 'operators' 'separators')
! !
!PPJavaLexicon methodsFor:'accessing'!
start
"Default start production."
^ input end
! !
!PPJavaLexicon methodsFor:'grammar-comments'!
charactersInLine
^ inputCharacter plus
!
comment
"traditional -> /*
endOfLine -> //"
^ traditionalComment / endOfLineComment
!
commentTail
^ ('*' asParser , commentTailStar ) /
(notStar , commentTail)
!
commentTailStar
^ ('/' asParser ) /
('*' asParser , commentTailStar ) /
(notStarNotSlash , commentTail )
!
endOfLineComment
^ '//' asParser , charactersInLine optional
!
notStar
^ ('*' asParser not , inputCharacter)/lineTerminator
!
notStarNotSlash
^ lineTerminator / ((PPPredicateObjectParser anyOf: '*/') not , inputCharacter )
!
traditionalComment
^ '/*' asParser , commentTail
! !
!PPJavaLexicon methodsFor:'grammar-identifiers'!
identifier
^ self asToken: (((keyword not) , (booleanLiteral not) , (nullLiteral not) , identifierChars ))
!
identifierChars
^ javaLetter plus , javaLetterOrDigit star
!
javaLetter
^ (#letter asParser) / (PPPredicateObjectParser anyOf: '_$')
!
javaLetterOrDigit
^ javaLetter / (#digit asParser)
! !
!PPJavaLexicon methodsFor:'grammar-input'!
input
^ (inputElements optional) , (sub optional)
!
inputElement
^ whiteSpace / comment / javaToken
!
inputElements
^ inputElement plus
!
javaToken
^ identifier / keyword / literal / separator / operator
!
sub
^ (Character value: 26) asParser
! !
!PPJavaLexicon methodsFor:'grammar-keywords'!
keyword
| keywordParsers |
keywordParsers := keywords keys asSortedCollection collect: [:eachKey | keywords at: eachKey ].
^ self asToken: ( (keywordParsers reduce: [ :a :b | a / b ]) )
"Modified (format): / 21-04-2015 / 15:27:29 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!PPJavaLexicon methodsFor:'grammar-lineTerminators'!
inputCharacter
^(lineTerminator not) , unicodeInputCharacter ==> #second
!
lineTerminator
self flag: 'Hack alert - should be fixed immediately in PJTraditionalCommentsNode>>comment:'.
^ (((Character codePoint: 10) asParser) ==> [ :lf | Array with: lf with: nil ])
/ (((Character codePoint: 13) asParser , ((Character codePoint: 10) asParser ) optional )) ==> [ :nodes | Array with: nodes first with: nil ]
"Modified: / 21-04-2015 / 17:16:50 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!PPJavaLexicon methodsFor:'grammar-literals'!
literal
"a literal must be a single token. Whitespaces are not allowed inside the literal"
^ nullLiteral / booleanLiteral / floatingPointLiteral / integerLiteral / characterLiteral / stringLiteral
! !
!PPJavaLexicon methodsFor:'grammar-literals-boolean'!
booleanLiteral
^ trueToken / falseToken
!
falseToken
^ ('false' asParser , #word asParser not) javaToken
!
nullToken
^ ('null' asParser , #word asParser not) javaToken
!
trueToken
^ ('true' asParser , #word asParser not) javaToken
! !
!PPJavaLexicon methodsFor:'grammar-literals-character'!
characterLiteral
^ ($' asParser , ( escapeSequence / singleCharacter ), $' asParser) javaToken
!
singleCharacter
^( PPPredicateObjectParser anyOf: '''\') not , inputCharacter ==> #second
! !
!PPJavaLexicon methodsFor:'grammar-literals-escape'!
escapeSequence
^ ($\ asParser , (PPPredicateObjectParser anyOf: 'btnfr""''\' ) ) /
octalEscape
!
octalEscape
^ $\ asParser , ( (zeroToThree , octalDigit , octalDigit) / (octalDigit , octalDigit optional) )
!
zeroToThree
^PPPredicateObjectParser anyOf: '0123'
! !
!PPJavaLexicon methodsFor:'grammar-literals-floating'!
binaryExponent
^ binaryExponentIndicator , signedInteger
!
binaryExponentIndicator
^ PPPredicateObjectParser anyOf: 'pP'
!
decimalFloatingPointLiteral
|dot|
dot := $. asParser.
^ ( ( (dot , digits)
/
(digits , dot , digits optional)) ,
exponentPart optional , floatTypeSuffix optional )
/
(digits ,
( (exponentPart , floatTypeSuffix optional)
/
(exponentPart optional , floatTypeSuffix) ))
!
exponentIndicator
^ PPPredicateObjectParser anyOf: 'eE'
!
exponentPart
^ exponentIndicator , signedInteger
!
floatTypeSuffix
^ PPPredicateObjectParser anyOf: 'fFdD'
!
floatingPointLiteral
^ (hexadecimalFloatingPointLiteral / decimalFloatingPointLiteral) javaToken
!
hexSignificand
|dot|
dot := $. asParser.
^ (hexNumeral , dot optional) /
($0 asParser , (PPPredicateObjectParser anyOf: 'xX') , hexDigits optional , dot , hexDigits )
!
hexadecimalFloatingPointLiteral
^ hexSignificand , binaryExponent , floatTypeSuffix optional
!
sign
^PPPredicateObjectParser anyOf: '-+'
!
signedInteger
^ sign optional , digits
! !
!PPJavaLexicon methodsFor:'grammar-literals-integer'!
decimalIntegerLiteral
^ decimalNumeral , (integerTypeSuffix optional)
!
decimalNumeral
^($0 asParser) / (nonZeroDigit , digits optional)
!
digits
"digit is already defined, no need to redefine it"
^#digit asParser plus
!
hexDigits
^hexDigit plus
!
hexIntegerLiteral
^ hexNumeral , (integerTypeSuffix optional)
!
hexNumeral
^$0 asParser, (PPPredicateObjectParser anyOf: 'xX' ), hexDigits
!
integerLiteral
^ (hexIntegerLiteral / octalIntegerLiteral / decimalIntegerLiteral) javaToken
!
integerTypeSuffix
^ PPPredicateObjectParser anyOf: 'lL'
!
nonZeroDigit
^PPPredicateObjectParser anyOf: '123456789'.
!
octalDigit
^PPPredicateObjectParser anyOf: '01234567'
!
octalDigits
^ octalDigit plus
!
octalIntegerLiteral
^ octalNumeral , (integerTypeSuffix optional)
!
octalNumeral
^($0 asParser) , octalDigits
! !
!PPJavaLexicon methodsFor:'grammar-literals-null'!
nullLiteral
^ nullToken
! !
!PPJavaLexicon methodsFor:'grammar-literals-string'!
stringCharacter
^ ( ( PPPredicateObjectParser anyOf: '"\') not , inputCharacter ==> #second ) /
escapeSequence
!
stringCharacters
^ stringCharacter plus
!
stringLiteral
^ ($" asParser , stringCharacters optional , $" asParser) javaToken
! !
!PPJavaLexicon methodsFor:'grammar-operators'!
operator
| operatorParsers |
operatorParsers := operators keys asSortedCollection collect: [:eachKey | operators at: eachKey ].
^self asToken: (operatorParsers reduce: [ :a :b | a / b ])
"Modified: / 21-04-2015 / 15:26:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!PPJavaLexicon methodsFor:'grammar-separators'!
separator
^self asToken: (PPPredicateObjectParser anyOf: '(){}[];,.' )
! !
!PPJavaLexicon methodsFor:'grammar-unicode-escapes'!
hexDigit
^#hex asParser
!
rawInputCharacter
^#any asParser
!
unicodeEscape
^ $\ asParser , unicodeMarker , hexDigit , hexDigit , hexDigit , hexDigit
!
unicodeInputCharacter
^ unicodeEscape / rawInputCharacter
!
unicodeMarker
^$u asParser plus
! !
!PPJavaLexicon methodsFor:'grammar-whiteSpace'!
whiteSpace
^ (Character space asParser ) /
(Character tab asParser ) /
((Character value: 12) asParser ) /
lineTerminator
! !
!PPJavaLexicon methodsFor:'initialization'!
initialize
super initialize.
self initializeKeywords.
self initializeOperators.
self initializeSeparators.
!
initializeKeywords
| values |
keywords := Dictionary new.
values := #('abstract' 'assert' 'boolean' 'break' 'byte' 'case' 'catch' 'char' 'class' 'const'
'continue' 'default' 'do' 'double' 'else' 'enum' 'extends' 'final' 'finally' 'float'
'for' 'if' 'goto' 'implements' 'import' 'instanceof' 'int' 'interface' 'long' 'native'
'new' 'package' 'private' 'protected' 'public' 'return' 'short' 'static' 'strictfp' 'super'
'switch' 'synchronized' 'this' 'throw' 'throws' 'transient' 'try' 'void' 'volatile' 'while').
values do: [:eachKeyword |
keywords at: eachKeyword
put: (PPUnresolvedParser named: ('keyword', eachKeyword first asUppercase asString , eachKeyword allButFirst))
].
keywords keysAndValuesDo: [:key :value |
(keywords at: key) def: (key asParser , #word asParser not)]
!
initializeOperators
| values |
operators := Dictionary new.
values := #( '>>>=' '>>>' '>>=' '>>' '>=' '>' '<<=' '<<' '<=' '<' '++' '+=' '+' '--' '-=' '-' '&&' '&=' '&'
'||' '|=' '|' '*=' '*' '%=' '%' '/=' '/' '^=' '^' '!!=' '!!' '==' '=' '~' '?' ':' '@' ).
" @ ? perhaps for annotation but not in the doc "
values do: [:eachOperator |
operators at: eachOperator
put: (PPUnresolvedParser named: ('operator', eachOperator asString))
].
operators keysAndValuesDo: [:key :value |
(operators at: key) def: (key asParser)]
!
initializeSeparators
| values |
separators := Dictionary new.
values := #( '(' ')' '{' '}' '[' ']' ';' ',' '.' ).
values do: [:eachSeparator |
separators at: eachSeparator
put: (PPUnresolvedParser named: ('separator', eachSeparator asString))
].
separators keysAndValuesDo: [:key :value |
(separators at: key) def: (key asParser)]
! !
!PPJavaLexicon methodsFor:'utility'!
asToken: aParser
^aParser javaToken
!
emptySquaredParenthesis
^ self asToken: (((self tokenFor: '['), (self tokenFor: ']')))
!
tokenFor: aString
^self asToken: (keywords at: aString
ifAbsent: [separators at: aString
ifAbsent: [operators at: aString] ])
! !
!PPJavaLexicon class methodsFor:'documentation'!
version_HG
^ '$Changeset: <not expanded> $'
! !
\ No newline at end of file
+"{ Package: 'stx:goodies/petitparser/parsers/java' }"
+
+"{ NameSpace: Smalltalk }"
+
+PPCompositeParser subclass:#PPJavaLexicon
+ instanceVariableNames:'unicodeEscape rawInputCharacter unicodeMarker hexDigit
+ lineTerminator unicodeInputCharacter inputElements sub
+ inputElement whiteSpace comment javaToken keyword literal
+ separator operator identifier traditionalComment endOfLineComment
+ commentTail charactersInLine commentTailStar notStar
+ notStarNotSlash inputCharacter booleanLiteral nullLiteral
+ identifierChars javaLetter javaLetterOrDigit keywords
+ floatingPointLiteral integerLiteral characterLiteral
+ stringLiteral hexIntegerLiteral octalIntegerLiteral
+ decimalIntegerLiteral decimalNumeral integerTypeSuffix hexNumeral
+ octalNumeral nonZeroDigit digits hexDigits octalDigits octalDigit
+ hexadecimalFloatingPointLiteral decimalFloatingPointLiteral
+ exponentPart floatTypeSuffix exponentIndicator signedInteger sign
+ hexSignificand binaryExponent binaryExponentIndicator
+ escapeSequence singleCharacter stringCharacters stringCharacter
+ octalEscape zeroToThree input operators separators trueToken
+ falseToken nullToken'
+ classVariableNames:''
+ poolDictionaries:''
+ category:'PetitJava-Core'
+!
+
+PPJavaLexicon comment:'A parser with a definitions for some basic Java gramar parts
Grammar rules follow as closely as possible the specification found in "The Java Language Specification Third Edition"
URL = '
+!
+
+
+!PPJavaLexicon class methodsFor:'accessing'!
+
+ignoredNames
+ "Answer a collection of instance-variables that should not be automatically initialized with productions, but that are used internal to the composite parser."
+
+ | newArray |
+ newArray := Array new: ((self namesToIgnore size) + (super ignoredNames size)).
+ newArray
+ replaceFrom: 1
+ to: self namesToIgnore size
+ with: self namesToIgnore.
+ newArray
+ replaceFrom: (self namesToIgnore size + 1)
+ to: newArray size
+ with: super ignoredNames.
+ ^newArray
+!
+
+namesToIgnore
+
+ ^#('keywords' 'operators' 'separators')
+! !
+
+!PPJavaLexicon methodsFor:'accessing'!
+
+start
+ "Default start production."
+
+ ^ input end
+! !
+
+!PPJavaLexicon methodsFor:'grammar-comments'!
+
+charactersInLine
+
+ ^ inputCharacter plus
+!
+
+comment
+ "traditional -> /*
+ endOfLine -> //"
+ ^ traditionalComment / endOfLineComment
+!
+
+commentTail
+
+ ^ ('*' asParser , commentTailStar ) /
+ (notStar , commentTail)
+!
+
+commentTailStar
+
+ ^ ('/' asParser ) /
+ ('*' asParser , commentTailStar ) /
+ (notStarNotSlash , commentTail )
+!
+
+endOfLineComment
+
+ ^ '//' asParser , charactersInLine optional
+!
+
+notStar
+
+ ^ ('*' asParser not , inputCharacter)/lineTerminator
+!
+
+notStarNotSlash
+
+ ^ lineTerminator / ((PPPredicateObjectParser anyOf: '*/') not , inputCharacter )
+!
+
+traditionalComment
+
+ ^ '/*' asParser , commentTail
+! !
+
+!PPJavaLexicon methodsFor:'grammar-identifiers'!
+
+identifier
+
+ ^ self asToken: (((keyword not) , (booleanLiteral not) , (nullLiteral not) , identifierChars ))
+!
+
+identifierChars
+
+ ^ javaLetter plus , javaLetterOrDigit star
+!
+
+javaLetter
+
+ ^ (#letter asParser) / (PPPredicateObjectParser anyOf: '_$')
+!
+
+javaLetterOrDigit
+
+ ^ javaLetter / (#digit asParser)
+! !
+
+!PPJavaLexicon methodsFor:'grammar-input'!
+
+input
+
+ ^ (inputElements optional) , (sub optional)
+!
+
+inputElement
+
+ ^ whiteSpace / comment / javaToken
+!
+
+inputElements
+
+ ^ inputElement plus
+!
+
+javaToken
+
+
+ ^ identifier / keyword / literal / separator / operator
+!
+
+sub
+
+ ^ (Character value: 26) asParser
+! !
+
+!PPJavaLexicon methodsFor:'grammar-keywords'!
+
+keyword
+
+ | keywordParsers |
+
+ keywordParsers := keywords keys asSortedCollection collect: [:eachKey | keywords at: eachKey ].
+ ^ self asToken: ( (keywordParsers reduce: [ :a :b | a / b ]) )
+
+ "Modified (format): / 21-04-2015 / 15:27:29 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!PPJavaLexicon methodsFor:'grammar-lineTerminators'!
+
+inputCharacter
+
+ ^(lineTerminator not) , unicodeInputCharacter ==> #second
+!
+
+lineTerminator
+
+ self flag: 'Hack alert - should be fixed immediately in PJTraditionalCommentsNode>>comment:'.
+
+ ^ (((Character codePoint: 10) asParser) ==> [ :lf | Array with: lf with: nil ])
+ / (((Character codePoint: 13) asParser , ((Character codePoint: 10) asParser ) optional )) ==> [ :nodes | Array with: nodes first with: nil ]
+
+ "Modified: / 21-04-2015 / 17:16:50 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!PPJavaLexicon methodsFor:'grammar-literals'!
+
+literal
+ "a literal must be a single token. Whitespaces are not allowed inside the literal"
+
+ ^ nullLiteral / booleanLiteral / floatingPointLiteral / integerLiteral / characterLiteral / stringLiteral
+! !
+
+!PPJavaLexicon methodsFor:'grammar-literals-boolean'!
+
+booleanLiteral
+
+ ^ trueToken / falseToken
+!
+
+falseToken
+ ^ ('false' asParser , #word asParser not) javaToken
+!
+
+nullToken
+ ^ ('null' asParser , #word asParser not) javaToken
+!
+
+trueToken
+ ^ ('true' asParser , #word asParser not) javaToken
+! !
+
+!PPJavaLexicon methodsFor:'grammar-literals-character'!
+
+characterLiteral
+
+ ^ ($' asParser , ( escapeSequence / singleCharacter ), $' asParser) javaToken
+!
+
+singleCharacter
+
+ ^( PPPredicateObjectParser anyOf: '''\') not , inputCharacter ==> #second
+! !
+
+!PPJavaLexicon methodsFor:'grammar-literals-escape'!
+
+escapeSequence
+
+ ^ ($\ asParser , (PPPredicateObjectParser anyOf: 'btnfr""''\' ) ) /
+ octalEscape
+!
+
+octalEscape
+
+ ^ $\ asParser , ( (zeroToThree , octalDigit , octalDigit) / (octalDigit , octalDigit optional) )
+!
+
+zeroToThree
+
+ ^PPPredicateObjectParser anyOf: '0123'
+! !
+
+!PPJavaLexicon methodsFor:'grammar-literals-floating'!
+
+binaryExponent
+
+ ^ binaryExponentIndicator , signedInteger
+!
+
+binaryExponentIndicator
+
+ ^ PPPredicateObjectParser anyOf: 'pP'
+!
+
+decimalFloatingPointLiteral
+
+ |dot|
+ dot := $. asParser.
+
+ ^ ( ( (dot , digits)
+ /
+ (digits , dot , digits optional)) ,
+ exponentPart optional , floatTypeSuffix optional )
+ /
+ (digits ,
+ ( (exponentPart , floatTypeSuffix optional)
+ /
+ (exponentPart optional , floatTypeSuffix) ))
+!
+
+exponentIndicator
+
+ ^ PPPredicateObjectParser anyOf: 'eE'
+!
+
+exponentPart
+
+ ^ exponentIndicator , signedInteger
+!
+
+floatTypeSuffix
+
+ ^ PPPredicateObjectParser anyOf: 'fFdD'
+!
+
+floatingPointLiteral
+
+ ^ (hexadecimalFloatingPointLiteral / decimalFloatingPointLiteral) javaToken
+!
+
+hexSignificand
+ |dot|
+ dot := $. asParser.
+
+ ^ (hexNumeral , dot optional) /
+ ($0 asParser , (PPPredicateObjectParser anyOf: 'xX') , hexDigits optional , dot , hexDigits )
+!
+
+hexadecimalFloatingPointLiteral
+
+ ^ hexSignificand , binaryExponent , floatTypeSuffix optional
+!
+
+sign
+
+ ^PPPredicateObjectParser anyOf: '-+'
+!
+
+signedInteger
+
+ ^ sign optional , digits
+! !
+
+!PPJavaLexicon methodsFor:'grammar-literals-integer'!
+
+decimalIntegerLiteral
+
+ ^ decimalNumeral , (integerTypeSuffix optional)
+!
+
+decimalNumeral
+
+ ^($0 asParser) / (nonZeroDigit , digits optional)
+!
+
+digits
+ "digit is already defined, no need to redefine it"
+ ^#digit asParser plus
+!
+
+hexDigits
+
+ ^hexDigit plus
+!
+
+hexIntegerLiteral
+
+ ^ hexNumeral , (integerTypeSuffix optional)
+!
+
+hexNumeral
+
+ ^$0 asParser, (PPPredicateObjectParser anyOf: 'xX' ), hexDigits
+!
+
+integerLiteral
+
+ ^ (hexIntegerLiteral / octalIntegerLiteral / decimalIntegerLiteral) javaToken
+!
+
+integerTypeSuffix
+
+ ^ PPPredicateObjectParser anyOf: 'lL'
+!
+
+nonZeroDigit
+
+ ^PPPredicateObjectParser anyOf: '123456789'.
+!
+
+octalDigit
+
+ ^PPPredicateObjectParser anyOf: '01234567'
+!
+
+octalDigits
+
+ ^ octalDigit plus
+!
+
+octalIntegerLiteral
+
+ ^ octalNumeral , (integerTypeSuffix optional)
+!
+
+octalNumeral
+
+ ^($0 asParser) , octalDigits
+! !
+
+!PPJavaLexicon methodsFor:'grammar-literals-null'!
+
+nullLiteral
+
+ ^ nullToken
+! !
+
+!PPJavaLexicon methodsFor:'grammar-literals-string'!
+
+stringCharacter
+
+ ^ ( ( PPPredicateObjectParser anyOf: '"\') not , inputCharacter ==> #second ) /
+ escapeSequence
+!
+
+stringCharacters
+
+ ^ stringCharacter plus
+!
+
+stringLiteral
+
+ ^ ($" asParser , stringCharacters optional , $" asParser) javaToken
+! !
+
+!PPJavaLexicon methodsFor:'grammar-operators'!
+
+operator
+ | operatorParsers |
+
+ operatorParsers := operators keys asSortedCollection collect: [:eachKey | operators at: eachKey ].
+ ^self asToken: (operatorParsers reduce: [ :a :b | a / b ])
+
+ "Modified: / 21-04-2015 / 15:26:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!PPJavaLexicon methodsFor:'grammar-separators'!
+
+separator
+ ^self asToken: (PPPredicateObjectParser anyOf: '(){}[];,.' )
+! !
+
+!PPJavaLexicon methodsFor:'grammar-unicode-escapes'!
+
+hexDigit
+
+ ^#hex asParser
+!
+
+rawInputCharacter
+
+ ^#any asParser
+!
+
+unicodeEscape
+
+ ^ $\ asParser , unicodeMarker , hexDigit , hexDigit , hexDigit , hexDigit
+!
+
+unicodeInputCharacter
+ ^ unicodeEscape / rawInputCharacter
+!
+
+unicodeMarker
+
+ ^$u asParser plus
+! !
+
+!PPJavaLexicon methodsFor:'grammar-whiteSpace'!
+
+whiteSpace
+
+ ^ (Character space asParser ) /
+ (Character tab asParser ) /
+ ((Character value: 12) asParser ) /
+ lineTerminator
+! !
+
+!PPJavaLexicon methodsFor:'initialization'!
+
+initialize
+
+ super initialize.
+
+ self initializeKeywords.
+ self initializeOperators.
+ self initializeSeparators.
+!
+
+initializeKeywords
+
+ | values |
+ keywords := Dictionary new.
+ values := #('abstract' 'assert' 'boolean' 'break' 'byte' 'case' 'catch' 'char' 'class' 'const'
+ 'continue' 'default' 'do' 'double' 'else' 'enum' 'extends' 'final' 'finally' 'float'
+ 'for' 'if' 'goto' 'implements' 'import' 'instanceof' 'int' 'interface' 'long' 'native'
+ 'new' 'package' 'private' 'protected' 'public' 'return' 'short' 'static' 'strictfp' 'super'
+ 'switch' 'synchronized' 'this' 'throw' 'throws' 'transient' 'try' 'void' 'volatile' 'while').
+
+ values do: [:eachKeyword |
+ keywords at: eachKeyword
+ put: (PPUnresolvedParser named: ('keyword', eachKeyword first asUppercase asString , eachKeyword allButFirst))
+ ].
+
+ keywords keysAndValuesDo: [:key :value |
+ (keywords at: key) def: (key asParser , #word asParser not)]
+!
+
+initializeOperators
+
+ | values |
+ operators := Dictionary new.
+ values := #( '>>>=' '>>>' '>>=' '>>' '>=' '>' '<<=' '<<' '<=' '<' '++' '+=' '+' '--' '-=' '-' '&&' '&=' '&'
+ '||' '|=' '|' '*=' '*' '%=' '%' '/=' '/' '^=' '^' '!!=' '!!' '==' '=' '~' '?' ':' '@' ).
+ " @ ? perhaps for annotation but not in the doc "
+ values do: [:eachOperator |
+ operators at: eachOperator
+ put: (PPUnresolvedParser named: ('operator', eachOperator asString))
+ ].
+
+ operators keysAndValuesDo: [:key :value |
+ (operators at: key) def: (key asParser)]
+!
+
+initializeSeparators
+
+ | values |
+ separators := Dictionary new.
+ values := #( '(' ')' '{' '}' '[' ']' ';' ',' '.' ).
+
+ values do: [:eachSeparator |
+ separators at: eachSeparator
+ put: (PPUnresolvedParser named: ('separator', eachSeparator asString))
+ ].
+
+ separators keysAndValuesDo: [:key :value |
+ (separators at: key) def: (key asParser)]
+! !
+
+!PPJavaLexicon methodsFor:'utility'!
+
+asToken: aParser
+
+ ^aParser javaToken
+!
+
+emptySquaredParenthesis
+
+ ^ self asToken: (((self tokenFor: '['), (self tokenFor: ']')))
+!
+
+tokenFor: aString
+
+ ^self asToken: (keywords at: aString
+ ifAbsent: [separators at: aString
+ ifAbsent: [operators at: aString] ])
+! !
+
+!PPJavaLexicon class methodsFor:'documentation'!
+
+version_HG
+
+ ^ '$Changeset: <not expanded> $'
+! !
+
--- a/parsers/java/PPJavaWhitespaceParser.st Sun May 10 06:46:56 2015 +0100
+++ b/parsers/java/PPJavaWhitespaceParser.st Sun May 10 14:20:24 2015 +0100
@@ -9,6 +9,7 @@
category:'PetitJava-Core'
!
+
!PPJavaWhitespaceParser methodsFor:'as yet unclassified'!
acceptsEpsilon
@@ -36,25 +37,27 @@
!
parseOn: context
-
- | start |
+
+ | start |
- [
- | peekTwice |
- [ context atEnd not and: [ context peek isSeparator ] ]
- whileTrue: [ context next ].
- peekTwice := context peekTwice.
- ((peekTwice first = $/) and:
- [ (peekTwice second = $*) or: [peekTwice second = $/]])
- ] whileTrue: [
- context next.
- start := context position.
- (context next = $*)
- ifTrue: [ context upToAll: '*/' ]
- ifFalse: [
- | position |
- position := context position.
- context upToAnyOf: CharacterSet crlf].
- ].
+ [
+ | peekTwice |
+ [ context atEnd not and: [ context peek isSeparator ] ]
+ whileTrue: [ context next ].
+ peekTwice := context peekTwice.
+ ((peekTwice first = $/) and:
+ [ (peekTwice second = $*) or: [peekTwice second = $/]])
+ ] whileTrue: [
+ context next.
+ start := context position.
+ (context next = $*)
+ ifTrue: [ context upToAll: '*/' ]
+ ifFalse: [
+ | position |
+ position := context position.
+ context upToAnyOf: String crlf].
+ ].
+
+ "Modified: / 10-05-2015 / 07:57:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
--- a/parsers/java/abbrev.stc Sun May 10 06:46:56 2015 +0100
+++ b/parsers/java/abbrev.stc Sun May 10 14:20:24 2015 +0100
@@ -22,7 +22,6 @@
PJTypeNode PJTypeNode stx:goodies/petitparser/parsers/java 'PetitJava-AST' 0
PJVariableDeclaratorNode PJVariableDeclaratorNode stx:goodies/petitparser/parsers/java 'PetitJava-AST' 0
PPJavaSyntax PPJavaSyntax stx:goodies/petitparser/parsers/java 'PetitJava-Core' 0
-PPJavaSyntaxTest PPJavaSyntaxTest stx:goodies/petitparser/parsers/java 'PetitJava-Tests' 1
PJAbstractTypeDeclarationNode PJAbstractTypeDeclarationNode stx:goodies/petitparser/parsers/java 'PetitJava-AST' 0
PJAnnotationNode PJAnnotationNode stx:goodies/petitparser/parsers/java 'PetitJava-AST' 0
PJArrayTypeNode PJArrayTypeNode stx:goodies/petitparser/parsers/java 'PetitJava-AST' 0
@@ -45,7 +44,6 @@
PJStringLiteralNode PJStringLiteralNode stx:goodies/petitparser/parsers/java 'PetitJava-AST' 0
PJWhileStatementNode PJWhileStatementNode stx:goodies/petitparser/parsers/java 'PetitJava-AST' 0
PPJavaParser PPJavaParser stx:goodies/petitparser/parsers/java 'PetitJava-Core' 0
-PPJavaParserTest PPJavaParserTest stx:goodies/petitparser/parsers/java 'PetitJava-Tests' 1
PJConstructorDeclarationNode PJConstructorDeclarationNode stx:goodies/petitparser/parsers/java 'PetitJava-AST' 0
PJEndOfLineCommentsNode PJEndOfLineCommentsNode stx:goodies/petitparser/parsers/java 'PetitJava-AST' 0
PJMethodDeclarationNode PJMethodDeclarationNode stx:goodies/petitparser/parsers/java 'PetitJava-AST' 1
@@ -53,3 +51,5 @@
PJSimpleNameNode PJSimpleNameNode stx:goodies/petitparser/parsers/java 'PetitJava-AST' 0
PJTraditionalCommentsNode PJTraditionalCommentsNode stx:goodies/petitparser/parsers/java 'PetitJava-AST' 0
PJTypeDeclarationNode PJTypeDeclarationNode stx:goodies/petitparser/parsers/java 'PetitJava-AST' 0
+PPJavaParserTest PPJavaParserTest stx:goodies/petitparser/parsers/java 'PetitJava-Tests' 1
+PPJavaSyntaxTest PPJavaSyntaxTest stx:goodies/petitparser/parsers/java 'PetitJava-Tests' 1
--- a/parsers/java/bc.mak Sun May 10 06:46:56 2015 +0100
+++ b/parsers/java/bc.mak Sun May 10 14:20:24 2015 +0100
@@ -35,7 +35,7 @@
-LOCALINCLUDES= -I$(INCLUDE_TOP)\stx\goodies\petitparser -I$(INCLUDE_TOP)\stx\goodies\petitparser\tests -I$(INCLUDE_TOP)\stx\goodies\sunit -I$(INCLUDE_TOP)\stx\libbasic -I$(INCLUDE_TOP)\stx\libbasic2
+LOCALINCLUDES= -I$(INCLUDE_TOP)\stx\goodies\petitparser -I$(INCLUDE_TOP)\stx\goodies\petitparser\tests -I$(INCLUDE_TOP)\stx\goodies\sunit -I$(INCLUDE_TOP)\stx\libbasic
LOCALDEFINES=
STCLOCALOPT=-package=$(PACKAGE) -I. $(LOCALINCLUDES) -headerDir=. $(STCLOCALOPTIMIZATIONS) $(STCWARNINGS) $(LOCALDEFINES) -varPrefix=$(LIBNAME)
--- a/parsers/java/extensions.st Sun May 10 06:46:56 2015 +0100
+++ b/parsers/java/extensions.st Sun May 10 14:20:24 2015 +0100
@@ -11,10 +11,14 @@
ifFalse: [ aString ]])
! !
-!PPParser methodsFor:'*petitjava-operations'!
+!PPParser methodsFor:'*petitcompiler'!
javaToken
- ^ PPJavaTokenParser on: self
+ | ws |
+ ws := PPJavaWhitespaceParser new.
+ ^ ((ws, ((PPTokenParser on: self) tokenClass: PPJavaToken; yourself), ws) ==> #second)
+ propertyAt: #'trimmingToken' put: true;
+ yourself
! !
!stx_goodies_petitparser_parsers_java class methodsFor:'documentation'!
--- a/parsers/java/stx_goodies_petitparser_parsers_java.st Sun May 10 06:46:56 2015 +0100
+++ b/parsers/java/stx_goodies_petitparser_parsers_java.st Sun May 10 14:20:24 2015 +0100
@@ -73,7 +73,6 @@
by searching all classes (and their packages) which are referenced by my classes."
^ #(
- #'stx:libbasic2' "CharacterSet - referenced by PPJavaTokenParser>>parseComments:on:"
)
!
@@ -126,7 +125,6 @@
PJTypeNode
PJVariableDeclaratorNode
PPJavaSyntax
- (PPJavaSyntaxTest autoload)
PJAbstractTypeDeclarationNode
PJAnnotationNode
PJArrayTypeNode
@@ -149,7 +147,6 @@
PJStringLiteralNode
PJWhileStatementNode
PPJavaParser
- (PPJavaParserTest autoload)
PJConstructorDeclarationNode
PJEndOfLineCommentsNode
PJMethodDeclarationNode
@@ -157,6 +154,8 @@
PJSimpleNameNode
PJTraditionalCommentsNode
PJTypeDeclarationNode
+ (PPJavaParserTest autoload)
+ (PPJavaSyntaxTest autoload)
)
!
--- a/tests/PPArithmeticParserTest.st Sun May 10 06:46:56 2015 +0100
+++ b/tests/PPArithmeticParserTest.st Sun May 10 14:20:24 2015 +0100
@@ -1,5 +1,7 @@
"{ Package: 'stx:goodies/petitparser/tests' }"
+"{ NameSpace: Smalltalk }"
+
PPCompositeParserTest subclass:#PPArithmeticParserTest
instanceVariableNames:''
classVariableNames:''
--- a/tests/PPCompositeParserTest.st Sun May 10 06:46:56 2015 +0100
+++ b/tests/PPCompositeParserTest.st Sun May 10 14:20:24 2015 +0100
@@ -1,5 +1,7 @@
"{ Package: 'stx:goodies/petitparser/tests' }"
+"{ NameSpace: Smalltalk }"
+
PPAbstractParserTest subclass:#PPCompositeParserTest
instanceVariableNames:'parser result'
classVariableNames:''
--- a/tests/PPExpressionParserTest.st Sun May 10 06:46:56 2015 +0100
+++ b/tests/PPExpressionParserTest.st Sun May 10 14:20:24 2015 +0100
@@ -1,5 +1,7 @@
"{ Package: 'stx:goodies/petitparser/tests' }"
+"{ NameSpace: Smalltalk }"
+
PPArithmeticParserTest subclass:#PPExpressionParserTest
instanceVariableNames:''
classVariableNames:''
--- a/tests/PPLambdaParserTest.st Sun May 10 06:46:56 2015 +0100
+++ b/tests/PPLambdaParserTest.st Sun May 10 14:20:24 2015 +0100
@@ -1,5 +1,7 @@
"{ Package: 'stx:goodies/petitparser/tests' }"
+"{ NameSpace: Smalltalk }"
+
PPCompositeParserTest subclass:#PPLambdaParserTest
instanceVariableNames:''
classVariableNames:''
--- a/tests/PPParserResource.st Sun May 10 06:46:56 2015 +0100
+++ b/tests/PPParserResource.st Sun May 10 14:20:24 2015 +0100
@@ -1,5 +1,7 @@
"{ Package: 'stx:goodies/petitparser/tests' }"
+"{ NameSpace: Smalltalk }"
+
TestResource subclass:#PPParserResource
instanceVariableNames:'parsers'
classVariableNames:''
--- a/tests/PPScriptingTest.st Sun May 10 06:46:56 2015 +0100
+++ b/tests/PPScriptingTest.st Sun May 10 14:20:24 2015 +0100
@@ -1,5 +1,7 @@
"{ Package: 'stx:goodies/petitparser/tests' }"
+"{ NameSpace: Smalltalk }"
+
PPAbstractParserTest subclass:#PPScriptingTest
instanceVariableNames:''
classVariableNames:''