Example #1
0
            internal int lhCntx;                        // length of fixed context lhs

            public NState(NfsaInstance elem)
            {
                myNfaInst    = elem;
                myNfsa       = elem.parent;
                serialNumber = nextSN++;
                epsilons     = new BitArray(myNfaInst.MaxEps); // Caller adds to nStates list.
            }
Example #2
0
 public NfsaInstance(StartState ss, NFSA parent)
 {
     myStartCondition = ss;
     this.parent      = parent;
     this.Pack        = parent.task.ChrClasses;
     if (Pack)
     {
         MaxSym = parent.task.partition.Length;          // Number of equivalence classes
     }
     else
     {
         MaxSym = parent.task.TargetSymCardinality;      // Size of alphabet
     }
     entryState = MkState();
 }
Example #3
0
        internal void Process(string fileArg)
		{
            GetNames(fileArg);
            // check for file exists
            OpenSource();
            // parse source file
            if (inputFile != null)
            {
                DateTime start = DateTime.Now;
                try
                {
                    handler = new ErrorHandler();
                    scanner = new QUT.Gplex.Lexer.Scanner(inputFile);
                    parser = new QUT.Gplex.Parser.Parser(scanner);
                    scanner.yyhdlr = handler;
                    parser.Initialize(this, scanner, handler, new OptionParser2(ParseOption));
                    aast = parser.Aast;
                    parser.Parse();
                    // aast.DiagnosticDump();
                    if (verbose) 
                        Status(start);
                    CheckOptions();
                    if (!Errors && !ParseOnly)
                    {	// build NFSA
                        if (ChrClasses) {
                            DateTime t0 = DateTime.Now;
                            partition = new Partition( TargetSymCardinality, this );
                            partition.FindClasses( aast );
                            partition.FixMap();
                            if (verbose)
                                ClassStatus( t0, partition.Length );
                        }
                        else
                            CharRange.Init( TargetSymCardinality );
                        nfsa = new NFSA(this);
                        nfsa.Build(aast);
                        if (!Errors)
                        {	// convert to DFSA
                            dfsa = new DFSA(this);
                            dfsa.Convert(nfsa);
                            if (!Errors)
                            {	// minimize automaton
                                if (minimize)
                                    dfsa.Minimize();
                                if (!Errors && !checkOnly)
                                {   // emit the scanner to output file
                                    TextReader frameRdr = FrameReader();
                                    TextWriter outputWrtr = OutputWriter();
                                    dfsa.EmitScanner(frameRdr, outputWrtr);

                                    if (!embedBuffers)
                                        CopyBufferCode();
                                    // Clean up!
                                    if (frameRdr != null) 
                                        frameRdr.Close();
                                    if (outputWrtr != null) 
                                        outputWrtr.Close();
                                }
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    string str = ex.Message;
                    handler.AddError(str, aast.AtStart);
                    throw;
                }
            }
		}
Example #4
0
        internal void Process(string fileArg)
        {
            GetNames(fileArg);
            // check for file exists
            OpenSource();
            // parse source file
            if (inputFile != null)
            {
                DateTime start = DateTime.Now;
                try
                {
                    handler        = new ErrorHandler();
                    scanner        = new QUT.Gplex.Lexer.Scanner(inputFile);
                    parser         = new QUT.Gplex.Parser.Parser(scanner);
                    scanner.yyhdlr = handler;
                    parser.Initialize(this, scanner, handler, new OptionParser2(ParseOption));
                    aast = parser.Aast;
                    parser.Parse();
                    // aast.DiagnosticDump();
                    if (verbose)
                    {
                        Status(start);
                    }
                    CheckOptions();
                    if (!Errors && !ParseOnly)
                    {   // build NFSA
                        if (ChrClasses)
                        {
                            DateTime t0 = DateTime.Now;
                            partition = new Partition(TargetSymCardinality, this);
                            partition.FindClasses(aast);
                            partition.FixMap();
                            if (verbose)
                            {
                                ClassStatus(t0, partition.Length);
                            }
                        }
                        else
                        {
                            CharRange.Init(TargetSymCardinality);
                        }
                        nfsa = new NFSA(this);
                        nfsa.Build(aast);
                        if (!Errors)
                        {       // convert to DFSA
                            dfsa = new DFSA(this);
                            dfsa.Convert(nfsa);
                            if (!Errors)
                            {   // minimize automaton
                                if (minimize)
                                {
                                    dfsa.Minimize();
                                }
                                if (!Errors && !checkOnly)
                                {   // emit the scanner to output file
                                    TextReader frameRdr   = FrameReader();
                                    TextWriter outputWrtr = OutputWriter();
                                    dfsa.EmitScanner(frameRdr, outputWrtr);

                                    if (!embedBuffers)
                                    {
                                        CopyBufferCode();
                                    }
                                    // Clean up!
                                    if (frameRdr != null)
                                    {
                                        frameRdr.Close();
                                    }
                                    if (outputWrtr != null)
                                    {
                                        outputWrtr.Close();
                                    }
                                }
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    string str = ex.Message;
                    handler.AddError(str, aast.AtStart);
                    throw;
                }
            }
        }
Example #5
0
 public NState(NfsaInstance elem)
 {
     myNfaInst = elem;
     myNfsa = elem.parent;
     serialNumber = (ushort)nextSN++;
     epsilons = new BitArray(myNfaInst.MaxEps);    // Caller adds to nStates list.
 }
Example #6
0
 public NfsaInstance(StartState ss, NFSA parent)
 {
     myStartCondition = ss;
     this.parent = parent;
     this.pack = parent.task.ChrClasses;
     if (pack)
         maxS = parent.task.partition.Length;          // Number of equivalence classes
     else
         maxS = parent.task.TargetSymCardinality;      // Size of alphabet
     entryState = MkState();
 }