Ejemplo n.º 1
0
        public override object?VisitDecl_const([NotNull] LogicScriptParser.Decl_constContext context)
        {
            var value = new ExpressionVisitor(new BlockContext(Context, true)).Visit(context.expression());

            if (!value.IsConstant)
            {
                Errors.AddError("Const declarations must have a constant value", value);
            }

            Context.Constants.Add(context.IDENT().GetText(), value);
            return(null);
        }
Ejemplo n.º 2
0
    internal override ComponentNode? Parse()
    {
        var keyWordComponent = Take(TokenType.KwComponent);
        var id = ParserIdentifier();
        if (id is null) return null;
        var fields = new List<ArchitectureField>();
        
        var equals = TakeWithoutSpace(TokenType.Equals);
        if (equals is null) return new ComponentNode(id, fields);

        while (_hasField())
        {
            Take(TokenType.NewLine);
            Take(TokenType.Indent);
            var fieldId = Take(TokenType.Identifier);
            if (fieldId is null)
            {
                ErrorSink.AddError(Current ?? Token.Default, ErrorType.InvalidIdentifier,
                    $"A field should have an Identifier.");
                continue;
            }
            
            TakeWithoutSpace(TokenType.Colon);

            var root = Take() ?? Token.Default;
            while (_stillInFieldDefinition())
            {
                if (Current == TokenType.Indent) Take();
                else root = root.Append(Take());
            }
            
            fields.Add(new ArchitectureField(fieldId, root));
        }

        return new ComponentNode(id, fields);
    }
Ejemplo n.º 3
0
 private void AddError(Severity severity, string message, SourceSpan?span = null)
 {
     _errorSink.AddError(message, _sourceCode, severity, span ?? CreateSpan(_current));
 }
        private void AddError(string message, Severity severity)
        {
            var span = new SourceSpan(tokenStart, new SourceLocation(index, line, column));

            errorSink.AddError(message, sourceCode, severity, span);
        }
 public void AddError(Severity severity, string mes, SourceSpan?span = null)
 {
     errorSink.AddError(mes, sourceCode, severity, span ?? CreateSpan(currentToken));
 }