Esempio n. 1
0
 private void ValidateNoUndeclaredCharsets(CharsetExpression expr)
 {
     if (expr is CharsetBinaryExpression)
     {
         var b = expr as CharsetBinaryExpression;
         ValidateNoUndeclaredCharsets(b.Left);
         ValidateNoUndeclaredCharsets(b.Right);
     }
     else if (expr is CharsetNameExpression)
     {
         var b = expr as CharsetNameExpression;
         if (!IsReservedCharsetName(b.Name) && !CharsetDefinitions.Any(x => x.Name == b.Name))
         {
             throw new GrammarException(b.Location, $"nome {{{b.Name}}} não declarado");
         }
     }
 }
Esempio n. 2
0
        private void ValidateNoRecursionCharset(CharsetExpression r, HashSet <string> stack)
        {
            if (r is CharsetNameExpression)
            {
                var rr = r as CharsetNameExpression;
                if (stack.Contains(rr.Name))
                {
                    throw new GrammarException(r.Location, $"recursão infinita para {{{rr.Name}}}");
                }

                stack.Add(rr.Name);
                if (IsReservedCharsetName(rr.Name))
                {
                    return;
                }
                ValidateNoRecursionCharset(CharsetDefinitions.First(x => x.Name == rr.Name).Expression, stack);
            }
            else if (r is CharsetBinaryExpression)
            {
                var b = r as CharsetBinaryExpression;
                ValidateNoRecursionCharset(b.Left, stack);
                ValidateNoRecursionCharset(b.Right, stack);
            }
        }
Esempio n. 3
0
 public CharsetBinaryExpression(CharsetBinaryOperator @operator, CharsetExpression left, CharsetExpression right, Location location) : base(location)
 {
     Operator = @operator;
     Left     = left;
     Right    = right;
 }
Esempio n. 4
0
 public CharsetDefinition(string name, CharsetExpression expression, Location location)
 {
     Name       = name;
     Expression = expression;
     Location   = location;
 }