#include <VRegExpr.hpp>
Public Methods | |
| void * | operator new (size_t size) |
| void | operator delete (void *ptr) |
| VRegExpr (TLabelID mylabelid) | |
| VRegExpr (int mytype, VRegExpr *child1=NULL, VRegExpr *child2=NULL) | |
| void | PrintLabelList () |
| void | Print () |
| FSM * | CreateNonDetFSM () |
| FSM * | CreateFSM () |
Static Public Methods | |
| TLabelID | ParseLabel (char **str, char *endptr) |
| VRegExpr * | ParseVRegExpr (char *&str, char *endptr) |
|
|
Definition at line 51 of file VRegExpr.hpp. Referenced by ParseVRegExpr().
00052 {
00053 type=VP_ITEMTYPE_LABEL;
00054 labelid=mylabelid;
00055 }
|
|
||||||||||||||||
|
Definition at line 57 of file VRegExpr.hpp. 00058 {
00059 type=mytype;
00060 children.child1=child1;
00061 children.child2=child2;
00062 }
|
|
|
Definition at line 482 of file VRegExpr.cpp. 00483 {
00484 FSM *fsm;
00485
00486 fsmtmpmem=&tmpmem;
00487 fsmmem=&tmpmem;
00488
00489 fsm=CreateNonDetFSM();
00490
00491 // fsm->Print();
00492
00493 // Let's make the FSM deterministic
00494 fsm=fsm->MakeDeterministic();
00495
00496 // fsm->Print();
00497
00498 // Now, we store the FSM in the main memory
00499 fsmmem=&mainmem;
00500 mainmem.WordAlign();
00501
00502 // Let's minimize
00503 fsm=fsm->Minimize();
00504
00505 // fsm->Print();
00506
00507 return fsm;
00508 }
|
|
|
Definition at line 55 of file VRegExpr.cpp. Referenced by CreateFSM().
00056 {
00057 FSM *fsm;
00058 FSMState *startstate,*finalstate;
00059
00060 // We create the finite state automaton
00061 fsm=new(fsmtmpmem) FSM();
00062
00063 startstate=fsm->CreateState();
00064 finalstate=fsm->CreateState(1);
00065
00066 fsm->SetStartState(startstate);
00067
00068 CreateFSMEdges(fsm,startstate,finalstate);
00069
00070 return fsm;
00071 }
|
|
||||||||||||
|
Definition at line 208 of file VRegExpr.cpp. Referenced by ParseVRegExpr().
00211 {
00212 char isattrib=0;
00213
00214 if(**str=='<')
00215 isattrib=0;
00216 else
00217 {
00218 if(**str=='@')
00219 isattrib=1;
00220 }
00221 (*str)++;
00222
00223 char *saveptr=*str;
00224
00225 while(*str<endptr)
00226 {
00227 if(((isattrib==0)&&(**str=='>'))||
00228 ((isattrib==1)&&(**str=='@')))
00229 {
00230 (*str)++;
00231 return globallabeldict.GetLabelOrAttrib(saveptr,*str-saveptr-1,isattrib);
00232 }
00233 (*str)++;
00234 }
00235
00236 Error("Could not find ending '>' in '");
00237 ErrorCont(saveptr,10); // !!!
00238 Exit();
00239 return 0;
00240 }
|
|
||||||||||||
|
Definition at line 376 of file VRegExpr.cpp. 00377 {
00378 char reachedend=false;
00379 RegExprStackItem *stack=NULL;
00380
00381 vregexprerrstr=NULL;
00382 vregexprerrptr=NULL;
00383
00384 do
00385 {
00386 switch(*str)
00387 {
00388 case '|': HandleBinOp(&stack,STACKITEM_ALT);
00389 str++;
00390 break;
00391 case '&': HandleBinOp(&stack,STACKITEM_AND);
00392 str++;
00393 break;
00394 case '-': HandleBinOp(&stack,STACKITEM_MINUS);
00395 str++;
00396 break;
00397 case '<':
00398 case '@':{
00399 TLabelID labelid=ParseLabel(&str,endptr);
00400 VRegExpr *regexpr=new VRegExpr(labelid);
00401 HandleRegExpr(&stack,regexpr);
00402 break;
00403 }
00404
00405 case '*': HandleUnaryOp(&stack,VP_ITEMTYPE_STAR,str);
00406 str++;
00407 break;
00408
00409 case '+': HandleUnaryOp(&stack,VP_ITEMTYPE_PLUS,str);
00410 str++;
00411 break;
00412
00413 case '?': HandleUnaryOp(&stack,VP_ITEMTYPE_OPT,str);
00414 str++;
00415 break;
00416
00417 case '~': HandleUnaryOp(&stack,VP_ITEMTYPE_NOT,str);
00418 str++;
00419 break;
00420
00421 case '(': if(str[1]==')')
00422 {
00423 VRegExpr *regexpr=new VRegExpr(VP_ITEMTYPE_EMPTY);
00424 HandleRegExpr(&stack,regexpr);
00425 str+=2;
00426 }
00427 else
00428 {
00429 HandleOpenParenc(&stack);
00430 str++;
00431 }
00432 break;
00433
00434 case ')': HandleCloseParenc(&stack,str);
00435 str++;
00436 break;
00437
00438 case '_':{ VRegExpr *regexpr=new VRegExpr(VP_ITEMTYPE_DONTCARE);
00439 HandleRegExpr(&stack,regexpr);
00440 str++;
00441 break;
00442 }
00443
00444 case '#':{ VRegExpr *regexpr=new VRegExpr(VP_ITEMTYPE_POUND);
00445 HandleRegExpr(&stack,regexpr);
00446 str++;
00447 break;
00448 }
00449 default: reachedend=1;
00450 break;
00451 }
00452 if(reachedend==1)
00453 break;
00454 }
00455 while(str<endptr);
00456
00457 if(stack==NULL)
00458 {
00459 Error("Invalid path expression");
00460 Exit();
00461 }
00462
00463 ReduceAll(&stack);
00464
00465 if(stack->prev!=NULL)
00466 {
00467 // stackptr->prev is a open parenthesis !
00468
00469 Error("Closing parenthesis expected");
00470 Exit();
00471
00472 vregexprerrstr="Closing parenthesis expected";
00473 vregexprerrptr=str;
00474 return NULL;
00475 }
00476 return stack->regexpr;
00477 }
|
|
|
Definition at line 15 of file VRegExpr.cpp. 00016 {
00017 printf("{");
00018 switch(type)
00019 {
00020 case VP_ITEMTYPE_LABEL: globallabeldict.PrintLabel(labelid);break;
00021 case VP_ITEMTYPE_DONTCARE: printf("_");break;
00022 case VP_ITEMTYPE_POUND: printf("#");break;
00023 case VP_ITEMTYPE_STAR: children.child1->Print();printf("*");break;
00024 case VP_ITEMTYPE_PLUS: children.child1->Print();printf("+");break;
00025 case VP_ITEMTYPE_OPT: children.child1->Print();printf("?");break;
00026 case VP_ITEMTYPE_NOT: children.child1->Print();printf("~");break;
00027 case VP_ITEMTYPE_EMPTY: printf("()");;
00028 case VP_ITEMTYPE_GROUP: printf("(");children.child1->Print();printf(")");break;
00029 case VP_ITEMTYPE_MINUS: children.child1->Print();
00030 printf("-");
00031 children.child2->Print();
00032 break;
00033
00034 case VP_ITEMTYPE_SEQ: children.child1->Print();
00035 printf(",");
00036 children.child2->Print();
00037 break;
00038
00039 case VP_ITEMTYPE_ALT: children.child1->Print();
00040 printf("|");
00041 children.child2->Print();
00042 break;
00043
00044 case VP_ITEMTYPE_AND: children.child1->Print();
00045 printf("&");
00046 children.child2->Print();
00047 break;
00048 }
00049 printf("}");
00050 }
|
|
|
|
|
|
Definition at line 49 of file VRegExpr.hpp. 00049 {}
|
|
|
Definition at line 48 of file VRegExpr.hpp. 00048 { return vregexprmem->GetByteBlock(size); }
|
1.2.11.1 written by Dimitri van Heesch,
© 1997-2001