Browse Source

added class with the array of bit

main
benoit.thomas 4 years ago
parent
commit
ffdf5112bc
1 changed files with 7 additions and 10 deletions
  1. +7
    -10
      parse.leg

+ 7
- 10
parse.leg View File

@ -7,6 +7,7 @@
#include <sys/stat.h>
#include "inputBuffer.c"
#include "class.c"
;
void fatal(char *fmt, ...)
@ -38,7 +39,7 @@ struct Star { enum op type; Node *children[1]; };
struct Plus { enum op type; Node *children[1]; };
struct Or { enum op type; Node *children[2]; };
struct And { enum op type; Node *children[2]; };
struct Class { enum op type; char *stringValue; int len; };
struct Class { enum op type; char *array; };
struct Dot { enum op type; };
struct Exc { enum op type; Node *children[1]; };
struct Et { enum op type; Node *children[1]; };
@ -140,8 +141,7 @@ Node *mkStar(Node *n)
Node *mkClass(char* str)
{
Node *node= new(Class);
node->Class.stringValue= str;
node->Class.len=strlen(str);
node->Class.array= str;
return node;
}
@ -211,7 +211,7 @@ void print(Node *node)
return;
case Class:
printf("Class");
printf("\"%s\"", node->Class.stringValue);
printf("\"%s\"", node->Class.array);
return;
case Dot:
printf("Dot");
@ -317,7 +317,7 @@ id = < [a-zA-z_][a-zA-z_0-9]* > - { $$ = mkId(intern(yytext)) }
string = '"' < [^\"]* > '"' - { $$ = mkString(yytext) }
class = '['-<(!']'string)*> ']' - { $$=mkClass(yytext) }
class = '['-<(!']'string)*> ']' - { $$=mkClass(classify(yytext)) }
dot = '.' - { $$=mkDot() }
@ -367,11 +367,8 @@ int execute(Node *node, InputBuffer *in)
return 1;
}
case Class: {
if (!currentChar(in)) {
return 0;
}
if (strchr(get(node,Class,stringValue), currentChar(in))) {
advance(in, 1);
if (testBit(get(Node,Class,array),currentChar(in))) {
advance(in, 1);
return 1;
}
return 0;

Loading…
Cancel
Save