diff options
| author | Stefan Eßer <se@FreeBSD.org> | 2023-01-28 20:02:27 +0000 |
|---|---|---|
| committer | Stefan Eßer <se@FreeBSD.org> | 2023-01-28 20:02:27 +0000 |
| commit | e7017237c9d842b4cebdcfb13526cd71a2b2836a (patch) | |
| tree | 9b947d28ee94ab6b413bebb96a7d040873038c0d /include/lex.h | |
| parent | 0b671e8cf134e605567a6b8091958c1f1dfc5140 (diff) | |
Diffstat (limited to 'include/lex.h')
| -rw-r--r-- | include/lex.h | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/include/lex.h b/include/lex.h index 160c0f114855..54d704f8b447 100644 --- a/include/lex.h +++ b/include/lex.h @@ -3,7 +3,7 @@ * * SPDX-License-Identifier: BSD-2-Clause * - * Copyright (c) 2018-2021 Gavin D. Howard and contributors. + * Copyright (c) 2018-2023 Gavin D. Howard and contributors. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -43,10 +43,30 @@ #include <vector.h> #include <lang.h> -// Two convencience macros for throwing errors in lex code. They take care of -// plumbing like passing in the current line the lexer is on. +/** + * A convenience macro for throwing errors in lex code. This takes care of + * plumbing like passing in the current line the lexer is on. + * @param l The lexer. + * @param e The error. + */ +#ifndef NDEBUG +#define bc_lex_err(l, e) (bc_vm_handleError((e), __FILE__, __LINE__, (l)->line)) +#else // NDEBUG #define bc_lex_err(l, e) (bc_vm_handleError((e), (l)->line)) +#endif // NDEBUG + +/** + * A convenience macro for throwing errors in lex code. This takes care of + * plumbing like passing in the current line the lexer is on. + * @param l The lexer. + * @param e The error. + */ +#ifndef NDEBUG +#define bc_lex_verr(l, e, ...) \ + (bc_vm_handleError((e), __FILE__, __LINE__, (l)->line, __VA_ARGS__)) +#else // NDEBUG #define bc_lex_verr(l, e, ...) (bc_vm_handleError((e), (l)->line, __VA_ARGS__)) +#endif // NDEBUG // BC_LEX_NEG_CHAR returns the char that corresponds to negative for the // current calculator. |
