summaryrefslogtreecommitdiff
path: root/lexer/symbol.c
diff options
context:
space:
mode:
Diffstat (limited to 'lexer/symbol.c')
-rw-r--r--lexer/symbol.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/lexer/symbol.c b/lexer/symbol.c
new file mode 100644
index 0000000..7a8001f
--- /dev/null
+++ b/lexer/symbol.c
@@ -0,0 +1,42 @@
+/* Name: make_local_label()
+ * Desc: Constructs a local label of the form:
+ * " " + global_name + " " + local_name
+ * Args:
+ * global: Global label name.
+ * global_len: Length of Global label name.
+ * local: Local label name.
+ * local_len: Length of Local label name.
+ * Return value: Returns the constructed local label.
+ */
+
+char make_local_label(char *global, int global_len, char *local, int local_len) {
+ char *name;
+ char *p;
+
+ if (!global_len) {
+ /* Use last defined global. */
+ global = last_global;
+ global_len = strlen(last_global);
+ }
+ name = malloc(local_len+global_len+3);
+ p = name;
+ *p++ = ' ';
+ if (global_len) {
+ memcpy(p, global, global_len);
+ p += global_len;
+ }
+ *p++ = ' ';
+ memcpy(p, local, local_len);
+ p[local_len] = '\0';
+ return name;
+}
+
+/* Name:
+ * Desc:
+ * Args:
+ *
+ *
+ *
+ *
+ * Return value:
+ */