]> code.bitgloo.com Git - clyne/interpreter.git/commitdiff
expose inew_number
authorClyne Sullivan <tullivan99@gmail.com>
Fri, 30 Mar 2018 03:08:34 +0000 (23:08 -0400)
committerClyne Sullivan <tullivan99@gmail.com>
Fri, 30 Mar 2018 03:08:34 +0000 (23:08 -0400)
parser.c
parser.h

index 14031dc90ba251cbcc739dd0a1a178e8511d6328..103b80d2a1e9ca55ba8d268269aa8959eed16d83 100644 (file)
--- a/parser.c
+++ b/parser.c
@@ -402,7 +402,7 @@ variable **iparse(instance *it, const char *s)
                                for (int c = 0; c >= 0; end++) {
                                        if (s[end] == '(')
                                                c++;
-                                       if (c == 0 && last != end && (s[end] == ',' || s[end] == ')')) {
+                                       if (c == 0 && last != end && (s[end] == ',' || s[end] == ')' || s[end] == '\0')) {
                                                argcount++;
                                                char *arg = strnclone(s + last, end - last);
                                                uint32_t parenidx = ooffset;
@@ -418,7 +418,7 @@ variable **iparse(instance *it, const char *s)
                                                ops[parenidx] = (variable *)(OP_MAGIC | count);
                                                last = end + 1;
                                        }
-                                       if (s[end] == ')')
+                                       if (s[end] == ')' || s[end] == '\0')
                                                c--;
                                }
                                if (s[end] != '\0')
index f1ffe70ed5fd980be6d7c66c816150bb9e4653e1..b032bb4f0d08e213bb17d02fa29fe86e01d4330c 100644 (file)
--- a/parser.h
+++ b/parser.h
@@ -78,6 +78,14 @@ int idoline(instance *it, const char *s);
  */
 void inew_cfunc(instance *it, const char *name, func_t func);
 
+/**
+ * Creates a script-accessible float number.
+ * @param it the current instance
+ * @param name the name of the new variable
+ * @param f the variable's initial value
+ */
+void inew_number(instance *it, const char *name, float f);
+
 /**
  * Pops a word from the instance's stack.
  * @param it the current instance