Goldie: Exception

Goldie
Parsing System (v0.8)
Goldie Home (v0.8)
Getting Started

- Requirements
- Download / Install
- Never Used a Parsing Tool?
- Goldie Overview
- Beginner's Tutorial
- Grammar Definition Language
- Contact / Support
  - Message Board
  - Issue Tracking

Goldie's Tools

- DumpCGT
- GenDocs
  - Template Format
- GRMC: Grammar Compiler
- JsonViewer
  - Parse Tree Mode
- Parse
- StaticLang
- Other Tools

GoldieLib Overview

- Static And Dynamic Styles
- Ambiguous Symbols

GoldieLib Reference

- Base
- Exception
- class Language
- class Lexer
- class Parser
- struct Symbol
- class Token
- Ver

GoldieLib Sample Apps

- Calculator Static
- Calculator Dynamic
- Sample Generic Parse

CGT File Format
FAQ
Change Log
If You Use Git Master
Future Work
Developers

- Scripts for Developers
- Library Source and StaticLang

Goldie Home (v0.8) -> GoldieLib Reference -> Exception

# Exception

- struct LexError
- class ParseException
  - class LexException : ParseException
    - class InvalidUtfSequence : LexException
  - class UnexpectedTokenException: ParseException
  - class UnexpectedEofException : ParseException
  - class InternalException : ParseException
- class LanguageLoadException: std.stdio.StdioException
  - class LanguageNotFoundException: LanguageLoadException
- class IllegalArgumentException

This includes functionality for when a parsed source contains errors.

module goldie.exception

struct LexError

This isn't actually a thrown exception. It's just used to represent a single lexing error.

string file
ptrdiff_t line
ptrdiff_t pos
Filename, line number, and "column number" of the error. Note Goldie's conventions regarding line and column numbers.
string content
The actual piece of source that failed to lex.
readonly @property string printableContent
Like content, but with non-printable characters removed.
string toString()
Ready-to-display string representation in the following format:
{file}({line}:{pos}): Syntax Error: '{printableContent}'

module goldie.exception

class ParseException : Exception

Thrown upon any lexing or parsing error.

Parser parser
Lexer lexer

The lexer and parser used when the error occurred. These can be inspected to obtain more information about the error.

Under certain circumstances, either or both of these may be null, so make sure to check for null before using.

string msg
Ready-to-display string representation of the error, including filename (if available) and line and column numbers.
this(string msg)
this(Parser parser, string msg)
Constructors.

module goldie.exception

class LexException : ParseException

Thrown upon any lexing error.

this(Lexer lexer)
Constructor.

module goldie.exception

class InvalidUtfSequence : LexException

Thrown when the lexer comes across a byte sequence that is invalid Unicode. This may occur if the source contains invalid UTF-8, or if a binary file is parsed by accident.

this(Lexer lexer)
Constructor.

module goldie.exception

class UnexpectedTokenException : ParseException

Thrown when parsing finds a type of token in a place where the grammar doesn't allow it. For example, in a C-like language, the if in: var1 + if + var2.

this(Parser parser)
Constructor.

module goldie.exception

class UnexpectedEofException : ParseException

Thrown when parsing reaches the end of the source in a place where the grammar expects more tokens. For example, in a C-like language, a source consisting entirely of: void main() {.

this(Parser parser=null)
Constructor.

module goldie.exception

class InternalException : ParseException

Thrown when an internal error is detected within Goldie.

If you get one of these exceptions (the "msg" string will say something along the lines of "Internal Goldie Error:..."), please file a bug report.

module goldie.exception

class LanguageLoadException : std.stdio.StdioException

Thrown when a problem occurs loading a CGT language file.

StdioException is part of D's standard library.

this(string msg="", string lang="", Exception next=null)
Constructor.

module goldie.exception

class LanguageNotFoundException : LanguageLoadException

Thrown when Goldie tries to load a CGT language file, but cannot find the file.

this(string lang, Exception next=null)
Constructor.

module goldie.exception

class IllegalArgumentException : Exception

Thrown when an invalid argument is passed to a Goldie function.

this(string msg)
Constructor.