summaryrefslogtreecommitdiff
path: root/as/as.y
diff options
context:
space:
mode:
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
+;