Sfoglia il codice sorgente

Update lexer.c

main
Vank143 3 anni fa
committed by GitHub
parent
commit
4b562ff629
Non sono state trovate chiavi note per questa firma nel database ID Chiave GPG: 4AEE18F83AFDEB23
1 ha cambiato i file con 19 aggiunte e 6 eliminazioni
  1. +19
    -6
      lexer.c

+ 19
- 6
lexer.c Vedi File

@ -8,7 +8,8 @@ typedef struct Exploration Exploration;
enum opcode {
STRING,
AND
AND,
STAR
};
struct Exploration
{
@ -78,6 +79,13 @@ Node *mkAnd(Node *node1, Node *node2)
return node;
}
Node *mkStar(Node *child)
{
Node *node= mkNode(STAR);
node->children[0]= child;
return node;
}
int execute(Node *node, Exploration *in)
{
@ -107,6 +115,10 @@ int execute(Node *node, Exploration *in)
return execute(node->children[1], in);
}
}
case STAR: {
//TODO
return 0;
}
}
printf("this cannot happen\n");
abort();
@ -118,21 +130,22 @@ int main(int argc, char **argv)
Exploration *in= mkExploration("aabbcc");
/*Node *program=
mkString("aabbcc");*/
mkString("aabbcc");
Node *program=
mkAnd(mkString("aab"),
mkString("bcc"));
mkString("bcc"));*/
/*Node *program=
Node *program=
mkAnd(mkString("aa"),
mkAnd(mkString("bb"),
mkString("cc"));
mkString("cc")));
Node *program=
/*Node *program=
mkAnd(mkStar(mkString("a")), // "a"*"b"*"c"*
mkAnd(mkStar(mkString("b")),
mkStar(mkString("c")));*/
if (execute(program, in)<=0)
{
printf("no match\n");

Caricamento…
Annulla
Salva