SciLex
A header-only C++20 lexer built on REAL
Loading...
Searching...
No Matches
Public Member Functions | List of all members
scilex::grammar_error Class Reference

Thrown for a malformed .lex grammar: where (origin, 1-based line, and 1-based byte column in the line when the cause has one) and why. More...

#include <grammar.hpp>

Inheritance diagram for scilex::grammar_error:
[legend]
Collaboration diagram for scilex::grammar_error:
[legend]

Public Member Functions

 grammar_error (const std::string &origin, std::size_t line, std::size_t column, const std::string &cause)
 Builds the error.
 
std::size_t line () const noexcept
 The 1-based line of the offending rule (0 for a grammar-wide error such as no rules).
 
std::size_t column () const noexcept
 The 1-based byte column in the line, or 0 when the cause has none.
 
const std::string & cause () const noexcept
 What is wrong, without the location.
 

Detailed Description

Thrown for a malformed .lex grammar: where (origin, 1-based line, and 1-based byte column in the line when the cause has one) and why.

what() reads origin:line[:column]: cause, the form compilers and editors recognize, or origin: cause for an error with no line (an unreadable file, a grammar with no rules).

Constructor & Destructor Documentation

◆ grammar_error()

scilex::grammar_error::grammar_error ( const std::string &  origin,
std::size_t  line,
std::size_t  column,
const std::string &  cause 
)
inline

Builds the error.

Parameters
[in]originWhere the grammar came from (a path, or a label such as <string>).
[in]lineThe 1-based line of the offending rule.
[in]columnThe 1-based byte column in that line, or 0 when the cause has none.
[in]causeWhat is wrong, without the location.

Member Function Documentation

◆ cause()

const std::string & scilex::grammar_error::cause ( ) const
inlinenoexcept

What is wrong, without the location.

Returns
The cause.

◆ column()

std::size_t scilex::grammar_error::column ( ) const
inlinenoexcept

The 1-based byte column in the line, or 0 when the cause has none.

Returns
The column.

◆ line()

std::size_t scilex::grammar_error::line ( ) const
inlinenoexcept

The 1-based line of the offending rule (0 for a grammar-wide error such as no rules).

Returns
The line.

The documentation for this class was generated from the following file: