コード例 #1
0
ファイル: Writer.cs プロジェクト: archfrog/Braceless0
 public override object Visit(NoneLiteral that, object value)
 {
     _writer.Write("none");
     return null;
 }
コード例 #2
0
ファイル: Writer.cs プロジェクト: archfrog/Braceless0
 public override object Visit(NoneLiteral that, object value)
 {
     /** \todo Output the default initializer for none types. */
     return new ImmediateStorage("null");
 }
コード例 #3
0
        public override object Visit(NoneLiteral that, object value = null)
        {
            PrintPrologue(that);
            PrintNodeId("Type", that.Type);
            PrintEpilogue(that);

            that.Type.Visit(this);

            return null;
        }
コード例 #4
0
 public override object Visit(NoneLiteral that, object value = null)
 {
     return null;
 }
コード例 #5
0
ファイル: Parser.cs プロジェクト: archfrog/Braceless0
        /** Parses an \c array type specifier. */
        private ArrayType ParseArrayType()
        {
            Token start = _matcher.Match(TokenKind.Keyword_Array);
            _matcher.Match(TokenKind.Space);
            Expression bound = null;
            if (_matcher.This.Kind == TokenKind.BracketBegin)
            {
                _matcher.Match(TokenKind.BracketBegin);
                bound = ParseExpression();
                _matcher.Match(TokenKind.BracketClose);
                _matcher.Match(TokenKind.Space);
            }
            else
                bound = new NoneLiteral(_matcher.This.Cursor, new NoneType(_matcher.This.Cursor));
            _matcher.Match(TokenKind.Keyword_Of);
            _matcher.Match(TokenKind.Space);
            Type type = ParseType();

            return new ArrayType(start.Cursor, type, bound);
        }
コード例 #6
0
ファイル: Parser.cs プロジェクト: archfrog/Braceless0
        /** Parses a value (data member) definition. */
        private ValueStatement ParseValueStatement()
        {
            Token start = _matcher.Match(TokenKind.Keyword_Value);
            _matcher.Match(TokenKind.Space);
            SymbolDefinition name = ParseSymbolDefinition(SymbolKind.Value);
            _matcher.Match(TokenKind.Space);
            _matcher.Match(TokenKind.Keyword_Is);
            _matcher.Match(TokenKind.Space);
            Type type = ParseType();

            Expression initializer = null;
            if (_matcher.This.Kind != TokenKind.EndOfLine)
            {
                _matcher.Match(TokenKind.Space);
                _matcher.Match(TokenKind.Assign_Identity);
                _matcher.Match(TokenKind.Space);
                initializer = ParseExpression();
            }
            else
                initializer = new NoneLiteral(_matcher.This.Cursor, new NoneType(_matcher.This.Cursor));

            _matcher.Match(TokenKind.EndOfLine);

            return new ValueStatement(start.Cursor, name, type, initializer);
        }
コード例 #7
0
ファイル: Parser.cs プロジェクト: archfrog/Braceless0
        /** Parses a \c create statement, which introduces a new symbol name in the current scope. */
        private CreateStatement ParseCreateStatement()
        {
            Token start = _matcher.This;

            _matcher.Match(TokenKind.Keyword_Create);
            _matcher.Match(TokenKind.Space);

            Token token = _matcher.Match(TokenKind.Name);
            var name = new SymbolDefinition(token.Cursor, token.Text, SymbolKind.Variable);

            Type type = null;
            if (_matcher.This.Kind == TokenKind.Space && _matcher.Next.Kind == TokenKind.Keyword_Is)
            {
                _matcher.Match(TokenKind.Space);
                _matcher.Match(TokenKind.Keyword_Is);
                _matcher.Match(TokenKind.Space);
                type = ParseType();
            }

            Expression initializer = null;
            if (_matcher.This.Kind == TokenKind.Space && _matcher.Next.Kind == TokenKind.Assign_Identity)
            {
                _matcher.Match(TokenKind.Space);
                _matcher.Match(TokenKind.Assign_Identity);
                _matcher.Match(TokenKind.Space);
                initializer = ParseExpression();
            }

            _matcher.Match(TokenKind.EndOfLine);

            if (type == null && initializer == null)
                throw new ParserError(name.Cursor, "Expected type and/or initalizer");

            if (type == null)
                type = new UnknownType(name.Cursor);
            if (initializer == null)
                initializer = new NoneLiteral(name.Cursor, new NoneType(name.Cursor));

            return new CreateStatement(start.Cursor, name, type, initializer);
        }
コード例 #8
0
ファイル: Visitor.cs プロジェクト: archfrog/Braceless0
 public virtual object Visit(NoneLiteral that, object value)
 {
     throw new System.NotImplementedException();
 }