[squeak-dev] The Inbox: ShoutCore.quasiquote-kb.41.mcz
commits at source.squeak.org
commits at source.squeak.org
Wed Feb 5 14:15:43 UTC 2014
Balázs Kósi uploaded a new version of ShoutCore to project The Inbox:
http://source.squeak.org/inbox/ShoutCore.quasiquote-kb.41.mcz
==================== Summary ====================
Name: ShoutCore.quasiquote-kb.41
Author: kb
Time: 5 February 2014, 3:15:36.334 pm
UUID: c127a411-2d61-468d-b4cb-04410f5a2663
Ancestors: ShoutCore-cwp.40
Syntax highlighting for Eliot's quasiquote syntax extension.
=============== Diff against ShoutCore-cwp.40 ===============
Item was changed:
----- Method: SHParserST80>>parseLiteral: (in category 'parse') -----
parseLiteral: inArray
currentTokenFirst == $$
ifTrue: [
| pos |
self failWhen: self currentChar isNil.
self rangeType: #'$'.
pos := currentTokenSourcePosition + 1.
self nextChar.
^self scanPast: #character start: pos end: pos].
currentTokenFirst isDigit
ifTrue: [
"do not parse the number, can be time consuming"
^self scanPast: #number].
currentToken = '-'
ifTrue: [
| c |
c := self currentChar.
(inArray and: [c isNil or: [c isDigit not]])
ifTrue: [
"single - can be a symbol in an Array"
^self scanPast: #symbol].
self scanPast: #-.
self failWhen: currentToken isNil.
"token isNil ifTrue: [self error: 'Unexpected End Of Input']."
"do not parse the number, can be time consuming"
^self scanPast: #number].
+ currentTokenFirst == $` ifTrue: [ ^self parseQuasiQuotedString ].
currentTokenFirst == $' ifTrue: [^self parseString].
currentTokenFirst == $# ifTrue: [^self parseSymbol].
(inArray and: [currentToken notNil]) ifTrue: [^self scanPast: #symbol].
self failWhen: currentTokenFirst == $. .
self error ": 'argument missing'"!
Item was added:
+ ----- Method: SHParserST80>>parseQuasiQuoteBlock (in category 'parse') -----
+ parseQuasiQuoteBlock
+ self enterBlock.
+ self scanPast: #blockStart level: bracketDepth.
+ self parseStatementList.
+ self failUnless: currentTokenFirst == $].
+ self rangeType: (self typePlusCycleFor: #blockEnd level: bracketDepth).
+ self leaveBlock!
Item was added:
+ ----- Method: SHParserST80>>parseQuasiQuotedString (in category 'parse') -----
+ parseQuasiQuotedString
+
+ | first c last |
+ first := sourcePosition.
+ c := self currentChar.
+ [
+ c ifNil: [
+ self rangeType: #unfinishedString start: first - 1 end: source size.
+ self error ": 'unfinished string'"].
+ c
+ caseOf: {
+ [ $[ ] -> [
+ self scanPast: #string start: first - 1 end: sourcePosition.
+ self parseQuasiQuoteBlock.
+ first := sourcePosition + 1.
+ self currentChar == $` ].
+ [ $$ ] -> [
+ c := self nextChar.
+ false ] }
+ otherwise: [ c == $` ] ] whileFalse: [ c := self nextChar ].
+ last := sourcePosition.
+ self nextChar.
+ self scanPast: #string start: first - 1 end: last.!
Item was changed:
----- Method: SHParserST80>>scanPast:level: (in category 'scan') -----
scanPast: rangeType level: level
- "first level adds no suffix to the rangeType.
- Suffix from 1 to 7 added in cycles , ((level-2) mod(7) + 1)"
- | cycle typePlusCycle |
+ ^self scanPast: (self typePlusCycleFor: rangeType level: level)
- cycle := level <= 1
- ifTrue: [0]
- ifFalse:[ ((level - 2) \\ 7) + 1].
- typePlusCycle := cycle = 0
- ifTrue:[rangeType]
- ifFalse:[(rangeType, cycle asString) asSymbol].
- ^self scanPast: typePlusCycle
!
Item was added:
+ ----- Method: SHParserST80>>typePlusCycleFor:level: (in category 'scan') -----
+ typePlusCycleFor: rangeType level: level
+ "first level adds no suffix to the rangeType.
+ Suffix from 1 to 7 added in cycles , ((level-2) mod(7) + 1)"
+ | cycle |
+
+ cycle := level <= 1
+ ifTrue: [ 0 ]
+ ifFalse: [ ((level - 2) \\ 7) + 1 ].
+ ^cycle = 0
+ ifTrue: [ rangeType ]
+ ifFalse: [ (rangeType, cycle asString) asSymbol ]!
More information about the Squeak-dev
mailing list
|