Exemplo n.º 1
0
        public Line(string s)
        {
            s = s.Trim();
            if(!String.IsNullOrEmpty(s))
                if (s.Length > 0)
                {
                    Raw = s;

                    switch (s[0])
                    {
                        case '.':
                            Type = ELineType.Directive;
                            break;
                        case '#':
                            Type = ELineType.Comment;
                            break;
                        case ':':
                            Type = ELineType.Label;
                            break;
                        default:
                            Type = ELineType.Instruction;
                            break;
                    }
                    if (s.Contains(' '))
                    {
                        Tokens.AddRange(s.Split(new String[] { " " }, StringSplitOptions.RemoveEmptyEntries));
                        if (Tokens.Count > 0)
                        {
                            switch (Tokens.First().ToLowerInvariant().Trim())
                            {
                                case ".class":
                                    Directive = ELineDirective.Class;
                                    break;
                                case ".super":
                                    Directive = ELineDirective.Super;
                                    break;
                                case ".source":
                                    Directive = ELineDirective.Source;
                                    break;
                                case ".field":
                                    Directive = ELineDirective.Field;
                                    NewGroup = true;
                                    break;
                                case ".method":
                                    Directive = ELineDirective.Method;
                                    NewGroup = true;
                                    break;
                                case ".end":
                                    if(Tokens[1] == "method")
                                        Directive = ELineDirective.EndMethod;
                                    break;
                            }
                        }
                    }
                }
        }
Exemplo n.º 2
0
        public Line(string s)
        {
            s = s.Trim();
            if (!String.IsNullOrEmpty(s))
            {
                if (s.Length > 0)
                {
                    Raw = s;

                    switch (s[0])
                    {
                    case '.':
                        Type = ELineType.Directive;
                        break;

                    case '#':
                        Type = ELineType.Comment;
                        break;

                    case ':':
                        Type = ELineType.Label;
                        break;

                    default:
                        Type = ELineType.Instruction;
                        break;
                    }
                    if (s.Contains(' '))
                    {
                        Tokens.AddRange(s.Split(new String[] { " " }, StringSplitOptions.RemoveEmptyEntries));
                        if (Tokens.Count > 0)
                        {
                            switch (Tokens.First().ToLowerInvariant().Trim())
                            {
                            case ".class":
                                Directive = ELineDirective.Class;
                                break;

                            case ".super":
                                Directive = ELineDirective.Super;
                                break;

                            case ".source":
                                Directive = ELineDirective.Source;
                                break;

                            case ".field":
                                Directive = ELineDirective.Field;
                                NewGroup  = true;
                                break;

                            case ".method":
                                Directive = ELineDirective.Method;
                                NewGroup  = true;
                                break;

                            case ".end":
                                if (Tokens[1] == "method")
                                {
                                    Directive = ELineDirective.EndMethod;
                                }
                                break;
                            }
                        }
                    }
                }
            }
        }