Common Lisp Package: COM.INFORMATIMAGO.COMMON-LISP.PARSER.SCANNER

An abstract scanner class. A method to the SCAN-NEXT-TOKEN generic function needs to be provided. License: AGPL3 Copyright Pascal J. Bourguignon 2004 - 2012 This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/>

README:

FUNCTION

Public

Undocumented

CHAR-NAME-SUPPORTED-P (NAME)

GENERIC-FUNCTION

Public

GETCHAR (PEEK-STREAM)

RETURN: The next character in the PEEK-STREAM, advancing.

NEXTCHAR (PEEK-STREAM &OPTIONAL PEEK-TYPE)

DO: Just like CL:PEEK-CHAR. If peek-type is not supplied or NIL, peek-char returns the next character to be read from input-stream, without actually removing it from input-stream. The next time input is done from input-stream, the character will still be there. If peek-type is T, then peek-char skips over whitespace[2] characters, but not comments, and then performs the peeking operation on the next character. The last character examined, the one that starts an object, is not removed from input-stream. If peek-type is a CHARACTER, then peek-char skips over input characters until a character that is char= to that character is found; that character is left in input-stream. RETURN: The same character that will be returned by the next (getchar self). NOTE: There's no conforming way to determine whether a character has the whitespace[2] syntax in the current *readtable*. Therefore we use instead the PEEK-STREAM-SPACES method to get the list of spaces.

READLINE (PEEK-STREAM)

RETURN: A string containing the read line.

SCAN-NEXT-TOKEN (SCANNER &OPTIONAL PARSER-DATA)

DO: Scans a new token and store it into (scanner-current-token scanner) PARSER-DATA: Some parsers give information to the scanner. RETURN: (scanner-current-token scanner).

SCANNER-ERROR-COLUMN (ERROR)

The column on which the scanner error was detected.

SCANNER-ERROR-CURRENT-TOKEN (ERROR)

The scanner token where error was detected.

SCANNER-ERROR-FORMAT-ARGUMENTS (ERROR)

The error message format control arguments.

SCANNER-ERROR-FORMAT-CONTROL (ERROR)

The error message format control string.

SCANNER-ERROR-INVALID-CHARACTER (ERROR)

The invalid character that made the scanner error.

SCANNER-ERROR-LINE (ERROR)

The line on which the scanner error was detected.

SCANNER-ERROR-SCANNER (ERROR)

The scanner that detected the error.

SCANNER-ERROR-STATE (ERROR)

The scanner state when error was detected.

SKIP-SPACES (SCANNER)

DO: Skips over the spaces in the input stream. Updates line and column slots. RETURN: line; column

UNGETCHAR (PEEK-STREAM CH)

DO: Unread the character CH from the PEEK-STREAM.

Undocumented

SETFSCANNER-SOURCE (NEW-SOURCE SCANNER)

Private

INCREMENT-COLUMN-TO-NEXT-TAB-STOP (SCANNER)

DO: Increments the scanner-column to the next tab-stop. RETURN: SCANNER

SLOT-ACCESSOR

Public

SCANNER-COLUMN (SCANNER)

The The number of the current column.

SETFSCANNER-COLUMN (NEW-VALUE OBJECT)

Set the The number of the current column.

SCANNER-CURRENT-TOKEN (SCANNER)

The The last token read.

SETFSCANNER-CURRENT-TOKEN (NEW-VALUE OBJECT)

Set the The last token read.

SCANNER-LINE (SCANNER)

The The number of the current line.

SETFSCANNER-LINE (NEW-VALUE OBJECT)

Set the The number of the current line.

SCANNER-SOURCE (SCANNER)

The The source can be a PEEK-STREAM, a STREAM, or a STRING.

SCANNER-SPACES (SCANNER)

The A string containing the characters considered space by SKIP-SPACES.

SETFSCANNER-SPACES (NEW-VALUE OBJECT)

Set the A string containing the characters considered space by SKIP-SPACES.

SCANNER-STATE (SCANNER)

The The state of the scanner.

SETFSCANNER-STATE (NEW-VALUE OBJECT)

Set the The state of the scanner.

SCANNER-TAB-WIDTH (SCANNER)

The TAB aligns to column number modulo TAB-WIDTH.

SETFSCANNER-TAB-WIDTH (NEW-VALUE OBJECT)

Set the TAB aligns to column number modulo TAB-WIDTH.

TOKEN-COLUMN (TOKEN)

The Returns the column of the first character of the token.

SETFTOKEN-COLUMN (NEW-VALUE OBJECT)

Set the Returns the column of the first character of the token.

TOKEN-KIND (TOKEN)

The Returns the kind of the token.

SETFTOKEN-KIND (NEW-VALUE OBJECT)

Set the Returns the kind of the token.

TOKEN-LINE (TOKEN)

The Returns the line where the token was found.

SETFTOKEN-LINE (NEW-VALUE OBJECT)

Set the Returns the line where the token was found.

TOKEN-TEXT (TOKEN)

The Returns the literal text the token.

SETFTOKEN-TEXT (NEW-VALUE OBJECT)

Set the Returns the literal text the token.

Private

SCANNER-STREAM (OBJECT)

The source is wrapped into this PEEK-STREAM. Subclasses may use scanner-stream to read from the source.

VARIABLE

Private

Undocumented

*SPACES*

CLASS

Public

SCANNER

An abstract scanner.

TOKEN

A syntactic element.

CONDITION

Public

SCANNER-ERROR

A scanner error.

SCANNER-ERROR-INVALID-CHARACTER (ERROR)

An invalid character scanner error.