Example #1
0
 public IncludeFile(DocLocation loc, string file, string description, ParserInformation parent)
 {
     Location     = loc;
     IncludedFile = file;
     Description  = description;
     Parent       = parent;
 }
 public IncludeFile(int counter, string file, string description, ParserInformation parent)
 {
     Offset       = counter;
     IncludedFile = file;
     Description  = description;
     Parent       = parent;
 }
Example #3
0
 public Label(int offset, string labelName, bool isEquate, string description, ParserInformation parent)
 {
     LabelName   = labelName;
     Offset      = offset;
     IsEquate    = isEquate;
     Description = description;
     Parent      = parent;
 }
Example #4
0
 public Macro(int counter, string macroName, List <string> args, string contents, string description, ParserInformation parent)
 {
     Offset      = counter;
     Name        = macroName;
     Contents    = contents;
     Description = description;
     Arguments   = args;
     Parent      = parent;
 }
Example #5
0
 public Define(int counter, string macroName, string contents, string description, ParserInformation parent, int?value = null)
 {
     Offset      = counter;
     Name        = macroName;
     Contents    = contents;
     Description = description;
     Parent      = parent;
     Value       = value;
 }
Example #6
0
 public Macro(DocLocation loc, string macroName, IList <string> args, string contents, string description, ParserInformation parent)
 {
     Location    = loc;
     Name        = macroName;
     Contents    = contents;
     Description = description;
     Arguments   = args;
     Parent      = parent;
 }
Example #7
0
        public void ParseText(ParserInformation parserInfo, string fileText)
        {
            var tokens = TokenizeLine(fileText);

            _tokensEnumerator = tokens.GetEnumerator();
            _lines            = fileText.Split('\n');
            _parserInfo       = parserInfo;
            int percent = 0;

            for (_lineIndex = 0; _lineIndex < _lines.Length; _lineIndex++)
            {
                int newPercent = _lineIndex * 100 / _lines.Length;

                if (percent + 5 <= newPercent)
                {
                    percent = newPercent;

                    if (OnParserProgress != null)
                    {
                        OnParserProgress(this, new ParserProgressEventArgs(parserInfo.SourceFile, percent));
                    }
                }

                bool hasNext;
                do
                {
                    hasNext = _tokensEnumerator.MoveNext();
                    if (!hasNext)
                    {
                        break;
                    }

                    char firstChar = _tokensEnumerator.Current.First();
                    if (firstChar == CommentChar)
                    {
                        SkipToEndOfLine();
                        break;
                    }
                    // handle label other xx = 22 type define
                    if (IsValidLabelChar(firstChar))
                    {
                        HandleLabelOrDefine();
                    }
                    else
                    {
                        if (char.IsWhiteSpace(firstChar))
                        {
                            hasNext = SkipWhitespace();
                            if (!hasNext)
                            {
                                break;
                            }
                        }

                        if (_tokensEnumerator.Current == "#")
                        {
                            if (_tokensEnumerator.MoveNext())
                            {
                                switch (_tokensEnumerator.Current.ToLower())
                                {
                                case IncludeString:
                                    HandleInclude();
                                    break;

                                case DefineString:
                                    HandleDefine();
                                    break;

                                case CommentString:
                                    _lineIndex = HandleBlockComment();
                                    break;

                                case MacroString:
                                    _lineIndex = HandleMacro();
                                    break;
                                }
                            }
                        }
                    }

                    hasNext = SkipToEndOfCodeLine();
                    if (_tokensEnumerator.Current == CommentChar.ToString())
                    {
                        SkipToEndOfLine();
                        break;
                    }
                } while (hasNext && IsEndOfCodeLine() && !IsEndOfLine());
            }
        }