AddCompilerError() private method

private AddCompilerError ( Cursor cursor, System error ) : void
cursor Cursor
error System
return void
Esempio n. 1
0
        public override void Run(Grammar grammar, CompileResult result)
        {
            var seenSettings = new HashSet<string>();

            foreach (var setting in grammar.Settings)
            {
                var cursor = setting.Key.Start;

                bool singleAllowed;
                if (KnownSettings.TryGetValue(setting.Key.Name, out singleAllowed))
                {
                    if (singleAllowed && !seenSettings.Add(setting.Key.Name))
                    {
                        result.AddCompilerError(cursor, () => Resources.PEG0005_ERROR_SettingAlreadySpecified, setting.Key.Name);
                    }
                }
                else
                {
                    result.AddCompilerError(cursor, () => Resources.PEG0006_WARNING_SettingUnknown, setting.Key.Name);
                }

                string pattern;
                if (ValuePatterns.TryGetValue(setting.Key.Name, out pattern))
                {
                    if (!Regex.IsMatch(setting.Value.ToString(), pattern))
                    {
                        result.AddCompilerError(cursor, () => Resources.PEG0012_ERROR_SettingValueInvalid, setting.Value, setting.Key.Name);
                    }
                }
            }
        }
        public override void Run(Grammar grammar, CompileResult result)
        {
            var seenSettings = new HashSet <string>();

            foreach (var setting in grammar.Settings)
            {
                var cursor = setting.Key.Start;

                bool singleAllowed;
                if (KnownSettings.TryGetValue(setting.Key.Name, out singleAllowed))
                {
                    if (singleAllowed && !seenSettings.Add(setting.Key.Name))
                    {
                        result.AddCompilerError(cursor, () => Resources.PEG0005_ERROR_SettingAlreadySpecified, setting.Key.Name);
                    }
                }
                else
                {
                    result.AddCompilerError(cursor, () => Resources.PEG0006_WARNING_SettingUnknown, setting.Key.Name);
                }

                string pattern;
                if (ValuePatterns.TryGetValue(setting.Key.Name, out pattern))
                {
                    if (!Regex.IsMatch(setting.Value.ToString(), pattern))
                    {
                        result.AddCompilerError(cursor, () => Resources.PEG0012_ERROR_SettingValueInvalid, setting.Value, setting.Key.Name);
                    }
                }
            }
        }
Esempio n. 3
0
        public override void Run(Grammar grammar, CompileResult result)
        {
            foreach (var rule in result.LeftRecursiveRules)
            {
                if (!rule.Flags.Any(f => f.Name == "memoize"))
                {
                    result.AddCompilerError(rule.Identifier.Start, () => Resources.PEG0020_ERROR_UnmemoizedLeftRecursion, rule.Identifier.Name);
                }
            }

            foreach (var rule in result.MutuallyRecursiveRules)
            {
                result.AddCompilerError(rule.Identifier.Start, () => Resources.PEG0023_ERROR_AmbiguousLeftRecursionDetected, rule.Identifier.Name);
            }
        }
Esempio n. 4
0
        public override void Run(Grammar grammar, CompileResult result)
        {
            foreach (var rule in result.LeftRecursiveRules)
            {
                if (!rule.Flags.Any(f => f.Name == "memoize"))
                {
                    result.AddCompilerError(rule.Identifier.Start, () => Resources.PEG0020_ERROR_UnmemoizedLeftRecursion, rule.Identifier.Name);
                }
            }

            foreach (var rule in result.MutuallyRecursiveRules)
            {
                result.AddCompilerError(rule.Identifier.Start, () => Resources.PEG0023_ERROR_AmbiguousLeftRecursionDetected, rule.Identifier.Name);
            }
        }
Esempio n. 5
0
 public override void Run(Grammar grammar, CompileResult result)
 {
     if (grammar.Rules.Count == 0)
     {
         var cursor = grammar.End;
         result.AddCompilerError(cursor, () => Resources.PEG0001_ERROR_NoRulesDefined);
     }
 }
Esempio n. 6
0
 public override void Run(Grammar grammar, CompileResult result)
 {
     foreach (var rule in grammar.Rules)
     {
         if (char.IsLower(rule.Identifier.Name[0]))
         {
             if (rule.Flags.Any(f => f.Name == "public"))
             {
                 result.AddCompilerError(rule.Identifier.Start, () => Resources.PEG0025_WARNING_LowercasePublicRule, rule.Identifier.Name);
             }
             else if (rule.Flags.Any(f => f.Name == "export"))
             {
                 result.AddCompilerError(rule.Identifier.Start, () => Resources.PEG0025_WARNING_LowercaseExportedRule, rule.Identifier.Name);
             }
         }
     }
 }
