chat
Class Lexer

java.lang.Object
  |
  +--java.io.StreamTokenizer
        |
        +--chat.Lexer

class Lexer
extends java.io.StreamTokenizer

Implementazione del lexer specifico per la seguente grammatica:

scopo ::= nome / chiave @ endpoint
nome ::= ( a |...| z | A |...| Z | 0 |...| 9 | _ | $ ) { a |...| z | A |...| Z | 0 |...| 9 | _ | $ }31
chiave ::= numero { , numero }
endpoint ::= ip : numero { @ ip : numero }
ip ::= numero . numero . numero . numero
numero ::= 0 [ x cifra-hex { cifra-hex } | { cifra } ] | cifra-non-nulla { cifra }
cifra ::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
cifra-non-nulla ::= 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
cifra-hex ::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | a | b | c | d | e | f | A | B | C | D | E | F

Sono riconosciuti i commenti in stile C e C++.

Version:
1.0
Author:
Marco Cimatti

Fields inherited from class java.io.StreamTokenizer
buf, CT_ALPHA, CT_COMMENT, CT_DIGIT, CT_QUOTE, CT_WHITESPACE, ctype, eolIsSignificantP, forceLower, input, LINENO, NEED_CHAR, nval, peekc, pushedBack, reader, SKIP_LF, slashSlashCommentsP, slashStarCommentsP, sval, TT_EOF, TT_EOL, TT_NOTHING, TT_NUMBER, TT_WORD, ttype
 
Constructor Summary
(package private) Lexer(java.io.Reader r)
          Unico costruttore che inizializza il lexer con i caratteri separatori specificati dalla grammatica.
 
Method Summary
 int nextToken()
          Specializzazione di java.io.StreamTokenizer.nextToken() per il corretto parsing dei numeri (naturali in notazione decimale ed esadecimale Java-like, prefissati cioč da 0x).
(package private)  java.lang.String tokenCorrente()
          Funzione che ritorna una rappresentazione testuale del token corrente ultimo estratto dallo stream.
 
Methods inherited from class java.io.StreamTokenizer
commentChar, eolIsSignificant, lineno, lowerCaseMode, ordinaryChar, ordinaryChars, parseNumbers, pushBack, quoteChar, read, resetSyntax, slashSlashComments, slashStarComments, toString, whitespaceChars, wordChars
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 

Constructor Detail

Lexer

Lexer(java.io.Reader r)
Unico costruttore che inizializza il lexer con i caratteri separatori specificati dalla grammatica.
Parameters:
r - il java.io.Reader su cui poggiare questa specializzazione di java.io.StreamTokenizer.
Method Detail

nextToken

public int nextToken()
              throws java.io.IOException
Specializzazione di java.io.StreamTokenizer.nextToken() per il corretto parsing dei numeri (naturali in notazione decimale ed esadecimale Java-like, prefissati cioč da 0x).
Overrides:
nextToken in class java.io.StreamTokenizer
Returns:
Il valore di java.io.StreamTokenizer.ttype, cioč il tipo del token letto.
Throws:
java.io.IOException - se generata da java.io.StreamTokenizer.nextToken().

tokenCorrente

java.lang.String tokenCorrente()
Funzione che ritorna una rappresentazione testuale del token corrente ultimo estratto dallo stream.
Returns:
La versione stringa del token in esame; "" in caso di End Of File.