Beispiel #1
0
        private void ParseEntities(ISymbolEnumerator symbols)
        {
            Symbol     temp   = symbols.NextNonEOLSymbol();
            SymbolList buffer = new SymbolList();

            while (temp != Symbol.End)
            {
                if (temp == Symbol.Assign)
                {
                    ParseEntity(buffer, symbols);
                    buffer.Clear();
                    // skip linebreaks behind an entity
                    temp = symbols.NextNonEOLSymbol();
                }
                else
                {
                    buffer.Add(temp);
                    temp = symbols.NextSymbol();
                }
            }
        }
Beispiel #2
0
        private bool Parse(ParseParams pp, char current, int row, int column)
        {
            switch (current)
            {
            case '\n':
            case '{':
            case '}':
            case '(':
            case ')':
            case '[':
            case ']':
            case ';':
            case ',':
            case '|':
                if (!pp.StringSection)
                {
                    bool moveNext = ParseLastSymbol(pp, row, column);
                    if (moveNext)
                    {
                        _symbols.Add(CreateSpecialSymbol(pp.File, '\n', row, column));
                        return(true);
                    }

                    _symbols.Add(CreateSpecialSymbol(pp.File, current, row, column));
                    return(false);
                }

                break;

            case '"':
                pp.StringSection = !pp.StringSection;
                break;

            case '\r':
                return(false);

            default:
                if ((int)current == 0x1A)
                {
                    // IMPORTANT: ignore invisible characters such as SUB.
                    return(false);
                }

                if (Char.IsWhiteSpace(current) && !pp.AssignSection && !pp.StringSection)
                {
                    bool moveNext = ParseLastSymbol(pp, row, column);
                    if (moveNext)
                    {
                        _symbols.Add(CreateSpecialSymbol(pp.File, '\n', row, column));
                        return(true);
                    }

                    return(false);
                }

                if (pp.AssignAhead)
                {
                    pp.AssignAhead = false;
                    ParseLastSymbol(pp, row, column);
                    break;
                }

                if (pp.DotSection && current != '.')
                {
                    ParseLastSymbol(pp, row, column);
                    pp.DotSection = false;
                }

                if (current == '.' && !pp.StringSection)
                {
                    if (!pp.DotSection)
                    {
                        ParseLastSymbol(pp, row, column);
                        pp.DotSection = true;
                    }
                }

                if (current == ':' && !pp.StringSection)
                {
                    if (!pp.AssignSection)
                    {
                        ParseLastSymbol(pp, row, column);
                    }

                    pp.AssignSection = true;
                }

                if (current == '=' && !pp.StringSection)
                {
                    pp.AssignSection = false;
                    pp.AssignAhead   = true;
                }

                break;
            }

            pp.Temp.Append(current);
            return(false);
        }