Esempio n. 7
0
 public override void Run(Grammar grammar, CompileResult result)
 {
     if (grammar.Rules.Count == 0)
     {
         var cursor = grammar.End;
         result.AddCompilerError(cursor, () => Resources.PEG0001_ERROR_NoRulesDefined);
     }
 }
 public override void Run(Grammar grammar, CompileResult result)
 {
     foreach (var rule in grammar.Rules)
     {
         if (char.IsLower(rule.Identifier.Name[0]))
         {
             if (rule.Flags.Any(f => f.Name == "public"))
             {
                 result.AddCompilerError(rule.Identifier.Start, () => Resources.PEG0025_WARNING_LowercasePublicRule, rule.Identifier.Name);
             }
             else if (rule.Flags.Any(f => f.Name == "export"))
             {
                 result.AddCompilerError(rule.Identifier.Start, () => Resources.PEG0025_WARNING_LowercaseExportedRule, rule.Identifier.Name);
             }
         }
     }
 }
        public override void Run(Grammar grammar, CompileResult result)
        {
            var types = result.ExpressionTypes;

            foreach (var rule in grammar.Rules)
            {
                if (!types.ContainsKey(rule.Expression))
                {
                    result.AddCompilerError(rule.Identifier.Start, () => Resources.PEG0019_ERROR_UnknownType, rule.Identifier.Name);
                }
            }
        }
Esempio n. 10
0
        public override void Run(Grammar grammar, CompileResult result)
        {
            var types = result.ExpressionTypes;

            foreach (var rule in grammar.Rules)
            {
                if (!types.ContainsKey(rule.Expression))
                {
                    result.AddCompilerError(rule.Identifier.Start, () => Resources.PEG0019_ERROR_UnknownType, rule.Identifier.Name);
                }
            }
        }
        public override void Run(Grammar grammar, CompileResult result)
        {
            var knownRules = new HashSet<string>();

            foreach (var rule in grammar.Rules)
            {
                if (!knownRules.Add(rule.Identifier.Name))
                {
                    var cursor = rule.Identifier.Start;
                    result.AddCompilerError(cursor, () => Resources.PEG0002_ERROR_RuleAlreadyDefined, rule.Identifier.Name);
                }
            }
        }
Esempio n. 12
0
        public override void Run(Grammar grammar, CompileResult result)
        {
            var knownRules = new HashSet <string>();

            foreach (var rule in grammar.Rules)
            {
                if (!knownRules.Add(rule.Identifier.Name))
                {
                    var cursor = rule.Identifier.Start;
                    result.AddCompilerError(cursor, () => Resources.PEG0002_ERROR_RuleAlreadyDefined, rule.Identifier.Name);
                }
            }
        }
Esempio n. 13
0
 public override void Run(Grammar grammar, CompileResult result)
 {
     foreach (var rule in grammar.Rules)
     {
         foreach (var flag in rule.Flags)
         {
             if (!KnownFlags.Contains(flag.Name))
             {
                 var cursor = flag.Start;
                 result.AddCompilerError(cursor, () => Resources.PEG0013_WARNING_FlagUnknown, flag.Name);
             }
         }
     }
 }
Esempio n. 14
0
 public override void Run(Grammar grammar, CompileResult result)
 {
     foreach (var rule in grammar.Rules)
     {
         foreach (var flag in rule.Flags)
         {
             if (!KnownFlags.Contains(flag.Name))
             {
                 var cursor = flag.Start;
                 result.AddCompilerError(cursor, () => Resources.PEG0013_WARNING_FlagUnknown, flag.Name);
             }
         }
     }
 }
Esempio n. 15
0
        public override void Run(Grammar grammar, CompileResult result)
        {
            var knownRules = new HashSet <string>(grammar.Rules.Select(r => r.Identifier.Name));

            foreach (var setting in grammar.Settings)
            {
                if (setting.Key.Name == SettingName.Start)
                {
                    var name = setting.Value.ToString().Trim();
                    if (!knownRules.Contains(name))
                    {
                        result.AddCompilerError(setting.Key.Start, () => Resources.PEG0003_ERROR_RuleDoesNotExist, name);
                    }
                }
            }
        }
        public override void Run(Grammar grammar, CompileResult result)
        {
            var knownRules = new HashSet<string>(grammar.Rules.Select(r => r.Identifier.Name));

            foreach (var setting in grammar.Settings)
            {
                if (setting.Key.Name == "start")
                {
                    var name = setting.Value.ToString().Trim();
                    if (!knownRules.Contains(name))
                    {
                        result.AddCompilerError(setting.Key.Start, () => Resources.PEG0003_ERROR_RuleDoesNotExist, name);
                    }
                }
            }
        }