예제 #1
0
        /**
         * Performs semantic analysis for all expressions.
         *
         * Currently: illegal lookahead check only
         * [fixme: more checks possible]
         *
         * @param rs   the reg exps to be checked
         * @param m    the macro table (in expanded form)
         * @param max  max character of the used charset (for negation)
         * @param f    the spec file containing the rules [fixme]
         */
        public static void check(RegExps rs, Macros m, char max, File f)
        {
            macros  = m;
            maxChar = max;

            bool errors = false;
            int  num    = rs.getNum();

            for (int i = 0; i < num; i++)
            {
                RegExp r = rs.getRegExp(i);
                RegExp l = rs.getLookAhead(i);

                if (!checkLookAhead(r, l))
                {
                    errors = true;
                    Out.error(f, ErrorMessages.LOOKAHEAD_ERROR, rs.getLine(i), -1);
                }
            }

            if (errors)
            {
                throw new GeneratorException();
            }
        }
예제 #2
0
        public NFA(int numInput, LexScan scanner, RegExps regExps,
                   Macros macros, CharClasses classes)
            : this(numInput, regExps.NFASize(macros) + 2 * scanner.states.number())
        {
            this.scanner = scanner;
            this.regExps = regExps;
            this.macros  = macros;
            this.classes = classes;

            numLexStates = scanner.states.number();

            ensureCapacity(2 * numLexStates);

            numStates = 2 * numLexStates;
        }