summaryrefslogtreecommitdiff
path: root/as/as.y
diff options
context:
space:
mode:
authorJakob Kaivo <jkk@ung.org>2019-03-13 21:05:34 -0400
committerJakob Kaivo <jkk@ung.org>2019-03-13 21:05:34 -0400
commit39ecba0032be794a1f4d66f61e09e4910270330f (patch)
tree9b68f25a597891afce13825328e837da168dfada /as/as.y
migrate to gitlab
Diffstat (limited to 'as/as.y')
-rw-r--r--as/as.y36
1 files changed, 36 insertions, 0 deletions
diff --git a/as/as.y b/as/as.y
new file mode 100644
index 0000000..ed8714f
--- /dev/null
+++ b/as/as.y
@@ -0,0 +1,36 @@
+%{
+#include <inttypes.h>
+%}
+
+%union {
+ char *s;
+ uintmax_t n;
+};
+
+%token<n> NUMBER
+%token<s> TOKEN
+%token NEWLINE
+
+%%
+
+program
+ : /* empty */
+ | instruction NEWLINE
+;
+
+instruction
+ : bare_instruction
+ | TOKEN ':' bare_instruction
+;
+
+bare_instruction
+ : TOKEN
+ | TOKEN operand
+ | TOKEN operand ',' operand
+ | TOKEN operand ',' operand ',' operand
+;
+
+operand
+ : TOKEN
+ | NUMBER
+;