changeset 69:bc9b86683bc3

expr: Add EXCEPTION type
author Lewin Bormann <lbo@spheniscida.de>
date Sun, 25 Aug 2019 16:04:53 +0200
parents d7a3916c0e17
children 1b2bd8c6cc25
files src/CMakeLists.txt src/parse.h src/types.h
diffstat 3 files changed, 13 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/CMakeLists.txt	Sun Aug 25 15:47:05 2019 +0200
+++ b/src/CMakeLists.txt	Sun Aug 25 16:04:53 2019 +0200
@@ -5,6 +5,7 @@
 # Tests
 if (CMAKE_BUILD_TYPE STREQUAL "Debug")
     ADD_COMPILE_OPTIONS(--coverage)
+    LINK_LIBRARIES(gcov)
 endif ()
 
 ADD_LIBRARY(core STATIC
@@ -18,7 +19,7 @@
     parse.c)
 
 if (CMAKE_BUILD_TYPE STREQUAL "Debug")
-    TARGET_LINK_LIBRARIES(core base gcov)
+    TARGET_LINK_LIBRARIES(core base)
 else ()
     TARGET_LINK_LIBRARIES(core base)
 endif ()
--- a/src/parse.h	Sun Aug 25 15:47:05 2019 +0200
+++ b/src/parse.h	Sun Aug 25 16:04:53 2019 +0200
@@ -3,6 +3,7 @@
 
 /**
  * @file parse.h
+ * @brief Parse a program source code stream into a tree of `yexpr_t`.
  * @addtogroup frontend
  * @{
  */
--- a/src/types.h	Sun Aug 25 15:47:05 2019 +0200
+++ b/src/types.h	Sun Aug 25 16:04:53 2019 +0200
@@ -65,13 +65,23 @@
  * Each enum value corresponds to a union field being set.
  */
 typedef enum {
+    /// Undefined type (freshly initialized)
     YEXPR_UNDEF = 0,
+    /// A signed integer. (also boolean: 0 is false, everything else is true)
     YEXPR_NUMBER = 1,
+    /// A string.
     YEXPR_STRING = 2,
+    /// An atom (a word or words that stand for themselves)
     YEXPR_ATOM = 3,
+    /// A list of expressions.
     YEXPR_LIST = 4,
+    /// A reference to a value or function.
     YEXPR_REF = 5,
+    /// A reference to a built-in function.
     YEXPR_BUILTIN = 6,
+    /// An exception described by the `str` field - when returned from a
+    /// function, the interpreter "bubbles up" the call stack.
+    YEXPR_EXCEPTION = 7,
 } YEXPR_TYPE;
 
 /**