Changeset 4504
- Timestamp:
- 06/30/08 02:55:00 (5 years ago)
- Location:
- developers/werner/greg
- Files:
-
- 4 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
developers/werner/greg/Makefile
r4502 r4504 6 6 LDLIBS=-lfl 7 7 8 OBJS=greg.o lex.yy.o y.tab.o cpp.o 8 OBJS=greg.o lex.yy.o y.tab.o cpp.o id.o 9 9 10 10 .PHONY: all dep depend clean spotless test tests -
developers/werner/greg/README
r4502 r4504 15 15 ------------ 16 16 17 - output format should be easier to read18 17 - value names in pcf50633.greg are often unsuitable for identifier generation 19 18 (should align them properly with what we use in u-boot and kernel) 20 19 - "pretty-print" is hard to read 21 20 - unique() should use rb-trees 22 - greg.c should use unique(), to accelerate lookups23 21 24 22 -
developers/werner/greg/greg.c
r4502 r4504 15 15 #include <stdlib.h> 16 16 #include <stdio.h> 17 #include <string.h>18 17 19 18 #include "reg.h" 20 19 #include "cpp.h" 20 #include "id.h" 21 21 #include "greg.h" 22 22 … … 82 82 const struct field *field; 83 83 84 id = unique(id); 84 85 for (reg = regs; reg; reg = reg->next) 85 if ( !strcmp(reg->id, id))86 if (reg->id == id) 86 87 break; 87 88 if (!reg) { -
developers/werner/greg/lang.l
r4502 r4504 22 22 23 23 #include "greg.h" 24 #include "id.h" 24 25 25 26 … … 27 28 static int col0 = 1; /* token starts in the first column */ 28 29 29 30 static char *unique(const char *s)31 {32 static struct node {33 char *s;34 struct node *left, *right;35 } *root = NULL;36 struct node **n = &root;37 int cmp;38 39 while (*n) {40 cmp = strcmp((*n)->s, s);41 if (!cmp)42 return (*n)->s;43 n = cmp < 0 ? &(*n)->left : &(*n)->right;44 }45 *n = malloc(sizeof(struct node));46 if (!*n) {47 perror("malloc");48 exit(1);49 }50 (*n)->s = strdup(s);51 if (!(*n)->s) {52 perror("strdup");53 exit(1);54 }55 (*n)->left = (*n)->right = NULL;56 return (*n)->s;57 }58 59 30 %} 60 31 32 61 33 %% 34 62 35 63 36 "%"[0-9]+ { yylval.num = strtoul(yytext+1, NULL, 10);
Note: See TracChangeset
for help on using the changeset viewer.
