private static void TokenOut(int type) throws TokenizerException {
  if (parseExpression) {
    if ((type == Token.BUILTIN) || (type == Token.NUMBER) || (type == Token.STRING)|| (type == Token.IDENT)) {
      if ((type != Token.STRING) && ((IsDelimiter(token) && !((type == Token.IDENT) && (prevToken.equals(".") || prevToken.equals("[") || prevToken.equals(",")))) || (((token.equals(",") && !inQuantifier) || token.equals(")") || token.equals("}")) && (parenDepth == 0)))) {
        if (parenDepth != 0) {
          TokenizingError("Expression with an unmatched (, [, {, or << " + "followed by");
        }
        ;
        if (inQuantifier) {
          TokenizingError("Expression with \\A or \\E" + " but no following `:` followed by");
        }
        ;
        exprEnd=true;
        Delimiter=token;
        DelimiterCol=col;
        DelimiterLine=reader.getLineNumber();
        if (nextChar == '\n') {
          DelimiterLine=DelimiterLine - 1;
        }
        ;
        if (linev.size() > 0) {
          startNewLine();
        }
      }
 else {
        if (type == Token.BUILTIN) {
          Symbol sym=PcalBuiltInSymbols.GetBuiltInSymbol(token);
          if (sym.symbolType == Symbol.LEFT_PAREN) {
            parenDepth=parenDepth + 1;
          }
          ;
          if (sym.symbolType == Symbol.RIGHT_PAREN) {
            parenDepth=parenDepth - 1;
            if (parenDepth < 0) {
              TokenizingError("Extra (unmatching)");
            }
            ;
          }
        }
        ;
        if (type == Token.STRING) {
          prevToken=" ";
        }
 else {
          prevToken=token;
        }
        ;
        if ((token.equals("\\A") || token.equals("\\E")) && (parenDepth == 0)) {
          inQuantifier=true;
        }
        ;
        if (inQuantifier && token.equals(":") && (parenDepth == 0)) {
          inQuantifier=false;
        }
        ;
        if ((!token.equals("")) || (type == Token.STRING)) {
          linev.addElement(new TLAToken(token,col,type,reader.getLineNumber() + getLineCorrection));
        }
        ;
        token="";
      }
    }
 else {
      TokenizingError("Illegal token in an expression");
      ;
    }
  }
 else {
    exprEnd=true;
    Delimiter=token;
    DelimiterCol=col;
    DelimiterLine=reader.getLineNumber();
    if (nextChar == '\n') {
      DelimiterLine=DelimiterLine - 1;
    }
    ;
    token="";
  }
}

private static void TokenOut ( int type ) throws TokenizerException { if ( parseExpression ) { if ( ( type == Token . BUILTIN ) || ( type == Token . NUMBER ) || ( type == Token . STRING ) || ( type == Token . IDENT ) ) { if ( ( type != Token . STRING ) && ( ( IsDelimiter ( token ) && ! ( ( type == Token . IDENT ) && ( prevToken . equals ( "." ) || prevToken . equals ( "[" ) || prevToken . equals ( "," ) ) ) ) || ( ( ( token . equals ( "," ) && ! inQuantifier ) || token . equals ( ")" ) || token . equals ( "}" ) ) && ( parenDepth == 0 ) ) ) ) { if ( parenDepth != 0 ) { TokenizingError ( "Expression with an unmatched (, [, {, or << " + "followed by" ) ; } ; if ( inQuantifier ) { TokenizingError ( "Expression with \\A or \\E" + " but no following `:` followed by" ) ; } ; exprEnd = true ; Delimiter = token ; DelimiterCol = col ; DelimiterLine = reader . getLineNumber ( ) ; if ( nextChar == '\n' ) { DelimiterLine = DelimiterLine - 1 ; } ; if ( linev . size ( ) > 0 ) { startNewLine ( ) ; } } else { if ( type == Token . BUILTIN ) { Symbol sym = PcalBuiltInSymbols . GetBuiltInSymbol ( token ) ; if ( sym . symbolType == Symbol . LEFT_PAREN ) { parenDepth = parenDepth + 1 ; } ; if ( sym . symbolType == Symbol . RIGHT_PAREN ) { parenDepth = parenDepth - 1 ; if ( parenDepth < 0 ) { TokenizingError ( "Extra (unmatching)" ) ; } ; } } ; if ( type == Token . STRING ) { prevToken = " " ; } else { prevToken = token ; } ; if ( ( token . equals ( "\\A" ) || token . equals ( "\\E" ) ) && ( parenDepth == 0 ) ) { inQuantifier = true ; } ; if ( inQuantifier && token . equals ( ":" ) && ( parenDepth == 0 ) ) { inQuantifier = false ; } ; if ( ( ! token . equals ( "" ) ) || ( type == Token . STRING ) ) { linev . addElement ( new TLAToken ( token , col , type , reader . getLineNumber ( ) + getLineCorrection ) ) ; } ; token = "" ; } } else { TokenizingError ( "Illegal token in an expression" ) ; ; } } else { exprEnd = true ; Delimiter = token ; DelimiterCol = col ; DelimiterLine = reader . getLineNumber ( ) ; if ( nextChar == '\n' ) { DelimiterLine = DelimiterLine - 1 ; } ; token = "" ; } }
used by tokenout to remember the previous token for figuring out whether the current token is a record - field name rather than an identifier . this is needed to prevent a + cal reservered word like " end " from screwing up the parsing when it is used as a record - field name . it is initialized in innertokenize and set / reset by tokenout .
