projects
/
m6w6
/
ext-psi
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
|
github
raw
|
inline
| side by side
flush
[m6w6/ext-psi]
/
idl
/
main.c
diff --git
a/idl/main.c
b/idl/main.c
index 6732b7dbac8b1a2b46b6e5f0861a35d1243b54cd..b4eb459004a3974f731f49704fa30647d17f1e3c 100644
(file)
--- a/
idl/main.c
+++ b/
idl/main.c
@@
-1,48
+1,40
@@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include "lexer.h"
-#include "parser.h"
-
-static volatile int TRACE;
-
-static void loop(PSI_Lexer *L, void *P)
-{
- token_t t;
- PSI_Token *T = NULL;
- if (TRACE) {
- PSI_ParserTrace(stdout, "> ");
- }
+#include "parser.h"
+#include "validator.h"
- while (-1 != (t = PSI_LexerScan(L))) {
- T = PSI_TokenAlloc(L, t);
-
- if (TRACE) {
- printf("# Token: <%s>(%d)\n", T->text, t);
- }
-
- PSI_Parser(P, t, T, L);
- }
- PSI_Parser(P, 0, T, L);
-}
+static int TRACE;
int main(int argc, char *argv[])
{
int main(int argc, char *argv[])
{
- PSI_
Lexer L
;
-
void *P = PSI_ParserAlloc(malloc)
;
+ PSI_
Parser P
;
+
PSI_Validator V
;
TRACE = !!getenv("TRACE");
TRACE = !!getenv("TRACE");
- if (!PSI_
LexerInit(&L
, argv[1])) {
- perror("Faile
d to init lex
er");
+ if (!PSI_
ParserInit(&P
, argv[1])) {
+ perror("Faile
r to init pars
er");
return 1;
}
return 1;
}
- loop(&L, P);
+ while (-1 != PSI_ParserScan(&P)) {
+ PSI_ParserParse(&P, PSI_TokenAlloc(&P));
+ };
+ PSI_ParserParse(&P, NULL);
+
+ if (!PSI_ValidatorInit(&V, &P)) {
+ perror("Failed to init validator");
+ return 2;
+ }
+
+ PSI_ParserDtor(&P);
- PSI_ParserFree(P, free);
- PSI_LexerDtor(&L);
+ if (PSI_ValidatorValidate(&V)) {
+ printf("Whoa! VALID.\n");
+ }
+ PSI_ValidatorDtor(&V);
return 0;
}
return 0;
}