Skip to content

FileSource

class FileSource

Represents a source of characters from a file, with support for lookahead and seeking.

constructor FileSource(Symbol filename)

ParameterDescription
filename

TYPE: Symbol

method void expand_location(Location &location)

Expand a location within the file to include the current location.

If the location is not within the file, it will be left unchanged.

ParameterDescription
location

The location to expand.

TYPE: Location &

method Symbol filename()

Get the name of the file.

ReturnsDescription
Symbol

The name of the file.

method int get()

Get the next character from the file. Returns EOF if the end of the file is reached.

ReturnsDescription
int

The next character from the file, or EOF if the end of the file is reached.

method Location location()

Get the current location in the file.

ReturnsDescription
Location

The current location in the file.

method void reset_to(const Location &new_location)

Reset the current position to a new location.

ParameterDescription
new_location

The new location to reset to.

TYPE: const Location &

ThrowsDescription
Exception

If the new location is not within the file.

method void unget()

Unget the last character read from the file. The next call to get() will return the same character again.

ThrowsDescription
Exception

If at the beginning of the file.