diff c/regexParser/regexParser.cc @ 144:d8a4922eceae pairPro

remove some errors (not working)
author Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
date Mon, 14 Dec 2015 17:14:33 +0900
parents 32977f5a2ed0
children 50217a0545e8
line wrap: on
line diff
--- a/c/regexParser/regexParser.cc	Fri Dec 11 15:04:58 2015 +0900
+++ b/c/regexParser/regexParser.cc	Mon Dec 14 17:14:33 2015 +0900
@@ -3,7 +3,6 @@
 #include <string.h>
 #include <ctype.h>
 #include "regexParser.h"
-#include "error.h"
 
 static NodePtr charClass(RegexInfoPtr);
 static void token(RegexInfoPtr);
@@ -27,18 +26,6 @@
 }
 
 static
-CharClassPtr createCharClassWord(RegexInfoPtr ri) {
-    CharClassPtr cc = NEW(CharClass);
-    cc->type = 'a';
-    cc->cond.w.word = ri->tokenValue;
-    cc->cond.w.length = ri->ptr - ri->tokenValue;
-    cc->nextState.bitContainer = 0;
-    token(ri);
-
-    return cc;
-}
-
-static
 NodePtr createNode(RegexInfoPtr ri,unsigned char type,CharClassPtr cc, NodePtr left, NodePtr right) {
     NodePtr n = allocateNode();
 
@@ -52,24 +39,18 @@
     return n;
 }
 
+CharClassPtr createCharClassWord(RegexInfoPtr ri) {
+    CharClassPtr cc = NEW(CharClass);
+    cc->type = 'a';
+    cc->cond.w.word = ri->tokenValue;
+    cc->cond.w.length = ri->ptr - ri->tokenValue;
+    cc->nextState.bitContainer = 0;
+    return cc;
+}
+
 CharClassPtr charClassMerge(CharClassPtr cc, unsigned char begin, unsigned char end, CharClassPtr next) {
-    if (src->type == 'a') {
-        if (add->type == 'a') {
-            if (src->cond.w.word[0] > add->cond.w.word[0]) {
-                // add のほうが小さいので小さい順のccをつくる
-                CharClassPtr left = charClassMerge(add->left.src);
-                return createCharClassWord(add->cond->w.word, left, add->right);
-            } else {
-                
-            }
-        } else if (add->type == 'c') {
-            // 
-            if (src->cond.w.word[0] < add->cond.range.begin) {
-
-            } else (src->cond->w.word[0] < add->end) {
-    } else if (src->type == 'c') {
-
-    }
+    CharClassPtr cc1 = NEW(CharClass);
+    return cc1;
 }
 
 // <charClass> ::= '['<literal>'-'<literal>']'
@@ -80,24 +61,24 @@
     cc->type = 'r';
     cc->nextState.bitContainer = 0;
     RangeListPtr rangeList = &cc->cond.range;
-    rangeList->begin = ri->ptr;
-    rangeList->end = ri->ptr;
+    rangeList->begin = (unsigned long)*ri->ptr;
+    rangeList->end = (unsigned long)*ri->ptr;
 
     for (ri->ptr++; *ri->ptr && *ri->ptr != ']'; ri->ptr++) {
         if (*ri->ptr == '-') {
-            rangeList->end = ri->ptr + 1;
+            rangeList->end = (unsigned long)(ri->ptr + 1);
             ri->ptr++;
             continue;
         }
         if (ri->ptr[0] == 0 || ri->ptr[0] == ']') break;
-        if (ri->ptr[0] == rangeList->end[0] + 1) {
-            rangeList->end = ri->ptr;
+        if (ri->ptr[0] == rangeList->end + 1) {
+            rangeList->end = (unsigned long)ri->ptr;
             continue;
         }
         rangeList->next = NEW(RangeList);
         rangeList = rangeList->next;
-        rangeList->begin = ri->ptr;
-        rangeList->end = ri->ptr;
+        rangeList->begin = (unsigned long)ri->ptr;
+        rangeList->end = (unsigned long)ri->ptr;
         rangeList->next = NULL;
     }
     // TODO literal support
@@ -111,6 +92,7 @@
 static
 NodePtr literal(RegexInfoPtr ri) {
     CharClassPtr cc = createCharClassWord(ri);
+    token(ri);
     NodePtr n = createNode(ri,'a',cc,0,0);
     return n;
 }