newspeak / Newspeak3CompilerAdaptor.ns3

The default branch has multiple heads

   1
   2
   3
   4
   5
   6
   7
   8
   9
  10
  11
  12
  13
  14
  15
  16
  17
  18
  19
  20
  21
  22
  23
  24
  25
  26
  27
  28
  29
  30
  31
  32
  33
  34
  35
  36
  37
  38
  39
  40
  41
  42
  43
  44
  45
  46
  47
  48
  49
  50
  51
  52
  53
  54
  55
  56
  57
  58
  59
  60
  61
  62
  63
  64
  65
  66
  67
  68
  69
  70
  71
  72
  73
  74
  75
  76
  77
  78
  79
  80
  81
  82
  83
  84
  85
  86
  87
  88
  89
  90
  91
  92
  93
  94
  95
  96
  97
  98
  99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
 152
 153
 154
 155
 156
 157
 158
 159
 160
 161
 162
 163
 164
 165
 166
 167
 168
 169
 170
 171
 172
 173
 174
 175
 176
 177
 178
 179
 180
 181
 182
 183
 184
 185
 186
 187
 188
 189
 190
 191
 192
 193
 194
 195
 196
 197
 198
 199
 200
 201
 202
 203
 204
 205
 206
 207
 208
 209
 210
 211
 212
 213
 214
 215
 216
 217
 218
 219
 220
 221
 222
 223
 224
 225
 226
 227
 228
 229
 230
 231
 232
 233
 234
 235
 236
 237
 238
 239
 240
 241
 242
 243
 244
 245
 246
 247
 248
 249
 250
 251
 252
 253
 254
 255
 256
 257
 258
 259
 260
 261
 262
 263
 264
 265
 266
 267
 268
 269
 270
 271
 272
 273
 274
 275
 276
 277
 278
 279
 280
 281
 282
 283
 284
 285
 286
 287
 288
 289
 290
 291
 292
 293
 294
 295
 296
 297
 298
 299
 300
 301
 302
 303
 304
 305
 306
 307
 308
 309
 310
 311
 312
 313
 314
 315
 316
 317
 318
 319
 320
 321
 322
 323
 324
 325
 326
 327
 328
 329
 330
 331
 332
 333
 334
 335
 336
 337
 338
 339
 340
 341
 342
 343
 344
 345
 346
 347
 348
 349
 350
 351
 352
 353
 354
 355
 356
 357
 358
 359
 360
 361
 362
 363
 364
 365
 366
 367
 368
 369
 370
 371
 372
 373
 374
 375
 376
 377
 378
 379
 380
 381
 382
 383
 384
 385
 386
 387
 388
 389
 390
 391
 392
 393
 394
 395
 396
 397
 398
 399
 400
 401
 402
 403
 404
 405
 406
 407
 408
 409
 410
 411
 412
 413
 414
 415
 416
 417
 418
 419
 420
 421
 422
 423
 424
 425
 426
 427
 428
 429
 430
 431
 432
 433
 434
 435
 436
 437
 438
 439
 440
 441
 442
 443
 444
 445
 446
 447
 448
 449
 450
 451
 452
 453
 454
 455
 456
 457
 458
 459
 460
 461
 462
 463
 464
 465
 466
 467
 468
 469
 470
 471
 472
 473
 474
 475
 476
 477
 478
 479
 480
 481
 482
 483
 484
 485
 486
 487
 488
 489
 490
 491
 492
 493
 494
 495
 496
 497
 498
 499
 500
 501
 502
 503
 504
 505
 506
 507
 508
 509
 510
 511
 512
 513
 514
 515
 516
 517
 518
 519
 520
 521
 522
 523
 524
 525
 526
 527
 528
 529
 530
 531
 532
 533
 534
 535
 536
 537
 538
 539
 540
 541
 542
 543
 544
 545
 546
 547
 548
 549
 550
 551
 552
 553
 554
 555
 556
 557
 558
 559
 560
 561
 562
 563
 564
 565
 566
 567
 568
 569
 570
 571
 572
 573
 574
 575
 576
 577
 578
 579
 580
 581
 582
 583
 584
 585
 586
 587
 588
 589
 590
 591
 592
 593
 594
 595
 596
 597
 598
 599
 600
 601
 602
 603
 604
 605
 606
 607
 608
 609
 610
 611
 612
 613
 614
 615
 616
 617
 618
 619
 620
 621
 622
 623
 624
 625
 626
 627
 628
 629
 630
 631
 632
 633
 634
 635
 636
 637
 638
 639
 640
 641
 642
 643
 644
 645
 646
 647
 648
 649
 650
 651
 652
 653
 654
 655
 656
 657
 658
 659
 660
 661
 662
 663
 664
 665
 666
 667
 668
 669
 670
 671
 672
 673
 674
 675
 676
 677
 678
 679
 680
 681
 682
 683
 684
 685
 686
 687
 688
 689
 690
 691
 692
 693
 694
 695
 696
 697
 698
 699
 700
 701
 702
 703
 704
 705
 706
 707
 708
 709
 710
 711
 712
 713
 714
 715
 716
 717
 718
 719
 720
 721
 722
 723
 724
 725
 726
 727
 728
 729
 730
 731
 732
 733
 734
 735
 736
 737
 738
 739
 740
 741
 742
 743
 744
 745
 746
 747
 748
 749
 750
 751
 752
 753
 754
 755
 756
 757
 758
 759
 760
 761
 762
 763
 764
 765
 766
 767
 768
 769
 770
 771
 772
 773
 774
 775
 776
 777
 778
 779
 780
 781
 782
 783
 784
 785
 786
 787
 788
 789
 790
 791
 792
 793
 794
 795
 796
 797
 798
 799
 800
 801
 802
 803
 804
 805
 806
 807
 808
 809
 810
 811
 812
 813
 814
 815
 816
 817
 818
 819
 820
 821
 822
 823
 824
 825
 826
 827
 828
 829
 830
 831
 832
 833
 834
 835
 836
 837
 838
 839
 840
 841
 842
 843
 844
 845
 846
 847
 848
 849
 850
 851
 852
 853
 854
 855
 856
 857
 858
 859
 860
 861
 862
 863
 864
 865
 866
 867
 868
 869
 870
 871
 872
 873
 874
 875
 876
 877
 878
 879
 880
 881
 882
 883
 884
 885
 886
 887
 888
 889
 890
 891
 892
 893
 894
 895
 896
 897
 898
 899
 900
 901
 902
 903
 904
 905
 906
 907
 908
 909
 910
 911
 912
 913
 914
 915
 916
 917
 918
 919
 920
 921
 922
 923
 924
 925
 926
 927
 928
 929
 930
 931
 932
 933
 934
 935
 936
 937
 938
 939
 940
 941
 942
 943
 944
 945
 946
 947
 948
 949
 950
 951
 952
 953
 954
 955
 956
 957
 958
 959
 960
 961
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
Newspeak3
'Newspeak3CompilerAdaptor'
class Newspeak3CompilerAdaptor usingPlatform: platform = NewspeakObject (
"
Copyright (c) 2010  Felix Geller. 
Copyright (c) 2011  Ryan Macnak and Cadence Design Systems

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the ''Software''), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED ''AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE."|

	Language = platform blackMarket NsMultilanguage Language.
	LanguageCompiler = platform blackMarket NsMultilanguage LanguageCompiler.
	LanguageFileWriter = platform blackMarket NsMultilanguage LanguageFileWriter.
	Categorizer = platform blackMarket Categorizer.
	SHRange = platform blackMarket Shout SHRange.
	ImplementationBase = platform blackMarket NewspeakCore ImplementationBase.
	TextColor = platform blackMarket Collections TextColor.
	TextEmphasis = platform blackMarket Collections TextEmphasis.
	Color = platform blackMarket Graphics Color.
	Error = platform blackMarket Exceptions Error.
	SystemMetadata = platform blackMarket NewsqueakMixins SystemMetadata.
	Mixin = platform blackMarket NewsqueakMixins Mixin.
	Smalltalk = platform blackMarket Smalltalk.
	NewspeakObject = platform blackMarket NewspeakObject.
	"MCPolyglotClassDefinition = platform blackMarket MCPolyglotClassDefinition.
	MCPolyglotMethodDefinition = platform blackMarket MCPolyglotMethodDefinition."
	
	Dictionary = platform collections Dictionary.
	OrderedCollection = platform collections OrderedCollection.
	TokenizingParser = platform mirrors parserLib TokenizingParser.	
	TypedNS3Grammar = platform mirrors grammar TypedNS3Grammar.
	compilation = platform mirrors compilation.
	Compiler = compilation Compiler.
	mirrors = platform mirrors.
	lowLevelMirrors = platform mirrors lowLevelMirrors.
	
	ns3Lang = NewspeakLanguage3 new.
	blackMarket = platform blackMarket.
	vmmirror = blackMarket VMMirror new.
