Squeak Class Documentation category index | class index  
 
Scanner
  category: System-Compiler
  superclass: Object
  subclasses: Parser

I scan a string or text, picking out Smalltalk syntactic tokens. I look one character ahead. I put each token found into the instance variable, token, and its type (a Symbol) into the variable, tokenType. At the end of the input stream, I pretend to see an endless sequence of special characters called doits.

instance methods
  error handling
  notify:
offEnd:

  expression types
  advance
checkpoint
nextLiteral
revertToCheckpoint:
scanLitVec
scanLitWord
scanStringStruct
scanToken
step

  initialize-release
  initScanner
scan:

  multi-character scans
  xBinary
xColon
xDelimiter
xDigit
xDollar
xDoubleQuote
xLetter
xLitQuote
xSingleQuote

  public access
  scanFieldNames:
scanMessageParts:
scanStringStruct:
scanTokens:

class methods
  class initialization
  initialize

  instance creation
  new

  testing
  isLiteralSymbol:

instance methods
  error handling top  
 

notify:

Refer to the comment in Object|notify:.


 

offEnd:

Parser overrides this


  expression types top  
 

advance


 

checkpoint

Return a copy of all changeable state. See revertToCheckpoint:


 

nextLiteral

Same as advance, but -4 comes back as a number instead of two tokens


 

revertToCheckpoint:

Revert to the state when checkpoint was made.


 

scanLitVec


 

scanLitWord

Accumulate keywords and asSymbol the result.


 

scanStringStruct


 

scanToken


 

step


  initialize-release top  
 

initScanner


 

scan:

Bind the input stream, fill the character buffers and first token buffer.


  multi-character scans top  
 

xBinary


 

xColon

Allow := for assignment by converting to #_


 

xDelimiter

Ignore blanks, etc.


 

xDigit

Form a number.


 

xDollar

Form a Character literal.


 

xDoubleQuote

Collect a comment.


 

xLetter

Form a word or keyword.


 

xLitQuote

Symbols and vectors: #(1 (4 5) 2 3) #ifTrue:ifFalse: #'abc'.


 

xSingleQuote

String.


  public access top  
 

scanFieldNames:

Answer an Array of Strings that are the identifiers in the input string,
stringOrArray. If passed an Array, just answer with that Array, i.e.,
assume it has already been scanned.


 

scanMessageParts:

Return an array of the form (comment keyword comment arg comment keyword comment arg comment) for the message pattern of this method. Courtesy of Ted Kaehler, June 1999


 

scanStringStruct:

The input is a string whose elements are identifiers and parenthesized
groups of identifiers. Answer an array reflecting that structure, representing
each identifier by an uninterned string.


 

scanTokens:

Answer an Array that has been tokenized as though the input text,
textOrString, had appeared between the array delimitors #( and ) in a
Smalltalk literal expression.


class methods
  class initialization top  
 

initialize

Object initialize


  instance creation top  
 

new

Answer a new instance of the receiver (which is a class) with no indexable variables. Fail if the class is indexable.


  testing top  
 

isLiteralSymbol:

Test whether a symbol can be stored as # followed by its characters.
Symbols created internally with asSymbol may not have this property,
e.g. '3' asSymbol.