!LENGTH and !BLANKS work
[pspp] / src / language / lexer / macro.h
index e829f8acee2fd771a4f00b0ae50982c999dfeea6..ba0f1fe735df4f36a8f989b6d6b94443ec6e0c02 100644 (file)
 #include "libpspp/str.h"
 #include "language/lexer/token.h"
 
+struct macro_expander;
+
 struct macro_param
   {
-    char *name;                 /* NULL for a positional parameter. */
+    bool positional;            /* Is this a positional parameter? */
+    char *name;                 /* "!1" or "!name". */
     struct tokens def;          /* Default expansion. */
     bool expand_arg;            /* Macro-expand the argument? */
 
@@ -55,6 +58,7 @@ struct macro
     size_t n_params;
 
     struct substring body;
+    struct tokens body_tokens;
   };
 
 void macro_destroy (struct macro *);
@@ -64,11 +68,23 @@ struct macro_set
     struct hmap macros;
   };
 
+struct macro_set *macro_set_create (void);
+void macro_set_destroy (struct macro_set *);
 const struct macro *macro_set_find (const struct macro_set *,
                                     const char *);
-
-struct macro_expander *macro_expander_create (const struct macro_set *,
-                                              const struct token *);
+void macro_set_add (struct macro_set *, struct macro *);
+
+static inline bool
+macro_set_is_empty (const struct macro_set *set)
+{
+  return hmap_is_empty (&set->macros);
+}
+\f
+/* Macro expansion. */
+
+int macro_expander_create (const struct macro_set *,
+                           const struct token *,
+                           struct macro_expander **);
 void macro_expander_destroy (struct macro_expander *);
 
 int macro_expander_add (struct macro_expander *, const struct token *);