Exemple #1
0
        public override IList <string> GetFirsts()
        {
            var result = new StringList();

            result.AddRange(Prefixes);
            //we assume that prefix is always optional, so string can start with start-end symbol
            result.AddRange(_startSymbolsFirsts.Select(ch => ch.ToString()));

            return(result);
        }
Exemple #2
0
        }//constructor

        public override IList <string> GetFirsts()
        {
            var result = new StringList();

            result.AddRange(Firsts);
            return(result);
        }
Exemple #3
0
 public CommentTerminal(string name, string startSymbol, params string[] endSymbols) : base(name, TokenCategory.Comment)
 {
     StartSymbol = startSymbol;
     EndSymbols  = new StringList();
     EndSymbols.AddRange(endSymbols);
     Priority = TerminalPriority.High; //assign max priority
 }
Exemple #4
0
        public override IList <string> GetFirsts()
        {
            var firsts = new StringList();

            firsts.AddRange(LineTerminators.Select(t => t.ToString()));
            return(firsts);
        }
Exemple #5
0
        public override IList <string> GetFirsts()
        {
            StringList result = new StringList();

            result.AddRange(base.Prefixes);
            //we assume that prefix is always optional, so number can always start with plain digit
            result.AddRange(new string[] { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" });
            // Python float numbers can start with a dot
            if (IsSet(NumberOptions.AllowStartEndDot))
            {
                result.Add(DecimalSeparator.ToString());
            }
            if (IsSet(NumberOptions.AllowSign))
            {
                result.AddRange(new string[] { "-", "+" });
            }
            return(result);
        }
Exemple #6
0
        public static string JoinStrings(string separator, IEnumerable <string> values)
        {
            StringList list = new StringList();

            list.AddRange(values);
            string[] arr = new string[list.Count];
            list.CopyTo(arr, 0);
            return(string.Join(separator, arr));
        }
        public LineContinuationTerminal(string name, params string[] startSymbols) : base(name, TokenCategory.Outline)
        {
            var symbols = startSymbols.Where(s => !IsNullOrWhiteSpace(s)).ToArray();

            StartSymbols = new StringList(symbols);
            if (StartSymbols.Count == 0)
            {
                StartSymbols.AddRange(_defaultStartSymbols);
            }
            Priority = TerminalPriority.High;
        }
        }//method

        public override IList <string> GetFirsts()
        {
            StringList result = new StringList();

            result.AddRange(Prefixes);
            //we assume that prefix is always optional, so string can start with start-end symbol
            foreach (char ch in _startSymbolsFirsts)
            {
                result.Add(ch.ToString());
            }
            return(result);
        }
Exemple #9
0
        //TODO: put into account non-Ascii aplhabets specified by means of Unicode categories!
        public override IList <string> GetFirsts()
        {
            var list = new StringList();

            list.AddRange(Prefixes);
            foreach (char ch in _allFirstCharsSet)
            {
                list.Add(ch.ToString());
            }
            if ((Options & IdOptions.CanStartWithEscape) != 0)
            {
                list.Add(this.EscapeChar.ToString());
            }
            return(list);
        }
        //TODO: put into account non-Ascii aplhabets specified by means of Unicode categories!
        public override IList <string> GetFirsts()
        {
            StringList list = new StringList();

            list.AddRange(Prefixes);
            if (string.IsNullOrEmpty(AllFirstChars))
            {
                return(list);
            }
            char[] chars = AllFirstChars.ToCharArray();
            foreach (char ch in chars)
            {
                list.Add(ch.ToString());
            }
            if ((Options & IdOptions.CanStartWithEscape) != 0)
            {
                list.Add(this.EscapeChar.ToString());
            }
            return(list);
        }