view regexParser/main.cc @ 222:c38a7b2dd996

implement exportState function (not correct working)
author Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
date Thu, 14 Jan 2016 21:46:35 +0900
parents a8e477f1352d
children 399380ad95b7
line wrap: on
line source

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "regexParser.h"
#include "subsetConstruction.h"
#include "node.h"

int main(int argc, char **argv)
{
    bool generate = true;
    bool subset = false;

    RegexInfo ri;
    ri.stateNumber = 1;
    for (int i = 1; i < argc; i++) {
        if (strcmp(argv[i],"-regex") == 0) {
            ri.ptr = (unsigned char*)argv[i+1]; i++;
        } else if (strcmp(argv[i],"-noGeneration") == 0) {
            generate = false;
        } else if (strcmp(argv[i],"-subset") == 0) {
            subset = true;
        }
    }
    if (!ri.ptr) return 0;

    printf("regex : %s\n",ri.ptr);
    NodePtr n = regex(&ri);   // parse only
    printTree(n);

    if (generate && !subset)  {  // NFA generation
        TGValue tgv = generateTransitionList(n);
        printTree(n);
        printState(tgv.tg);
        exportState(tgv.tg);
    } else if (subset)  {
        TGValue tgv = generateTransitionList(n);
        SCValue scv = createSCValue(tgv);
        subsetConstruction(scv);   // Determinization
        printState(tgv.tg);
        exportState(tgv.tg);
    }
    return 0;
}