now macros keep track of representation
[pspp] / src / language / lexer / macro.h
index ba0f1fe735df4f36a8f989b6d6b94443ec6e0c02..61cfbc0937087636db99782ab432eeef5f146841 100644 (file)
 
 struct macro_expander;
 
+struct macro_token
+  {
+    struct token token;
+    struct substring representation;
+  };
+
+void macro_token_copy (struct macro_token *, const struct macro_token *);
+void macro_token_uninit (struct macro_token *);
+
+struct macro_tokens
+  {
+    struct macro_token *mts;
+    size_t n;
+    size_t allocated;
+  };
+
+void macro_tokens_copy (struct macro_tokens *, const struct macro_tokens *);
+void macro_tokens_uninit (struct macro_tokens *);
+void macro_tokens_add (struct macro_tokens *, const struct macro_token *);
+
+void macro_tokens_print (const struct macro_tokens *, FILE *);
+
 struct macro_param
   {
     bool positional;            /* Is this a positional parameter? */
     char *name;                 /* "!1" or "!name". */
-    struct tokens def;          /* Default expansion. */
+    struct macro_tokens def;    /* Default expansion. */
     bool expand_arg;            /* Macro-expand the argument? */
 
     enum
@@ -57,8 +79,7 @@ struct macro
     struct macro_param *params;
     size_t n_params;
 
-    struct substring body;
-    struct tokens body_tokens;
+    struct macro_tokens body;
   };
 
 void macro_destroy (struct macro *);
@@ -87,8 +108,8 @@ int macro_expander_create (const struct macro_set *,
                            struct macro_expander **);
 void macro_expander_destroy (struct macro_expander *);
 
-int macro_expander_add (struct macro_expander *, const struct token *);
+int macro_expander_add (struct macro_expander *, const struct macro_token *);
 
-void macro_expander_get_expansion (struct macro_expander *, struct tokens *);
+void macro_expander_get_expansion (struct macro_expander *, struct macro_tokens *);
 
 #endif /* macro.h */