예제 #1
0
        public override void Analyse(LineCollection lines)
        {
            if (lines == null)
            {
                return;
            }


            manager = new LuceneManager();
            if (!manager.ExistSchema("address"))
            {
                manager.AddSchema("address");
            }



            var analyzeIndexList = new List <AnalyzeIndex>();


            foreach (var line in lines)
            {
                foreach (var sentence in line.SentenceList)
                {
                    foreach (var word in sentence.WordList)
                    {
                        if (word.SpellWord != null)
                        {
                            if (word.SpellWord.Root != null)
                            {
                                var adresList = AddressControl(word);


                                if (adresList != null)
                                {
                                    if (adresList.Count > 0)
                                    {
                                        var analyze = new AnalyzeIndex();

                                        analyze.AnalyzeIndexCollection.AddRange(adresList);
                                        analyze.LineNumber     = lines.IndexOf(line);
                                        analyze.WordNumber     = sentence.WordList.IndexOf(word);
                                        analyze.SentenceNumber = line.SentenceList.IndexOf(sentence);


                                        analyzeIndexList.Add(analyze);
                                    }
                                }
                            }
                        }
                    }
                }
            }



            ClearAddressIndex(ref analyzeIndexList, lines);
        }
예제 #2
0
        internal static LineCollection ScanLines(string[] lines, out CodeBlock[] userFunctions)
        {
            LineCollection allLines = new LineCollection();
            List <uint>    funLines = new List <uint>();

            for (uint lineNumber = 0; lineNumber < lines.Length; ++lineNumber)
            {
                Line current = new Line(lineNumber + 1, lines[lineNumber]); // Tag all lines with its line number (index + 1)

                if (string.IsNullOrEmpty(current.Text) || current.Text[0] == ';')
                {
                    continue;
                }
                if (current.Name[current.Name.Length - 1] == '$' || current.Name[current.Name.Length - 1] == ']')
                {
                    current.Text = "LET " + current.Text; // add the word LET if it's an equality, but use the original name as visible name
                }
                else if (current.Name.EqualsIgnoreCase("FUNCTION"))
                {
                    funLines.Add(current.LineNumber);
                }
                else
                {
                    current.VisibleName = current.VisibleName.ToUpper();
                }

                while (current.Text[current.Text.Length - 1] == '_')   // line continuation
                {
                    lineNumber++;
                    if (lineNumber >= lines.Length)
                    {
                        throw new EndOfCodeException("line continuation character '_' cannot end script");
                    }
                    current = new Line(current.LineNumber, current.Text.Remove(current.Text.LastIndexOf('_')) + lines[lineNumber].Trim());
                }

                allLines.Add(current);
            }

            List <CodeBlock> userFuncs = new List <CodeBlock>();

            foreach (uint funcLine in funLines)
            {
                FuncBlock func = new FuncBlock(allLines.IndexOf(funcLine), allLines);
                userFuncs.Add(func);
                allLines.Remove(func.Header);
                allLines.Remove(func.Body);
                allLines.Remove(func.Footer);
            }
            userFunctions = userFuncs.ToArray();
            return(allLines);
        }