public static PatternCode Scan(string code)
        {
            PatternCode lPatternCode = new PatternCode();
            int         lPosition    = 0;

            PatternToken lPreviousToken = PatternToken.UNKNOWN;

            // tokenize code
            while (lPosition < code.Length)
            {
                string       lTokenString = ReadTokenString(code, ref lPosition);
                PatternToken lToken       = GetToken(lTokenString, lPreviousToken);

                // "*" could also be a variable
                if ((lToken == PatternToken.MULTIPLY) && (lPreviousToken == PatternToken.COMMA || lPreviousToken == PatternToken.OPEN_PARA))
                {
                    lToken = PatternToken.VARIABLE;
                }

                int lParameterCount = (lToken == PatternToken.FUNCTION) ? GetParameterCount(code, lPosition) : 0;

                PatternOperand patternOperand = new PatternOperand(lToken, lTokenString, lParameterCount);

                if (lToken == PatternToken.UNKNOWN)
                {
                    lPatternCode.SetErrorMessage("Unknown Token: " + lTokenString.ToString());
                    return(lPatternCode);
                }
                lPatternCode.Add(patternOperand);

                lPreviousToken = lToken;
            }

            return(lPatternCode);
        }
Ejemplo n.º 2
0
 public void Add(PatternOperand patternOperand)
 {
     Code.Add(patternOperand);
 }
Ejemplo n.º 3
0
 public void Add(PatternOperand patternOperand)
 {
     Code.Add(patternOperand);
 }
Ejemplo n.º 4
0
        public static PatternCode Scan(string code)
        {
            PatternCode lPatternCode = new PatternCode();
            int lPosition = 0;

            PatternToken lPreviousToken = PatternToken.UNKNOWN;

            // tokenize code
            while (lPosition < code.Length)
            {
                string lTokenString = ReadTokenString(code, ref lPosition);
                PatternToken lToken = GetToken(lTokenString, lPreviousToken);

                // "*" could also be a variable
                if ((lToken == PatternToken.MULTIPLY) && (lPreviousToken == PatternToken.COMMA || lPreviousToken == PatternToken.OPEN_PARA))
                    lToken = PatternToken.VARIABLE;

                int lParameterCount = (lToken == PatternToken.FUNCTION) ? GetParameterCount(code, lPosition) : 0;

                PatternOperand patternOperand = new PatternOperand(lToken, lTokenString, lParameterCount);

                if (lToken == PatternToken.UNKNOWN)
                {
                    lPatternCode.SetErrorMessage("Unknown Token: " + lTokenString.ToString());
                    return lPatternCode;
                }
                lPatternCode.Add(patternOperand);

                lPreviousToken = lToken;
            }

            return lPatternCode;
        }