141 ! |
141 ! |
142 |
142 |
143 extendedBinarySelectorCharacters |
143 extendedBinarySelectorCharacters |
144 "return a collection of characters which are optionally allowed in binary selectors" |
144 "return a collection of characters which are optionally allowed in binary selectors" |
145 |
145 |
146 "/ ^ '±×·÷«»'. |
146 "/ ^ '±×·÷«»'. |
147 ^ String |
147 ^ String |
148 with:(Character value:16rB1) "/ plus-minus |
148 with:(Character value:16rB1) "/ plus-minus |
149 with:(Character value:16rD7) "/ times |
149 with:(Character value:16rD7) "/ times |
150 with:(Character value:16rB7) "/ centered dot |
150 with:(Character value:16rB7) "/ centered dot |
151 with:(Character value:16rF7) "/ divide |
151 with:(Character value:16rF7) "/ divide |
152 with:(Character value:16rAB) "/ << |
152 with:(Character value:16rAB) "/ << |
153 with:(Character value:16rBB). "/ >> |
153 with:(Character value:16rBB). "/ >> |
|
154 |
|
155 "Modified (comment): / 17-11-2016 / 09:22:42 / cg" |
154 ! |
156 ! |
155 |
157 |
156 setupActions |
158 setupActions |
157 "initialize the scanners actionTables - these are used to dispatch |
159 "initialize the scanner's actionTables - these are used to dispatch |
158 into scanner methods as characters are read. |
160 into scanner methods as characters are read. |
159 Compatibility note: in previous versions, these tables used to be kept |
161 Compatibility note: in previous versions, these tables used to be kept |
160 in classVariables, which made reuse hard as subclasses had no easy way of |
162 in classVariables, which made reuse hard as subclasses had no easy way of |
161 defining their own tables. These are now class instance variables." |
163 defining their own tables. These are now class instance variables." |
162 |
164 |
1444 errMsg := 'Invalid character: ''' , ch asString , ''' ', '(' , (v radixPrintStringRadix:16) , ').'. |
1446 errMsg := 'Invalid character: ''' , ch asString , ''' ', '(' , (v radixPrintStringRadix:16) , ').'. |
1445 ] ifFalse:[ |
1447 ] ifFalse:[ |
1446 errMsg := 'Invalid character: ' , (v radixPrintStringRadix:16) , '.'. |
1448 errMsg := 'Invalid character: ' , (v radixPrintStringRadix:16) , '.'. |
1447 ]. |
1449 ]. |
1448 v > 16r7F ifTrue:[ |
1450 v > 16r7F ifTrue:[ |
1449 errMsg := errMsg , '\\Notice:\ Only 7-bit ascii allowed (for compatibility with other Smalltalk dialects).' withCRs. |
1451 errMsg := errMsg , ' |
|
1452 |
|
1453 Notice: |
|
1454 Only 7-bit ascii allowed (for compatibility with other Smalltalk dialects). |
|
1455 You can enable some of the special characters via the compiler-settings dialog.'. |
1450 ]. |
1456 ]. |
1451 self syntaxError:errMsg position:tokenPosition to:tokenPosition. |
1457 self syntaxError:errMsg position:tokenPosition to:tokenPosition. |
1452 source next. |
1458 source next. |
1453 tokenName := token := nil. |
1459 tokenName := token := nil. |
1454 tokenType := #Error. |
1460 tokenType := #Error. |
1455 ^ #Error |
1461 ^ #Error |
1456 |
1462 |
1457 "Modified: / 22-08-2006 / 14:26:21 / cg" |
1463 "Modified: / 17-11-2016 / 09:37:52 / cg" |
1458 ! |
1464 ! |
1459 |
1465 |
1460 lastTokenLineNumber |
1466 lastTokenLineNumber |
1461 "return the line number of the token which was just read." |
1467 "return the line number of the token which was just read." |
1462 |
1468 |
1747 didWarnAboutOldStyleAssignment := true |
1753 didWarnAboutOldStyleAssignment := true |
1748 ] |
1754 ] |
1749 ] |
1755 ] |
1750 |
1756 |
1751 "Modified: 23.5.1997 / 12:16:48 / cg" |
1757 "Modified: 23.5.1997 / 12:16:48 / cg" |
|
1758 ! |
|
1759 |
|
1760 warnParagraphAt:position |
|
1761 "warn about §-character in an identifier" |
|
1762 |
|
1763 ignoreWarnings ifFalse:[ |
|
1764 "/ didWarnAboutParagraphInIdentifier ifFalse:[ |
|
1765 parserFlags warnParagraphInIdentifier ifTrue:[ |
|
1766 self |
|
1767 warning:'§-characters in identifiers/symbols are nonportable' |
|
1768 doNotShowAgainAction:[ ParserFlags warnParagraphInIdentifier:false ] |
|
1769 position:position to:position. |
|
1770 " |
|
1771 only warn once (per method) |
|
1772 " |
|
1773 parserFlags := parserFlags copy. |
|
1774 parserFlags warnParagraphInIdentifier:false. |
|
1775 "/ didWarnAboutParagraphInIdentifier := true |
|
1776 ] |
|
1777 "/ ] |
|
1778 ] |
|
1779 |
|
1780 "Created: / 17-11-2016 / 09:16:22 / cg" |
1752 ! |
1781 ! |
1753 |
1782 |
1754 warnPeriodAt:position |
1783 warnPeriodAt:position |
1755 "warn about a period in an identifier" |
1784 "warn about a period in an identifier" |
1756 |
1785 |
2759 ] |
2788 ] |
2760 ]. |
2789 ]. |
2761 nextChar := source peekOrNil. |
2790 nextChar := source peekOrNil. |
2762 |
2791 |
2763 (((nextChar == $_) and:[allowUnderscoreInIdentifier]) |
2792 (((nextChar == $_) and:[allowUnderscoreInIdentifier]) |
2764 or:[(allowDollarInIdentifier and:[nextChar == $$ ]) |
2793 or:[ (allowDollarInIdentifier and:[nextChar == $$ ]) |
2765 or:[allowNationalCharactersInIdentifier and:[ nextChar notNil and:[nextChar isNationalLetter]]]]) ifTrue:[ |
2794 or:[ (nextChar == $§ and:[ parserFlags allowParagraphInIdentifier]) |
|
2795 or:[ allowNationalCharactersInIdentifier and:[ nextChar notNil and:[nextChar isNationalLetter]]]]]) ifTrue:[ |
2766 pos := source position + 1. |
2796 pos := source position + 1. |
2767 nextChar == $_ ifTrue:[ |
2797 nextChar == $_ ifTrue:[ |
2768 self warnUnderscoreAt:pos. |
2798 self warnUnderscoreAt:pos. |
2769 ] ifFalse:[ |
2799 ] ifFalse:[ |
2770 nextChar == $$ ifTrue:[ |
2800 nextChar == $$ ifTrue:[ |
2771 self warnDollarAt:pos. |
2801 self warnDollarAt:pos. |
2772 ] ifFalse:[ |
2802 ] ifFalse:[ |
2773 "/ self warnNationalCharacterAt:pos. |
2803 nextChar == $§ ifTrue:[ |
|
2804 self warnParagraphAt:pos. |
|
2805 ] ifFalse:[ |
|
2806 "/ self warnNationalCharacterAt:pos. |
|
2807 ] |
2774 ] |
2808 ] |
2775 ]. |
2809 ]. |
2776 ok := true. |
2810 ok := true. |
2777 [ok] whileTrue:[ |
2811 [ok] whileTrue:[ |
2778 string := string copyWith:nextChar. |
2812 string := string copyWith:nextChar. |
2784 string := string , source nextAlphaNumericWord. |
2818 string := string , source nextAlphaNumericWord. |
2785 nextChar := source peekOrNil. |
2819 nextChar := source peekOrNil. |
2786 ]. |
2820 ]. |
2787 ok := ((nextChar == $_) and:[allowUnderscoreInIdentifier]) |
2821 ok := ((nextChar == $_) and:[allowUnderscoreInIdentifier]) |
2788 or:[((nextChar == $$ ) and:[allowDollarInIdentifier]) |
2822 or:[((nextChar == $$ ) and:[allowDollarInIdentifier]) |
2789 or:[(nextChar notNil and:[nextChar isNationalLetter]) and:[allowNationalCharactersInIdentifier]]]. |
2823 or:[((nextChar == $§ ) and:[parserFlags allowParagraphInIdentifier]) |
|
2824 or:[(nextChar notNil and:[nextChar isNationalLetter]) and:[allowNationalCharactersInIdentifier]]]]. |
2790 ] |
2825 ] |
2791 ]. |
2826 ]. |
2792 ]. |
2827 ]. |
2793 |
2828 |
2794 (nextChar == $: and:[scanColonAsKeyword]) ifTrue:[ |
2829 (nextChar == $: and:[scanColonAsKeyword]) ifTrue:[ |
3459 (ch isNationalLetter and:[parserFlags allowNationalCharactersInIdentifier]) ifTrue:[ |
3494 (ch isNationalLetter and:[parserFlags allowNationalCharactersInIdentifier]) ifTrue:[ |
3460 tok := self nextIdentifier. |
3495 tok := self nextIdentifier. |
3461 tok notNil ifTrue:[ |
3496 tok notNil ifTrue:[ |
3462 ^ tok |
3497 ^ tok |
3463 ]. |
3498 ]. |
|
3499 "/ a nil token means: continue reading |
3464 ] ifFalse:[ |
3500 ] ifFalse:[ |
3465 ^ self invalidCharacter:ch. |
3501 (ch == $§ and:[parserFlags allowParagraphInIdentifier]) ifTrue:[ |
3466 ] |
3502 tok := self nextIdentifier. |
|
3503 tok notNil ifTrue:[ |
|
3504 ^ tok |
|
3505 ]. |
|
3506 "/ a nil token means: continue reading |
|
3507 ] ifFalse:[ |
|
3508 ^ self invalidCharacter:ch. |
|
3509 ]. |
|
3510 ]. |
3467 ] |
3511 ] |
3468 ] loop. |
3512 ] loop. |
3469 |
3513 |
3470 "Modified: / 13-09-1995 / 12:56:14 / claus" |
3514 "Modified: / 13-09-1995 / 12:56:14 / claus" |
3471 "Modified: / 25-03-2011 / 13:56:28 / cg" |
|
3472 "Modified: / 27-07-2011 / 15:36:53 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
3515 "Modified: / 27-07-2011 / 15:36:53 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
3516 "Modified: / 17-11-2016 / 09:35:39 / cg" |
3473 ! |
3517 ! |
3474 |
3518 |
3475 nextToken:aCharacter |
3519 nextToken:aCharacter |
3476 "return a character token" |
3520 "return a character token" |
3477 |
3521 |