aboutsummaryrefslogtreecommitdiff
path: root/demos/sample-files/arithmetic-skeleton.c
diff options
context:
space:
mode:
Diffstat (limited to 'demos/sample-files/arithmetic-skeleton.c')
-rw-r--r--demos/sample-files/arithmetic-skeleton.c62
1 files changed, 0 insertions, 62 deletions
diff --git a/demos/sample-files/arithmetic-skeleton.c b/demos/sample-files/arithmetic-skeleton.c
deleted file mode 100644
index ef5ec2f..0000000
--- a/demos/sample-files/arithmetic-skeleton.c
+++ /dev/null
@@ -1,62 +0,0 @@
-#include <stdio.h>ae
-#include <stdlib.h>
-
-#include "lr-parser.c"
-#include "bin/generated.c"
-
-#include "parts/toklist.h"
-
-enum symbol {
- PLUS = 0,
- MINUS,
- LPAREN,
- RPAREN,
- N0, N1,
- END_INPUT,
-
- EP, E, T, N,
- SYMBOLS_END,
-};
-
-struct token {
- symbol s;
-};
-
-static inline struct token *char_to_token(char c)
-{
- static struct token t;
-
- switch(c) {
- case '+': t = (struct token){PLUS}; break;
- case '-': t = (struct token){MINUS}; break;
- case '(': t = (struct token){LPAREN}; break;
- case ')': t = (struct token){RPAREN}; break;
- case '0': t = (struct token){N0}; break;
- case '1': t = (struct token){N1}; break;
- case 0 : t = (struct token){END_INPUT}; break;
- default: fprintf(stderr, "ERROR: Unknown character '%c'\n", c); exit(1);
- }
-
- return &t;
-}
-
-static char *input;
-
-symbol token_sym(struct token *t) { return t->s; }
-int token_val(struct token *t) { return 0; }
-struct token *toklist_eat() { return char_to_token(*(input++)); } // unsafe
-struct token *toklist_peek() { return char_to_token(*input); } // unsafe
-
-int main(int argc, char **argv)
-{
- if(argc != 2) {
- fprintf(stderr, "ERROR: Not enough arguments\n");
- return 1;
- }
-
- input = argv[1];
-
- printf("INPUT: '%s'\n", input);
- printf("OUTPUT: %d\n", lr_parser());
- return 0;
-}