Esempio n. 1
0
        private int getOff(ArgumentPart a)
        {
            switch (ArgEnum.get(a).Index)
            {
            case 7:
            case 8:
                return(ArgEnum.get(a).Index + 2);

            case 10:                     // xxx.w
                return(7);

            case 9:                     // xxx.l
                return(8);

            default:
                return(ArgEnum.get(a).Index);
            }
        }
Esempio n. 2
0
        private static ArgumentPart[] parseArgs(int lnum, List <string> parts, char size)
        {
            ArgumentPart[] ret = new ArgumentPart[parts.Count];

            for (int i = 0; i < parts.Count && parse; i++)
            {
                char c = parts[i].ElementAt(0);

                if (c == '#')
                {
                    ret[i] = new ArgImmediateValue(lnum, parts[i], size);
                }
                else if (parts[i].Contains(';'))
                {
                    if (parts[i].StartsWith("\t"))
                    {
                        if (cycleRegex.Matches(parts[i]).Count > 0)
                        {
                            // this is comment about cycle counts more likely. Try to remove it.
                            ArgumentPart[] p = ret;
                            ret = new ArgumentPart[p.Length - 1];

                            for (int q = 0; q < i; q++)
                            {
                                ret[q] = p[q];
                            }
                        }
                        else
                        {
                            // not cycle count comment
                            ret[i] = new Comment(lnum, parts[i]);
                        }
                    }
                    else
                    {
                        ret[i] = new Comment(lnum, parts[i]);
                    }
                }
                else
                {
                    bool hadSP = false;
                    // change sp to a7 so we can deal with it easier
                    if (!parts[i].ToLower().Contains("usp") && parts[i].ToLower().Contains("sp"))
                    {
                        parts[i] = parts[i].ToLower().Replace("sp", "a7");
                        hadSP    = true;
                    }

                    // we found no 'easy' match, therefore attempt patternmatching via regex
                    int rx = -1;
                    foreach (Regex r in regex)
                    {
                        ++rx;
                        if (r.Matches(parts[i]).Count > 0)
                        {
                            ret[i] = funcs[rx](lnum, hadSP ? parts[i].Replace("a7", "sp") : parts[i], size, i);
                            break;
                        }
                    }

                    if (ret[i] == null)
                    {
                        ShowParseError(lnum, "Could not find regex that matches '" + parts[i] + "'!\nParsing will now terminate.", "Error!");
                        return(null);
                    }
                }
            }

            return(ret);
        }