|)
(
class NS3BrowserColorizer = NS3Colorizer (|
	coloredText
|)
('as yet unclassified'
applyColor: kind from: start to: end  = (
"Hacked up to roughly match the table in SHTextStylerST80 newsqueakStyleTable.
The advantage is that this code is not dependent on Shout"

	({#error. #undefinedUnary. #undefinedKeyword. #undefinedBinary.} includes: kind)
		ifTrue:
			[ coloredText addAttribute: TextColor red from: start to: end.
			coloredText addAttribute: TextEmphasis underlined from: start to: end.
			^self ].

	({#shadowingTempVar. #obsoleteMessage} includes: kind)
		ifTrue:
			[coloredText addAttribute: TextEmphasis bold from: start to: end.
			coloredText addAttribute: (TextColor color: Color orange) from: start to: end.
			coloredText addAttribute: TextEmphasis underlined from: start to: end.
			^self ].

	({#incompleteKeyword. #incompleteBinary. #incompleteUnary.} includes: kind)
		ifTrue:
			[ coloredText addAttribute: TextEmphasis underlined from: start to: end. ^self ].

	({ #self.  #super. #true. #false. #nil. #string. #symbol. #stringSymbol. #number. #character.  #protected. #private. #public } includes: kind)
		ifTrue:
			[ 
			 coloredText addAttribute: TextColor gray from: start to: end. 
			^self 
			].
		
	({#tempVar. #blockTempVar. #blockPatternArg. #patternArg. #patternTempVar} includes: kind)
		ifTrue:
			[ coloredText addAttribute: TextEmphasis bold from: start to: end. 
			  coloredText addAttribute: TextColor gray from: start to: end. 
			^self 
			].
		
			({#methodTempBar. #leftParenthesis. #rightParenthesis.  #leftParenthesis3. #rightParenthesis3.  #leftParenthesis6. #rightParenthesis6. #blockStart. #blockEnd.  #blockStart3. #blockEnd3.  #blockStart6. #blockEnd6.  #leftBrace. #rightBrace.  #leftBrace3. #rightBrace3.  #leftBrace6. #rightBrace6. 
} includes: kind)
		ifTrue:
			[ coloredText addAttribute: TextEmphasis bold from: start to: end. 
			  coloredText addAttribute: TextColor black from: start to: end. 
			^self 
			].
	#slotDecl = kind
		ifTrue:
			[ coloredText addAttribute: TextEmphasis bold from: start to: end. 
			  coloredText addAttribute: TextColor gray from: start to: end. 
			^self 
			].

	#messagePatternDecl = kind
		ifTrue:
			[ coloredText addAttribute: TextEmphasis bold from: start to: end. ^self ].
		
	kind = #comment
		ifTrue:[ coloredText addAttribute: (TextColor color: Color blue twiceDarker) from: start to: end. 
			^self ].
		
		({#type. #return. #leftParenthesis1. #rightParenthesis1.  #leftParenthesis4. #rightParenthesis4. #leftParenthesis7. #rightParenthesis7. #blockStart1. #blockEnd1.  #blockStart4. #blockEnd4.  #blockStart7. #blockEnd7.  #leftBrace1. #rightBrace1.  #leftBrace4. #rightBrace4.  #leftBrace7. #rightBrace7.} includes: kind)
		ifTrue:
			[ coloredText addAttribute: TextEmphasis bold from: start to: end. 
			  coloredText addAttribute: (TextColor color: Color blue twiceDarker) from: start to: end. 
			^self ].
		({#leftParenthesis2. #rightParenthesis2. #leftParenthesis5. #rightParenthesis5.   #blockStart2. #blockEnd2.  #blockStart5. #blockEnd5.  #leftBrace2. #rightBrace2.  #leftBrace5. #rightBrace5 } includes: kind)
		  ifTrue:[coloredText addAttribute: TextEmphasis bold from: start to: end. 
			  coloredText addAttribute: (TextColor color: Color magenta twiceDarker) from: start to: end. 
			].

	"Transcript show: kind; cr."
)
applyRanges =(	
	rangeMap do: [ :blk | blk value ].
	^coloredText
)
classDefinitionTemplate = (
	^(tokenFromSymbol: #class), [classHeader]
)
noteRange: kind from: start to: end = (
	start = 0 ifTrue:[^self].
	rangeMap add: [ applyColor: kind from: start to: end ].
)
parseText: s <String> fromClass: c <Class> usingSelector: selector <Symbol> ^<Text> = (
	| stream parser |

	assert: [s isString].

	inputSize:: s size.
	klass:: c.
	bracketDepth:: 0.
	braceDepth:: 0.
	parenDepth:: 0.
	rangeMap:: OrderedCollection new.
	cachedScopeStack: nil.

	coloredText:: s asText.
	stream:: s readStream.

	parser:: (perform: selector), [eoi].
	parser parse: stream ifError: [ :msg :pos | 
		noteRange: #error from: pos to: inputSize. 
		^applyRanges ].
	^applyRanges
)
rangesIn: s classOrMetaClass: c workspace: w environment: e = (
^Error signal
))
class NS3Colorizer = TypedNS3Grammar (|
	cachedScopeStack
	klass
	rangeMap
	inputSize
	startComment
	braceDepth
	bracketDepth
	parenDepth
|)
('as yet unclassified'
accessModifier = (
	^super accessModifier wrapper: [ :mod :ws |
		noteRange: mod token asSymbol from: mod start to: mod end.
		mod]
)
assignment = (
	^super assignment
		 wrap:[:t | self noteRange: #assignment from: t start to: t end].
)
beginComment = (
	^ (TokenizingParser new parser: super beginComment) 
			wrap:[:t | 
				self noteRange: #unfinishedComment from: t start to: self inputSize. t].
)
binaryMsgPattern = (
^super binaryMsgPattern
    wrapper:[:sel <Token>  :p <Tuple[Token, Token]> |
	          self pushScope.
	          self currentScope at: p first token put: #parameter.
                self noteRange: #messagePatternDecl from: sel start to: sel end.
                self noteRange: #patternArg from: p first start to: p first end.             
               ].
)
binarySelector = (
^super binarySelector
   wrap:[:t | 
           (Symbol hasInterned: t token ifTrue:[:s | self noteRange: #binary from: t start to: t end])
              ifFalse:[(Symbol thatStartsCaseSensitive: t token skipping: nil) isNil
                          ifTrue:[self noteRange: #undefinedBinary from: t  start to: t end]
                          ifFalse:[self noteRange: #incompleteBinary from: t start to: t end]
                      ].
           t.
         ].
)
block = (
^super block 
   wrapper:[:lb :params :cb :rb |
                  params isNil ifFalse:[params isEmpty ifFalse:[self popScope]].
                  {lb. params. cb. rb}
  ]
)
blockParameter = (
	^super blockParameter wrapper: [ :cn :sd | "blockParameter ::= colon, slotDecl"
		| kind |
		kind:: (symbolInScope: sd first token) ifTrue: [#shadowingTempVar] ifFalse: [#blockPatternArg].
		noteRange: kind from: sd first start to: sd first end.
		sd]
)
blockParameters = (
^super blockParameters
   wrapper:[:ps :vb  | self pushScope. 
	                         ps do:[:p | self currentScope at: p first token put: #parameter].
	                         {ps. vb}
	          ]
)
braceLevelString = (
^self braceDepth = 1 ifTrue:[''] ifFalse:[self braceDepth printString]
)
bracketLevelString = (
	^ self bracketDepth = 1 ifTrue:[''] ifFalse:[self bracketDepth printString]
)
characterConstant = (
	^ super characterConstant 
		   wrap:[: t | self noteRange: #'$' from: t start to: t end. t].
)
classHeader = (
	^super classHeader
		wrap:
			[ :tokens |
			(tokens at: 7) = nil ifFalse:
				[ | decs |
					decs:: (tokens at: 7) size = 3 ifTrue: [
						((tokens at: 7) at: 2) ] ifFalse: [(tokens at: 7) at: 3].			
					
					decs
					do: [ :each | noteRange: #slotDecl from: (each at: 2) first start to: (each at: 2) first end ] ].
			tokens ]
)
codeBody = (
^super codeBody
  wrapper:[:litMsg :tmps :stmts | tmps isNil ifFalse:[tmps isEmpty ifFalse:[self popScope]].
	                                 {tmps. stmts}
	         ]
)
comment = (
^super comment
    wrapper:[:oq :b :eq | self noteRange: #comment from: oq start to: eq end].
)
currentScope = (
self assert: [self scopeStack isEmpty not].
^self scopeStack last
)
decreaseBraceLevel = (
	self braceDepth: (self braceDepth - 1) \\ 7.
)
decreaseBracketLevel = (
self bracketDepth: (self bracketDepth - 1) \\ 7.
)
decreaseParenLevel = (
self parenDepth: (self parenDepth - 1) \\ 7.
)
endComment = (
^(TokenizingParser new parser: super endComment) wrap:[:t | self rangeMap removeLast. t].
)
extendedCanUnderstand: sel = (
	| k |
	k: klass.
	[k isNil] whileFalse: [
		(k canUnderstand: sel) ifTrue: [^true].
		k: k enclosingClass.
	].

	klass mixin applications do: [:any | ^any canUnderstand: sel].
	^Object canUnderstand: sel
)
increaseBraceLevel = (
self braceDepth: (self braceDepth + 1) \\ 7.
)
increaseBracketLevel = (
self bracketDepth: (self bracketDepth + 1) \\ 7.
)
increaseParenLevel = (
	self parenDepth: (self parenDepth + 1) \\ 7.
)
keywordHereSend = (
	^super keywordHereSend wrap:[ :kws | | sel  kind  |
		sel:: String streamContents: [ :s |
			kws do: [ :kwd |
				self rangeMap removeLast.
				s nextPutAll: kwd first token]].
		kind:: symbol: sel
			ifInScope: [#instVar] ifNotInScope: [#undefinedKeyword] ifObsolete: [#obsoleteMessage].
		kws do: [:kwp |
			self noteRange: kind from: kwp first start to: kwp first end]]
)
keywordMsg = (
^super keywordMsg
          wrap:[:kws  |
                  | sel  kind  |
                    sel:: (kws inject:'' into:[:s    :kwd   | 
                                                 s, (kwd at:1) token
                                               ]) asString.
                  (Symbol hasInterned: sel ifTrue:[:s | kind:: #keyword])
                     ifFalse:[(Symbol thatStartsCaseSensitive: sel skipping: nil) isNil
                          ifTrue:[kind:: #undefinedUnary]
                          ifFalse:[kind:: #incompleteUnary]
                      ].
                    
                    kws do:[:kwp |  
                              self noteRange: kind from: kwp first start to: kwp first end. 
                             ].                         
                 ].
)
keywordMsgPattern = (
	^super keywordMsgPattern wrap: [ :kws |
		assert: [kws isEmpty not].
		pushScope.
		kws do: [ :kwp | | kind |
			kind:: (symbolInScope: kwp last first token) ifTrue: [#shadowingTempVar] ifFalse: [#patternArg].
			currentScope at: kwp last first token put: #parameter.
			noteRange: #messagePatternDecl from: kwp first start to: kwp first end.
			noteRange: kind from: kwp last first start to: kwp last first end]]
)
lbracket = (
^super lbracket
   wrap:[:t | 
           | range |
           self increaseBracketLevel.
           range:: ('blockStart', self bracketLevelString) asSymbol.
           self noteRange: range from: t start to: t end. 
           t.
          ]
)
lcurly = (
^super lcurly
   wrap:[:t | 
           | range |
           self increaseBraceLevel.
           range:: ('leftBrace', self braceLevelString) asSymbol.
           self noteRange: range from: t start to: t end. 
           t.
          ]
)
lparen = (
^super lparen 
   wrap:[:t | 
           | range |
           self increaseParenLevel.
           range:: ('leftParenthesis', self parenLevelString) asSymbol.
           self noteRange: range from: t start to: t end. 
           t.
          ]
)
method = (
| res |
  self pushScope.
  res:: super method.
  self popScope.
  ^res
)
methodDef = (
| res |
  self pushScope.
  res:: super methodDef.
  self popScope.
  ^res
)
noteRange: kind from: start to: end  = (
self rangeMap addLast: (SHRange new start: start; end: end; type: kind).
)
number = (
^super number
   wrap:[: t | self noteRange: #number from: t start to: t end. t].
)
parenLevelString = (
	^self parenDepth = 1 ifTrue:[''] ifFalse:[self parenDepth printString]
)
pattern = (
^super pattern
   wrap:[ :tpl | self noteRange: #string 
					from: (tpl at: 1) start 
					to: (tpl at: 3) end.
			tpl at: 2 ]
)
popScope = (
	self scopeStack removeLast
)
pushScope = (
self scopeStack addLast: Dictionary new
)
rangesIn: s classOrMetaClass: c workspace: w environment: e = (
| defaultRange input  |

self inputSize: s size.
self rangeMap: (OrderedCollection new: self inputSize).
self klass: c.
self bracketDepth: 0.
self braceDepth: 0.
self parenDepth: 0.
input:: s readStream.

defaultRange:: SHRange new start:1; end: self inputSize; type: #default.
self rangeMap add: defaultRange.
self methodDecl parse: input ifError:[:msg :pos | 
                                        self rangeMap add:( SHRange new start:(pos max:1); end: self inputSize; type:#excessCode).
                                        ^self rangeMap.
                                       ].
input position < self inputSize 
   ifTrue:[self rangeMap add:( SHRange new start: input position + 1 ; end: self inputSize; type:#excessCode)].
^self rangeMap
)
rbracket = (
^super rbracket
   wrap:[:t | 
           | range |
           range:: ('blockEnd', self bracketLevelString) asSymbol.
           self decreaseBracketLevel.
           self noteRange: range from: t start to: t end. 
           t.
          ]
)
rcurly = (
^super rcurly 
   wrap:[:t | 
           | range |
           range:: ('rightBrace', self braceLevelString) asSymbol.
           self decreaseBraceLevel.
           self noteRange: range from: t start to: t end. 
           t.
          ]
)
returnStatement = (
^super returnStatement
  wrapper:[:h <Token>  : expr :od <Token>  | 
               self noteRange: #return from: h start to: h end.
               expr
             ].
)
returnType = (
^super returnType
   wrapper:[:h <Token> :t | self noteRange: #type from: h start to: h end. t]
)
rparen = (
^super rparen 
   wrap:[:t | 
           | range |
           range:: ('rightParenthesis', self parenLevelString) asSymbol.
           self decreaseParenLevel.
           self noteRange: range from: t start to: t end. 
           t.
          ]
)
scopeStack = (
	"deal with forwarding reference"
	cachedScopeStack isCollection 
		ifFalse: [ cachedScopeStack:: OrderedCollection new ].
	^ cachedScopeStack
)
semicolon = (
^super semicolon
  wrap:[:t | self noteRange: #cascadeSeparator from: t start to: t end. t].
)
setterKeyword = (
	^super setterKeyword wrap:[ :skw <Token> | | kind  |
		kind:: (self symbolInScope: (skw token copyUpToLast: $:))
			ifTrue:[#instVar]
			ifFalse:[#undefinedKeyword].
		self noteRange: kind from: skw  start to: skw end.
		skw]
	)
slotDef = (
	^ super slotDef wrap: [ :tokens | | sd |
		sd:: (tokens at: 2) first.
		noteRange: #slotDecl from: sd start to: sd end.
		tokens]
)
slotName = (
	^super slotName wrap:[ :n <Token> |
		| kind |
		kind:: ({'self'. 'super'. 'true'. 'false'. 'nil'. 'thisContext'} includes: n token)
			ifTrue: [n token asSymbol]
                  ifFalse: [symbol: n token
			ifInScope: [#instVar] ifNotInScope: [#undefinedUnary] ifObsolete: [#obsoleteMessage]].
		noteRange: kind from: n start to: n end.
		n]
)
string = (
^super string
   wrap:[:t | self noteRange: #string from: t start to: t end. t]
)
symbol: aString <String> ifInScope: inScopeAction ifNotInScope: notInScopeAction ifObsolete: obsoleteAction = (
	scopeStack do: [:s | (s includesKey: aString) ifTrue:[^inScopeAction value]].
	Symbol hasInterned: aString ifTrue: [ :sel <Symbol> |
		scopeStack do: [:s | (s includesKey: sel) ifTrue:[^inScopeAction value]].
		(extendedCanUnderstand: sel) ifTrue:[
			(ImplementationBase canUnderstand: sel)
				ifTrue: [^obsoleteAction value]
				ifFalse: [^inScopeAction value]]].
	^notInScopeAction value
)
symbolConstant = (
^super symbolConstant
   wrapper:[:p <Token>  :s | 
               self noteRange: #symbol from: p start to: s end.
               s.
              ].
)
symbolInScope: aString <String> ^ <Boolean> = (
	scopeStack do: [:s | (s includesKey: aString) ifTrue:[^true]].
	^Symbol hasInterned: aString ifTrue: [ :sel <Symbol> |
		scopeStack do: [:s | (s includesKey: sel) ifTrue:[^true]].
		(extendedCanUnderstand: sel) ifTrue:[^true].
		^false]
)
temporaries = (
^super temporaries wrap: [ :parts | 
	| vb1 vb2 vds vb3 vb4 |
	
	parts size = 3 ifTrue: [ 
		vb1:: parts at: 1.
		vb2:: vb1. 
		vds:: parts at: 2. 
		vb3:: parts at: 3.
		vb4:: vb3] ifFalse: [ 
		vb1:: parts at: 1. 
		vb2:: parts at: 2.
		vds:: parts at: 3.
		vb3:: parts at: 4.
		vb4:: parts at: 5].
	
	vds isEmpty ifFalse: [pushScope].
	noteRange: #methodTempBar from: vb1 start to: vb2 end.
	vds do: [ :vd | | v kind |
		v:: (vd at: 2)  first.
		kind:: (symbolInScope: v token) ifTrue: [#shadowingTempVar] ifFalse: [#tempVar].
		currentScope at: v token put: #temporary.
		currentScope at: v token, ':' put: #temporary.
		noteRange: kind from: v start to: v end].
	noteRange: #methodTempBar from: vb3 start to: vb4 end.
	vds]
)
type = (
^super type
   wrapper:[:lb :te : rb | self noteRange: #type from: lb start to: rb end. te]
)
unaryMsgPattern = (
	^super unaryMsgPattern
		wrap:
			[:sel <Symbol> |
			self noteRange: #messagePatternDecl from: sel start to: sel end.
			sel ].
)
unarySelector = (
^super unarySelector
   wrap:[:t | 
           (Symbol hasInterned: t token ifTrue:[:s | self noteRange: #unary from: t start to: t end])
              ifFalse:[(Symbol thatStartsCaseSensitive: t token skipping: nil) isNil
                          ifTrue:[self noteRange: #undefinedUnary from: t  start to: t end]
                          ifFalse:[self noteRange: #incompleteUnary from: t start to: t end]
                      ].
           t.
         ].
)
variableName = (
^super variableName
  wrap:[:n <Token> |   n token = 'self'
                  ifTrue:[self noteRange: #self from: n start to: n end]
                  ifFalse:[n token = 'super' ifTrue:[self noteRange: #super from: n start to: n end]
                  ifFalse:[n token = 'true' ifTrue:[self noteRange: #true from: n start to: n end]
                  ifFalse:[n token = 'false' ifTrue:[self noteRange: #false from: n start to: n end]
                  ifFalse:[n token = 'nil' ifTrue:[self noteRange: #nil from: n start to: n end]
                  ifFalse:[n token = 'thisContext' ifTrue:[self noteRange: #thisContext from: n start to: n end]
                  ifFalse:[]]]]]].
             n.
         ]
))
class NS3DefinitionCollector onStream: stream withTimestamps: ts = (
"Describe the class in this comment."|
	input = stream.
	definitions = OrderedCollection new.
	timestamps = ts.
	
	cat
	klass
	isMeta
|(ns3Lang parserInstance compilationUnit
		parse: input) apply: self)
('as yet unclassified'
categoryNode: node <CategoryAST> = (
	| oldCat |
	oldCat: cat.
	
	cat: node name asSymbol.
	node methods do: [:ea | ea apply: self].
	
	cat: oldCat.
)
classNode: node <ClassDeclarationAST> = (
	| simpleName fullName src defn myCat oldCat oldKlass oldIsMeta |
	"src:: input contents copyFrom: node hdr start to: node hdr end."
	src:: input contents copy.
	
	simpleName:: node hdr name.
	klass isNil
		ifTrue: [fullName:: simpleName]
		ifFalse: [fullName:: klass , '`' , simpleName].
	myCat: node hdr category.
	myCat isNil ifTrue: [myCat: cat , '-nested'].
	myCat: myCat asSymbol.

	defn:: MCPolyglotClassDefinition
		language: ns3Lang
		headerString: src
		name: fullName
		superclassName: #ProtoObject
		category: myCat
		instVarNames: (node hdr slots collect: [:ea | ea apply: self])
		classInstVarNames: {}
		type: #normal
		comment: ''.
		
	definitions add: defn.
	true ifTrue: [^self].
	
	oldCat: cat.
	oldKlass: klass.
	oldIsMeta: isMeta.
	
	cat: myCat.
	klass: fullName.
	isMeta: false.	
	node instanceSide apply: self.
	isMeta: true.
	node classSide apply: self.
	
	isMeta: oldIsMeta.
	cat: oldCat.
	klass: oldKlass.
)
methodNode: node <MethodAST> = (
	| src defn ts sel |
	src:: input contents copyFrom: node start to: node end.
	sel:: node pattern selector.
	ts:: [(timestamps at: klass asString) at: sel asString] ifError: [nil].
	ts:: nil.

	defn:: MCPolyglotMethodDefinition
			className: klass
			classIsMeta: isMeta
			selector: sel
			category: cat
			timeStamp: ts
			source: src.
			
	definitions add: defn.
)
sideNode: node <NSSideAST> = (
	node categories do: [:ea | ea apply: self].
	node nestedClasses do: [:ea | ea apply: self].
)
slotDefNode: node <MutableSlotDefAST> = (

	|src|
	src:: input contents copyFrom: node slotDecl start to: node slotDecl end.
	^src
))
class NS3FileWriter = LanguageFileWriter (|
|)
('as yet unclassified'
declSourceFor: selector of: aClass = (

	^(aClass compiledMethodAt: selector) getSource
)
isTrivial: organization <ClassOrganizer> ^<Boolean> = (

	^organization elementArray isEmpty and:
		[ (organization categories copyWithout: Categorizer nullCategory) isEmpty]
)
language = (
	^ ns3Lang
)
prefersSmalltalkClassDefinitionSyntaxInMonticello = (
	"Answer if classes of this writer class's language prefer
	 to use the Smalltalk style class defintion or not for
	 comparing class definitions."
	^false
)
writeDeclarationOf: aClass on: aStream = (
	"print the source for this class in the top level syntax on aStream, without the
	language id and class category"
	| sels komment |

	aStream cr; nextPutAll: 'class '.
	writeHeaderFor: aClass on: aStream.

	"Instance side"
	aStream cr; nextPut: $(.
	writeNestedClassesOf: aClass on: aStream.
	writeOrganizationOf: aClass on: aStream.
	aStream nextPut: $).

	"Class side"
	(isTrivial: aClass class organization)
		ifFalse:
			[ aStream nextPutAll: ' : ('; cr.
     		writeOrganizationOf: aClass class on: aStream.
			aStream nextPut: $) ]
)
writeHeaderFor: klass on:  aStream = (

aStream nextPutAll: (klass language metadataFor: klass)
)
writeLanguageAndCategoryFor: aClass <Class> on: aStream <WriteStream> = (
	aStream nextPutAll: aClass language name asString; cr.
	aStream print: aClass category asString; cr.
)
writeNestedClassesOf: aClass <Class> on: aStream <Stream> = (
	(SystemMetadata definingClassMetadataOf: aClass) nestedClasses do: [ :nc <Class> | 
		aStream cr.
		writeDeclarationOf: nc on: aStream.
	].
)
writeOrganizationOf: cls <Class> on: aStream <WriteStream> ^<self> = (
	| organization <ClassOrganizer> |
	organization:: cls organization.

	(isTrivial: organization) ifTrue: [ ^self ].
	organization categories do:
		[ :cat | | sels |
		aStream  nextPut:$'; nextPutAll: cat;  nextPut:$'; cr.
		sels:: organization listAtCategoryNamed: cat.
		sels do: [ :sel | aStream nextPutAll: (self declSourceFor: sel of: cls); cr; cr ]]
))
class Newspeak3CompilerAdaptor = LanguageCompiler (
"I'd rather subclass Newspeak2Compilation`Compiler but this fails because of a bug in NS2Compiler, which doesn't set the enclosingObject slots correctly."|
	language = ns3Lang.
	compiler = Compiler new language: language; yourself.
|)
('as yet unclassified'
compileClassHeader: src <Stream> of: klassMirror <NS2Mixin> ^ <Class> = (
	self halt.
"	|
		newRep <MixinRep>
		klass <Class>
		metadata <DefiningClassMetadata>
		compiledMixinMirror <CompiledMixinMirror>
		mixinRep <MixinRep>
		klassMixinRep <MixinRep>
	|
	
	klass:: klassMirror implementationMirror implementationClass.
	metadata:: SystemMetadata definingClassMetadataOf: klass.
	newRep:: compiler compileClassHeader: src of: klassMirror.
	^(metadata enclosingClass)
		ifNil:[
			mixinRep:: mirrors mixinRepFor: klass.
			compiledMixinMirror: newRep first.
			mixinRep at: 1 put: compiledMixinMirror.
			(reflection installMixinReps: { mixinRep }) first ]
		ifNotNil:[:ec |
			mixinRep:: mirrors mixinRepFor: ec.
			klassMixinRep:: (mixinRep at: 2) detect: [ :mr | (mr first name) = klass name].
			compiledMixinMirror:: newRep last first first.	
			klassMixinRep at: 1 put: compiledMixinMirror.
			reflection installMixinReps: { {newRep first. mixinRep last} }.
 			klass ]"
)
compileMethodSource: src <ReadStream> 
category: category <String> 
within: cls <Class> ^ <Symbol> = (

	| builder methodBuilder |
	builder:: mirrors MixinBuilder reflecting: cls mixin.
	methodBuilder:: (builder methods addFromSource: src).
	methodBuilder category: category.
	builder declaration install.
	^methodBuilder simpleName
)
compileMethodSource: src <ReadStream> 
within: cls <Class> ^ <Symbol> = (
	^ compileMethodSource: src category: #'as yet unclassified' within: cls.
)
compileNestedClass: ns <ClassDeclarationAST> within: aClass <Class> = (
	self halt.
"	| 
		moduleClass <Class>
		moduleMixinRep <MixinRep>
		enclosingClassMixinRep <MixinRep>
		nestedClasses 	<Collection[MixinRep]>		
		classMirror <NS2ClassStencilMirror>
		classSource <String>
		compilationResult <Collection[MixinRep]>
		installedClass <Class>
		nestedClassName <String>
	| 
	classSource:: (wrapClassSource: input contents for: aClass) readStream.
	
	moduleClass:: (SystemMetadata definingClassMetadataOf: aClass) definingModule.
	moduleMixinRep:: mirrors mixinRepFor: moduleClass.

	enclosingClassMixinRep:: findMixinRepOfClassNamed: aClass name inMixinReps: { moduleMixinRep }.	
	classMirror:: reflection mixinFor: aClass. 

	compilationResult:: compiler compileClassSource: classSource within: classMirror.
	
	enclosingClassMixinRep at: 1 put: compilationResult first.
	
	nestedClassName:: (compilationResult at: 2) first first name.
	enclosingClassMixinRep second removeAllSuchThat: [ :mr | mr first name = nestedClassName ].
	enclosingClassMixinRep second add: (compilationResult at: 2) first.

	installedClass:: (reflection installMixinReps: { moduleMixinRep }) anyOne.
	^ (SystemMetadata allNestedClassesOf: installedClass) detect: [ :nc | nc name = nestedClassName]"
)
compileNestedClassSource: src <String> within: aClass <Class> = (
	
	| enclosing newClass |
	enclosing:: mirrors MixinBuilder reflecting: aClass mixin.
	newClass:: enclosing nestedClasses addFromSource: src.
	^newClass install reflectee definingClass
)
compileUnit: src <Stream> ^ <Class> = (
		"Compile File"
	| builder mixinMirror klass |
	builder:: mirrors ClassDeclarationBuilder fromUnitSource: src.
	Smalltalk at: builder simpleName ifPresent: [:it | builder prvtExistingMixin: it mixin].
	mixinMirror:: builder install.
	klass:: mixinMirror reflectee apply: NewspeakObject withName: mixinMirror simpleName.
	Smalltalk at: klass name put: klass.
	klass category: mixinMirror reflectee definingClass category.
	^klass
)
evaluate: textOrStream in: aContext to: receiver notifying: aRequestor ifFail: failBlock logged: logFlag = (
	
	| string |
	string:: textOrStream readStream contents asString. "Ugly coercion"

	aContext ifNil: [
		"Inspector DoIt"
		^((mirrors ObjectMirror reflecting: receiver) evaluate: string) reflectee
	] ifNotNil: [
		"Debugger DoIt"
		^((mirrors ActivationMirror reflecting: aContext) evalute: string) reflectee
	].
)
findMixinRepOfClassNamed: className <String> inMixinReps: mixinReps <MixinRep> ^ <MixinRep> = (
	
	"Do a breadth-first-search on mixin reps.
	Why do we do it this way? We could make use of the naming scheme and only follow the right mixins."
	| nestedMixinReps |
	nestedMixinReps:: OrderedCollection new.
	mixinReps do: [:mr |
		mr first name = className
			ifTrue: [^ mr]
			ifFalse: [nestedMixinReps addAll: (mr at: 2)]].

	nestedMixinReps isEmpty
		ifTrue: [mixinReps errorNotFound: className]
		ifFalse: [^ findMixinRepOfClassNamed: className inMixinReps: nestedMixinReps].
)
wrapClassSource: src for: aClass = (
	| cat <String> |
	cat:: aClass category.
	cat isNil ifTrue:[cat:: 'Uncategorized NS3'].
	^ 'Newspeak3 ''', cat,''' ',src
)) : ('as yet unclassified'
evaluate: textOrString for: anObject logged: logFlag = (
	^self evaluate: textOrString for: anObject notifying: nil logged: logFlag
)
evaluate: textOrString for: anObject notifying: aController logged: logFlag = (
	"Compile and execute the argument, textOrString with respect to the class 
	of anObject. If a compilation error occurs, notify aController. If both 
	compilation and execution are successful then, if logFlag is true, log 
	(write) the text onto a system changes file so that it can be replayed if 
	necessary."

	^ self new
				evaluate: textOrString
				in: nil
				to: anObject
				notifying: aController
				ifFail: [^nil]
				logged: logFlag.
))
class NewspeakColorizerPreferences = NewspeakObject (
""|  |)
('as yet unclassified'
Nil ^ <[]> = (
	^[ :start :end | coloredText addAttribute: TextColor gray from: start to: end.
      ].
)
Self ^ <[]> = (
	^[ :start :end | coloredText addAttribute: TextColor gray from: start to: end.
      ].
)
Super ^ <[]> = (
	^[ :start :end | coloredText addAttribute: TextColor gray from: start to: end.
      ].
)
applyColor: kind <Symbol> from: start <Integer> to: end  <Integer> = (
	(perform: kind) value: start value: end
)
blockEnd ^ <[]> = (
	^[ :start :end | coloredText addAttribute: TextColor black from: start to: end.
	coloredText addAttribute: TextEmphasis bold from: start to: end.
      ].
)
blockEnd1 ^ <[]> = (
	^[ :start :end | coloredText addAttribute: (TextColor color: Color blue twiceDarker) from: start to: end.
	coloredText addAttribute: TextEmphasis bold from: start to: end.
      ].
)
blockEnd2 ^ <[]> = (
	^[ :start :end | coloredText addAttribute: (TextColor color: Color magenta twiceDarker) from: start to: end.
	coloredText addAttribute: TextEmphasis bold from: start to: end.
      ].
)
blockEnd3 ^ <[]> = (
	^[ :start :end | coloredText addAttribute: TextColor black from: start to: end.
	coloredText addAttribute: TextEmphasis bold from: start to: end.
      ].
)
blockEnd4 ^ <[]> = (
	^[ :start :end | coloredText addAttribute: (TextColor color: Color blue twiceDarker) from: start to: end.
	coloredText addAttribute: TextEmphasis bold from: start to: end.
      ].
)
blockEnd5 ^ <[]> = (
	^[ :start :end | coloredText addAttribute: (TextColor color: Color magenta twiceDarker) from: start to: end.
	coloredText addAttribute: TextEmphasis bold from: start to: end.
      ].
)
blockEnd6 ^ <[]> = (
	^[ :start :end | coloredText addAttribute: TextColor black from: start to: end.
	coloredText addAttribute: TextEmphasis bold from: start to: end.
      ].
)
blockEnd7 ^ <[]> = (
	^[ :start :end | coloredText addAttribute: (TextColor color: Color blue twiceDarker) from: start to: end.
	coloredText addAttribute: TextEmphasis bold from: start to: end.
      ].
)
blockPatternArg ^ <[]> = (
	^[ :start :end | coloredText addAttribute: TextColor gray from: start to: end.
	coloredText addAttribute: TextEmphasis bold from: start to: end.
      ].
)
blockStart ^ <[]> = (
	^[ :start :end | coloredText addAttribute: TextColor black from: start to: end.
	coloredText addAttribute: TextEmphasis bold from: start to: end.
      ].
)
blockStart1 ^ <[]> = (
	^[ :start :end | coloredText addAttribute: (TextColor color: Color blue twiceDarker) from: start to: end.
	coloredText addAttribute: TextEmphasis bold from: start to: end.
      ].
)
blockStart2 ^ <[]> = (
	^[ :start :end | coloredText addAttribute: (TextColor color: Color magenta twiceDarker) from: start to: end.
	coloredText addAttribute: TextEmphasis bold from: start to: end.
      ].
)
blockStart3 ^ <[]> = (
	^[ :start :end | coloredText addAttribute: TextColor black from: start to: end.
	coloredText addAttribute: TextEmphasis bold from: start to: end.
      ].
)
blockStart4 ^ <[]> = (
	^[ :start :end | coloredText addAttribute: (TextColor color: Color blue twiceDarker) from: start to: end.
	coloredText addAttribute: TextEmphasis bold from: start to: end.
      ].
)
blockStart5 ^ <[]> = (
	^[ :start :end | coloredText addAttribute: (TextColor color: Color magenta twiceDarker) from: start to: end.
	coloredText addAttribute: TextEmphasis bold from: start to: end.
      ].
)
blockStart6 ^ <[]> = (
	^[ :start :end | coloredText addAttribute: TextColor black from: start to: end.
	coloredText addAttribute: TextEmphasis bold from: start to: end.
      ].
)
blockStart7 ^ <[]> = (
	^[ :start :end | coloredText addAttribute: (TextColor color: Color blue twiceDarker) from: start to: end.
	coloredText addAttribute: TextEmphasis bold from: start to: end.
      ].
)
blockTempVar ^ <[]> = (
	^[ :start :end | coloredText addAttribute: TextColor gray from: start to: end.
	coloredText addAttribute: TextEmphasis bold from: start to: end.
      ].
)
boolean ^ <[]> = (
	^[ :start :end | coloredText addAttribute: TextColor gray from: start to: end.
      ].
)
character ^ <[]> = (
	^[ :start :end | coloredText addAttribute: TextColor gray from: start to: end.
      ].
)
comment ^ <[]> = (
	^[ :start :end | coloredText addAttribute: (TextColor color: Color blue twiceDarker) from: start to: end.
      ].
)
error ^ <[]> = (
	^[ :start :end | coloredText addAttribute: TextColor red from: start to: end.
	coloredText addAttribute: TextEmphasis underlined from: start to: end.
      ].
)
incompleteBinary ^ <[]> = (
	^[ :start :end |
	coloredText addAttribute: TextEmphasis underlined from: start to: end.
      ].
)
incompleteKeyword ^ <[]> = (
	^[ :start :end |
	coloredText addAttribute: TextEmphasis underlined from: start to: end.
      ].
)
incompleteUnary ^ <[]> = (
	^[ :start :end |
	coloredText addAttribute: TextEmphasis underlined from: start to: end.
      ].
)
leftBrace ^ <[]> = (
	^[ :start :end | coloredText addAttribute: TextColor black from: start to: end.
	coloredText addAttribute: TextEmphasis bold from: start to: end.
      ].
)
leftBrace1 ^ <[]> = (
	^[ :start :end | coloredText addAttribute: (TextColor color: Color blue twiceDarker) from: start to: end.
	coloredText addAttribute: TextEmphasis bold from: start to: end.
      ].
)
leftBrace2 ^ <[]> = (
	^[ :start :end | coloredText addAttribute: (TextColor color: Color magenta twiceDarker) from: start to: end.
	coloredText addAttribute: TextEmphasis bold from: start to: end.
      ].
)
leftBrace3 ^ <[]> = (
	^[ :start :end | coloredText addAttribute: TextColor black from: start to: end.
	coloredText addAttribute: TextEmphasis bold from: start to: end.
      ].
)
leftBrace4 ^ <[]> = (
	^[ :start :end | coloredText addAttribute: (TextColor color: Color blue twiceDarker) from: start to: end.
	coloredText addAttribute: TextEmphasis bold from: start to: end.
      ].
)
leftBrace5 ^ <[]> = (
	^[ :start :end | coloredText addAttribute: (TextColor color: Color magenta twiceDarker) from: start to: end.
	coloredText addAttribute: TextEmphasis bold from: start to: end.
      ].
)
leftBrace6 ^ <[]> = (
	^[ :start :end | coloredText addAttribute: TextColor black from: start to: end.
	coloredText addAttribute: TextEmphasis bold from: start to: end.
      ].
)
leftBrace7 ^ <[]> = (
	^[ :start :end | coloredText addAttribute: (TextColor color: Color blue twiceDarker) from: start to: end.
	coloredText addAttribute: TextEmphasis bold from: start to: end.
      ].
)
leftParenthesis ^ <[]> = (
	^[ :start :end | coloredText addAttribute: TextColor black from: start to: end.
	coloredText addAttribute: TextEmphasis bold from: start to: end.
      ].
)
leftParenthesis1 ^ <[]> = (
	^[ :start :end | coloredText addAttribute: (TextColor color: Color blue twiceDarker) from: start to: end.
	coloredText addAttribute: TextEmphasis bold from: start to: end.
      ].
)
leftParenthesis2 ^ <[]> = (
	^[ :start :end | coloredText addAttribute: (TextColor color: Color magenta twiceDarker) from: start to: end.
	coloredText addAttribute: TextEmphasis bold from: start to: end.
      ].
)
leftParenthesis3 ^ <[]> = (
	^[ :start :end | coloredText addAttribute: TextColor black from: start to: end.
	coloredText addAttribute: TextEmphasis bold from: start to: end.
      ].
)
leftParenthesis4 ^ <[]> = (
	^[ :start :end | coloredText addAttribute: (TextColor color: Color blue twiceDarker) from: start to: end.
	coloredText addAttribute: TextEmphasis bold from: start to: end.
      ].
)
leftParenthesis5 ^ <[]> = (
	^[ :start :end | coloredText addAttribute: (TextColor color: Color magenta twiceDarker) from: start to: end.
	coloredText addAttribute: TextEmphasis bold from: start to: end.
      ].
)
leftParenthesis6 ^ <[]> = (
	^[ :start :end | coloredText addAttribute: TextColor black from: start to: end.
	coloredText addAttribute: TextEmphasis bold from: start to: end.
      ].
)
leftParenthesis7 ^ <[]> = (
	^[ :start :end | coloredText addAttribute: (TextColor color: Color blue twiceDarker) from: start to: end.
	coloredText addAttribute: TextEmphasis bold from: start to: end.
      ].
)
messagePatternDecl ^ <[]> = (
	^[ :start :end | 
	coloredText addAttribute: TextEmphasis bold from: start to: end.
      ].
)
methodTempBar ^ <[]> = (
	^[ :start :end | coloredText addAttribute: TextColor black from: start to: end.
	coloredText addAttribute: TextEmphasis bold from: start to: end.
      ].
)
number ^ <[]> = (
	^[ :start :end | coloredText addAttribute: TextColor gray from: start to: end.
      ].
)
patternArg ^ <[]> = (
	^[ :start :end | coloredText addAttribute: TextColor gray from: start to: end.
	coloredText addAttribute: TextEmphasis bold from: start to: end.
      ].
)
patternTempVar ^ <[]> = (
	^[ :start :end | coloredText addAttribute: TextColor gray from: start to: end.
	coloredText addAttribute: TextEmphasis bold from: start to: end.
      ].
)
return ^ <[]> = (
	^[ :start :end | coloredText addAttribute: (TextColor color: Color blue twiceDarker) from: start to: end.
	coloredText addAttribute: TextEmphasis bold from: start to: end.
      ].
)
rightBrace ^ <[]> = (
	^[ :start :end | coloredText addAttribute: TextColor black from: start to: end.
	coloredText addAttribute: TextEmphasis bold from: start to: end.
      ].
)
rightBrace1 ^ <[]> = (
	^[ :start :end | coloredText addAttribute: (TextColor color: Color blue twiceDarker) from: start to: end.
	coloredText addAttribute: TextEmphasis bold from: start to: end.
      ].
)
rightBrace2 ^ <[]> = (
	^[ :start :end | coloredText addAttribute: (TextColor color: Color magenta twiceDarker) from: start to: end.
	coloredText addAttribute: TextEmphasis bold from: start to: end.
      ].
)
rightBrace3 ^ <[]> = (
	^[ :start :end | coloredText addAttribute: TextColor black from: start to: end.
	coloredText addAttribute: TextEmphasis bold from: start to: end.
      ].
)
rightBrace4 ^ <[]> = (
	^[ :start :end | coloredText addAttribute: (TextColor color: Color blue twiceDarker) from: start to: end.
	coloredText addAttribute: TextEmphasis bold from: start to: end.
      ].
)
rightBrace5 ^ <[]> = (
	^[ :start :end | coloredText addAttribute: (TextColor color: Color magenta twiceDarker) from: start to: end.
	coloredText addAttribute: TextEmphasis bold from: start to: end.
      ].
)
rightBrace6 ^ <[]> = (
	^[ :start :end | coloredText addAttribute: TextColor black from: start to: end.
	coloredText addAttribute: TextEmphasis bold from: start to: end.
      ].
)
rightBrace7 ^ <[]> = (
	^[ :start :end | coloredText addAttribute: (TextColor color: Color blue twiceDarker) from: start to: end.
	coloredText addAttribute: TextEmphasis bold from: start to: end.
      ].
)
rightParenthesis ^ <[]> = (
	^[ :start :end | coloredText addAttribute: TextColor black from: start to: end.
	coloredText addAttribute: TextEmphasis bold from: start to: end.
      ].
)
rightParenthesis1 ^ <[]> = (
	^[ :start :end | coloredText addAttribute: (TextColor color: Color blue twiceDarker) from: start to: end.
	coloredText addAttribute: TextEmphasis bold from: start to: end.
      ].
)
rightParenthesis2 ^ <[]> = (
	^[ :start :end | coloredText addAttribute: (TextColor color: Color magenta twiceDarker) from: start to: end.
	coloredText addAttribute: TextEmphasis bold from: start to: end.
      ].
)
rightParenthesis3 ^ <[]> = (
	^[ :start :end | coloredText addAttribute: TextColor black from: start to: end.
	coloredText addAttribute: TextEmphasis bold from: start to: end.
      ].
)
rightParenthesis4 ^ <[]> = (
	^[ :start :end | coloredText addAttribute: (TextColor color: Color blue twiceDarker) from: start to: end.
	coloredText addAttribute: TextEmphasis bold from: start to: end.
      ].
)
rightParenthesis5 ^ <[]> = (
	^[ :start :end | coloredText addAttribute: (TextColor color: Color magenta twiceDarker) from: start to: end.
	coloredText addAttribute: TextEmphasis bold from: start to: end.
      ].
)
rightParenthesis6 ^ <[]> = (
	^[ :start :end | coloredText addAttribute: TextColor black from: start to: end.
	coloredText addAttribute: TextEmphasis bold from: start to: end.
      ].
)
rightParenthesis7 ^ <[]> = (
	^[ :start :end | coloredText addAttribute: (TextColor color: Color blue twiceDarker) from: start to: end.
	coloredText addAttribute: TextEmphasis bold from: start to: end.
      ].
)
slotDecl ^ <[]> = (
	^[ :start :end | coloredText addAttribute: TextColor gray from: start to: end.
	coloredText addAttribute: TextEmphasis bold from: start to: end.
      ].
)
string ^ <[]> = (
	^[ :start :end | coloredText addAttribute: TextColor gray from: start to: end.
      ].
)
stringSymbol ^ <[]> = (
	^[ :start :end | coloredText addAttribute: TextColor gray from: start to: end.
      ].
)
symbol ^ <[]> = (
	^[ :start :end | coloredText addAttribute: TextColor gray from: start to: end.
      ].
)
tempVar ^ <[]> = (
	^[ :start :end | coloredText addAttribute: TextColor gray from: start to: end.
	coloredText addAttribute: TextEmphasis bold from: start to: end.
      ].
)
type ^ <[]> = (
	^[ :start :end | coloredText addAttribute: (TextColor color: Color blue twiceDarker) from: start to: end.
	coloredText addAttribute: TextEmphasis bold from: start to: end.
      ].
)
undefinedBinary ^ <[]> = (
	^[ :start :end | coloredText addAttribute: TextColor red from: start to: end.
	coloredText addAttribute: TextEmphasis underlined from: start to: end.
      ].
)
undefinedKeyword ^ <[]> = (
	^[ :start :end | coloredText addAttribute: TextColor red from: start to: end.
	coloredText addAttribute: TextEmphasis underlined from: start to: end.
      ].
)
undefinedUnary ^ <[]> = (
	^[ :start :end | coloredText addAttribute: TextColor red from: start to: end.
	coloredText addAttribute: TextEmphasis underlined from: start to: end.
      ].
))
class NewspeakLanguage3 = Language (|
	parserClass = compilation Parser.
	parser = parserClass.
	parserInstance = parser new.
	
	cachedColorizer
	cachedBrowserColorizer
	
	cachedSourceMirrorParser
|)
('as yet unclassified'
= other = (
	^ self name = other name
)
activationMirrorFor: context using: activationMirrors = (
	^activationMirrors ActivationMirrorCompiledByNewspeak onContext: context
)
becomeLanguageFor: cls = (
	assert: cls language isNewspeakLanguage2
	message: 'Cannot convert from ',cls language asString,' to NewspeakLanguage3'.
	
	becomeLanguageFor: cls metadata: (SystemMetadata definingClassMetadataOf: cls) languageData.
)
becomeLanguageFor: cls metadata: md = (
	| classMetadata <DefiningClassMetadata> |
	"nothing to do"
	cls language isNewspeakLanguage3 ifTrue: [ ^ self ].
	
	assert: cls language isNewspeakLanguage2
	message: 'Cannot convert from ',cls language asString,' to NewspeakLanguage3'.
	
	classMetadata:: SystemMetadata definingClassMetadataOf: cls. 
	classMetadata language: self.
)
browserColorizer = (
	^ NS3BrowserColorizer
)
browserColorizerInstance = (
	true ifTrue: [ cachedBrowserColorizer:: NS3BrowserColorizer new ].
	^ cachedBrowserColorizer
)
classSubjectFor: aClass using: ide = (
	^ide browsingNS3 ClassSubject onModel: 
		(mirrors ClassDeclarationMirror reflecting: aClass mixin)
)
colorizer = (
	^ NS3Colorizer
)
colorizerInstance = (
	true ifTrue: [ cachedColorizer:: NS3Colorizer new ].
	^ cachedColorizer
)
compiler = (
	^Newspeak3CompilerAdaptor
)
compilerModule = (

	^compilation
)
definitionCollectorClass = (
	^NS3DefinitionCollector
)
extractLocalName: str = (
	^ (str findTokens: syntheticNameSeparatorCharacter) last
)
fileExtension = (
	^ 'ns3'
)
isConstructorSelector: sel forMixin: mxn = (
	^mirrors isConstructorSelector: sel forMixin: mxn
)
isNestedClassAccessorSelector: sel forMixin: mxn = (
	| ts <OrderedCollection[String]> |
	ts:: sel findTokens: syntheticNameSeparator.
	^ (ts size = 1 and: [mxn classes includesMirrorNamed: ts anyOne])
		or: [ ts size > 2 
			and: [(ts last = 'slot' or: [ts last = 'slot:']) 
				and: [mxn classes includesMirrorNamed: (ts at: ts size - 1)]]]
)
isNewspeakLanguage3 = (
	^ true.
)
isSlotAccessorSelector: sel forMixin: mxn = (
	^ (mxn slots includesMirrorNamed: sel)
		or: [(sel endsWith: ':') 
			and: [mxn slots includesMirrorNamed: (sel copyFrom: 1 to: sel size - 1)]].	
)
isSubInitializerSelector: sel = (
	| ts  <OrderedCollection[String]> | 
	ts:: sel findTokens: syntheticNameSeparator.
	^ ts size > 1 
		and: [(ts at: ts size - 1) isPositiveInteger 
		and: [ (ts last) startsWith: 'init' ]].	
)
isSuperConstructorSelector: sel = (
	| ts  <OrderedCollection[String]> | 
	ts:: sel findTokens: syntheticNameSeparator.
	^ ts size > 1 and: [(ts at: ts size - 1) = 'superInit'].
)
isTopLevelClassName: cn = (
	^ (cn includes: syntheticNameSeparatorCharacter) not
)
name = (
	^ #'Newspeak3'
)
removeClass: victim <Class> = (
	(SystemMetadata immediatelyNestedClassesOf: victim)
		do: [ :c <Class> | c removeFromSystem ].
	Mixin removeMixinFor: victim.
	SystemMetadata removeClass: victim.
)
sourceMirrorClass = (
	self halt.
	^ NS2SourceMirrorParser
)
syntheticNameSeparator = (
	^ Language syntheticNameSeparator.
)
syntheticNameSeparatorCharacter = (
	^ Language syntheticNameSeparatorCharacter.
)
timeStampFor: m <MethodReference> = (
	^nil
)
writer = (
	^ NS3FileWriter
)))
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.