Scanner.st
changeset 671 8361d4bedc9f
parent 666 bf2af3d84787
child 707 2fe4b3a7708a
equal deleted inserted replaced
670:7358611ae2a7 671:8361d4bedc9f
   587 markCommentFrom:pos1 to:pos2
   587 markCommentFrom:pos1 to:pos2
   588 
   588 
   589     "Created: / 31.3.1998 / 13:34:45 / cg"
   589     "Created: / 31.3.1998 / 13:34:45 / cg"
   590 !
   590 !
   591 
   591 
       
   592 markConstantFrom:pos1 to:pos2
       
   593 
       
   594     "Created: / 1.4.1998 / 13:02:56 / cg"
       
   595 !
       
   596 
   592 markStringFrom:pos1 to:pos2
   597 markStringFrom:pos1 to:pos2
   593 
   598 
   594     "Created: / 31.3.1998 / 16:37:18 / cg"
   599     "Created: / 31.3.1998 / 16:37:18 / cg"
       
   600 !
       
   601 
       
   602 markSymbolFrom:pos1 to:pos2
       
   603 
       
   604     "Created: / 1.4.1998 / 12:58:42 / cg"
   595 ! !
   605 ! !
   596 
   606 
   597 !Scanner methodsFor:'error handling'!
   607 !Scanner methodsFor:'error handling'!
   598 
   608 
   599 lastTokenLineNumber
   609 lastTokenLineNumber
   943 
   953 
   944     source next.
   954     source next.
   945     nextChar := source next.
   955     nextChar := source next.
   946     nextChar notNil ifTrue:[
   956     nextChar notNil ifTrue:[
   947         tokenValue := token := nextChar.
   957         tokenValue := token := nextChar.
   948         tokenType := #Character
   958         tokenType := #Character.
       
   959 "/        self markConstantFrom:tokenPosition to:(tokenPosition + 1).
   949     ] ifFalse:[
   960     ] ifFalse:[
   950         tokenType := #EOF
   961         tokenType := #EOF
   951     ].
   962     ].
   952     ^ tokenType
   963     ^ tokenType
   953 
   964 
   954     "Modified: 20.6.1997 / 17:51:39 / cg"
   965     "Modified: / 1.4.1998 / 13:06:33 / cg"
   955 !
   966 !
   956 
   967 
   957 nextColonOrAssign
   968 nextColonOrAssign
   958     "colon has been read - look for = to make it an assign"
   969     "colon has been read - look for = to make it an assign"
   959 
   970 
  1019                             nextChar := source peek.
  1030                             nextChar := source peek.
  1020                         ]
  1031                         ]
  1021                     ].
  1032                     ].
  1022                 ].
  1033                 ].
  1023                 (nextChar == $:) ifFalse:[
  1034                 (nextChar == $:) ifFalse:[
       
  1035                     self markSymbolFrom:tokenPosition to:(source position-1).
  1024                     tokenValue := token := string asSymbol.
  1036                     tokenValue := token := string asSymbol.
  1025                     tokenType := #Symbol.
  1037                     tokenType := #Symbol.
  1026                     ^ tokenType
  1038                     ^ tokenType
  1027                 ].
  1039                 ].
  1028                 string := string copyWith:nextChar.
  1040                 string := string copyWith:nextChar.
  1048         ].
  1060         ].
  1049         (nextChar == $' ) ifTrue:[
  1061         (nextChar == $' ) ifTrue:[
  1050             "it seems that ST-80 supports arbitrary symbols as #'...'
  1062             "it seems that ST-80 supports arbitrary symbols as #'...'
  1051              (seen in a PD program)"
  1063              (seen in a PD program)"
  1052             self nextString.
  1064             self nextString.
       
  1065             self markSymbolFrom:tokenPosition to:(source position-1).
  1053             tokenValue := token := tokenValue asSymbol.
  1066             tokenValue := token := tokenValue asSymbol.
  1054             tokenType := #Symbol.
  1067             tokenType := #Symbol.
  1055             ^ tokenType
  1068             ^ tokenType
  1056         ].
  1069         ].
  1057         ((TypeArray at:(nextChar asciiValue)) == #special) ifTrue:[
  1070         ((TypeArray at:(nextChar asciiValue)) == #special) ifTrue:[
  1061                 ((TypeArray at:(nextChar asciiValue)) == #special) ifTrue:[
  1074                 ((TypeArray at:(nextChar asciiValue)) == #special) ifTrue:[
  1062                     source next.
  1075                     source next.
  1063                     string := string copyWith:nextChar
  1076                     string := string copyWith:nextChar
  1064                 ]
  1077                 ]
  1065             ].
  1078             ].
       
  1079             self markSymbolFrom:tokenPosition to:(source position-1).
  1066             tokenValue := token := string asSymbol.
  1080             tokenValue := token := string asSymbol.
  1067             tokenType := #Symbol.
  1081             tokenType := #Symbol.
  1068             ^ tokenType
  1082             ^ tokenType
  1069         ]
  1083         ]
  1070     ].
  1084     ].
  1077 "
  1091 "
  1078     self syntaxError:'unexpected end-of-input in Symbol'
  1092     self syntaxError:'unexpected end-of-input in Symbol'
  1079             position:tokenPosition to:(tokenPosition + 1).
  1093             position:tokenPosition to:(tokenPosition + 1).
  1080     ^ #Error
  1094     ^ #Error
  1081 "
  1095 "
  1082 
  1096 .
  1083     "Modified: 14.10.1997 / 17:14:56 / cg"
  1097 
       
  1098     "Modified: / 1.4.1998 / 13:02:45 / cg"
  1084 !
  1099 !
  1085 
  1100 
  1086 nextId
  1101 nextId
  1087     |nextChar string oldString 
  1102     |nextChar string oldString 
  1088      index "{ Class: SmallInteger }"
  1103      index "{ Class: SmallInteger }"
  1293         ].
  1308         ].
  1294         tokenType := #Float
  1309         tokenType := #Float
  1295     ] ifFalse:[
  1310     ] ifFalse:[
  1296         tokenType := #Integer
  1311         tokenType := #Integer
  1297     ].
  1312     ].
       
  1313 "/    self markConstantFrom:tokenPosition to:(source position - 1).
  1298     ^ tokenType
  1314     ^ tokenType
  1299 
  1315 
  1300     "Modified: / 5.3.1998 / 02:54:36 / cg"
  1316     "Modified: / 1.4.1998 / 13:06:28 / cg"
  1301 !
  1317 !
  1302 
  1318 
  1303 nextPrimitive
  1319 nextPrimitive
  1304     |nextChar inPrimitive string 
  1320     |nextChar inPrimitive string 
  1305      index "{ Class: SmallInteger }"
  1321      index "{ Class: SmallInteger }"
  1698 ! !
  1714 ! !
  1699 
  1715 
  1700 !Scanner class methodsFor:'documentation'!
  1716 !Scanner class methodsFor:'documentation'!
  1701 
  1717 
  1702 version
  1718 version
  1703     ^ '$Header: /cvs/stx/stx/libcomp/Scanner.st,v 1.78 1998-04-01 09:19:46 cg Exp $'
  1719     ^ '$Header: /cvs/stx/stx/libcomp/Scanner.st,v 1.79 1998-04-01 11:11:59 cg Exp $'
  1704 ! !
  1720 ! !
  1705 Scanner initialize!
  1721 Scanner initialize!