main ordering done

This commit is contained in:
anon 2024-12-06 21:33:57 +01:00
parent a3872d1318
commit 716e6fb8d5
4 changed files with 19 additions and 17 deletions

View File

@ -8,11 +8,6 @@
#define AS_SYMBOL(c) c
#define TOKEN_OFFSET 128 /* XXX */
typedef struct {
int state;
const char * pattern;
} pattern_t;
static inline
void put_header(FILE * f, const int alphabet_size, const int n_states, const int no_match) {
fputs(
@ -94,7 +89,7 @@ int get_max_number_of_states(const pattern_t * patterns) {
return r;
}
void generate(const pattern_t * patterns) {
void generate(const char * filename) {
// Init
int n_states = get_max_number_of_states(patterns);
@ -181,10 +176,3 @@ void generate(const pattern_t * patterns) {
put_table(stdout, (int*)table, prefixes, n_states, alphabet_size);
put_state_table(states, n_states);
}
signed main(void) {
generate(patterns);
return 0;
}

View File

@ -1,7 +1,14 @@
#ifndef JEGER_H
#define JEGER_H
typedef struct {
int state;
const char * pattern;
} pattern_t;
extern pattern_t * patterns;
extern int alphabet_size;
extern void generate(const char * filename);
#endif

View File

@ -5,13 +5,13 @@
maybe it should be reimplemented in pure C when possible.
*/
#include "jeger.h"
#include <map>
#include <vector>
#include <string>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <map>
#include <vector>
#include <string>
using namespace std;
@ -239,12 +239,18 @@ prefix={value} {
%%
int parse(const char * filename) {
int r = 0;
FILE * f = fopen(argv[1], "r");
if (!f) { return 2; }
yyin = f;
return yylex();
r = yylex();
if (r) { return r; }
/* XXX fill globals */
return r;
}
#ifdef SCANNER_MAIN

View File

@ -11,6 +11,7 @@ signed main(const int argc, char * argv[]) {
}
parse(argv[1]);
generate("jeger.yy.c");
return 0;
}