Ejemplo n.º 1
0
        public override object Visit(CardinalType that, object value)
        {
            var result = (System.Text.StringBuilder) value;

            // Output type specifier.
            result.Append('u');         // 'u' for unsigned as 'c' is used for 'character'

            // Output width specifier.
            #if FEATURE_SCALAR_WIDTH
            char width;
            switch (that.Width)
            {
                case   0: width = '0'; break;
                case   8: width = '1'; break;
                case  16: width = '2'; break;
                case  32: width = '3'; break;
                case  64: width = '4'; break;
                case 128: width = '5'; break;
                case 256: width = '6'; break;
                default :
                    throw new System.Exception("Invalid scalar width encountered: " + that.Width.ToString());
            }
            result.Append(width);
            #else
            result.Append('0');
            #endif

            return null;
        }
        public override object Visit(CardinalType that, object value = null)
        {
            PrintPrologue(that);
            _writer.WriteLine("TypeKind = {0}", that.TypeKind.ToString());
            #if FEATURE_SCALAR_WIDTH
            _writer.WriteLine("Width = {0}", that.Width);
            #endif
            PrintEpilogue(that);

            return null;
        }
Ejemplo n.º 3
0
 public override object Visit(CardinalType that, object value)
 {
     _writer.Write("cardinal");
     return null;
 }
Ejemplo n.º 4
0
 public override void Given()
 {
     this.X = 2;
     this.Y = 3;
     this.Cardinal = CardinalType.W;
     this.Rover = new Rover { X = this.X, Y = this.Y, Cardinal = this.Cardinal };
 }
Ejemplo n.º 5
0
 public override object Visit(CardinalType that, object value = null)
 {
     return null;
 }
Ejemplo n.º 6
0
        /** Parses the reserved entry profile: <tt>entry Name(system is !Braceless.System) is boolean/cardinal:</tt>. */
        private Profile ParseEntryProfile()
        {
            // parse: "("
            Token start = _matcher.Match(TokenKind.ParenthesisBegin);

            // parse 'system' parameter name
            var parameters = new List<Parameter>();
            #if DONE
            Parameter parameter = ParseParameter();
            parameters.Add(parameter);
            #endif
            // parse: ")"
            _matcher.Match(TokenKind.ParenthesisClose);
            #if DONE
            // check that we actually parsed "!Braceless.System"
            if (parameter.Name.Symbol != "system")
                throw new ParserError(parameter.Cursor, "Expected predefined parameter name 'system'");

            /** \todo Check that the argument was "system is !Braceless.System". */
            bool invalid = false;
            if (!invalid)
                invalid = (parameter.Direction != DirectionKind.In);
            if (!invalid)
                invalid = (parameter.Type.Kind != NodeKind.NamedType);
            if (!invalid)
                invalid = (((NamedType) parameter.Type).Reference.PathKind != PathKind.Absolute);
            if (invalid)
                throw new ParserError(parameter.Type.Cursor, "Expected predefined parameter type '!Braceless.System'");
            #endif
            // Parse implicit return type (boolean or cardinal).
            _matcher.Match(TokenKind.Space);
            _matcher.Match(TokenKind.Keyword_Is);
            _matcher.Match(TokenKind.Space);

            Type type;
            Token token = _matcher.Read();
            #if DONE
            if (token.Kind == TokenKind.Keyword_Boolean)
                type = new BooleanType(token.Cursor);
            else
            #endif
            if (token.Kind == TokenKind.Keyword_Cardinal)
                type = new CardinalType(token.Cursor);
            else
                throw new ParserError(token.Cursor, "Expected boolean or integer return type of entry point");

            _matcher.Match(TokenKind.Colon);
            _matcher.Match(TokenKind.EndOfLine);

            return new Profile(start.Cursor, type, parameters.ToArray());
        }
Ejemplo n.º 7
0
        /** Parses an \c enumeration definition. */
        private EnumerationStatement ParseEnumerationStatement()
        {
            Token start = _matcher.Match(TokenKind.Keyword_Enumeration);
            _matcher.Match(TokenKind.Space);
            SymbolDefinition name = ParseSymbolDefinition(SymbolKind.Enumeration);
            _matcher.Match(TokenKind.Colon);
            _matcher.Match(TokenKind.EndOfLine);

            _matcher.Match(TokenKind.Indent);
            var values = new List<EnumerateStatement>();
            uint index = 1;
            do
            {
                _matcher.Match(TokenKind.Keyword_Value);
                _matcher.Match(TokenKind.Space);
                SymbolDefinition value = ParseSymbolDefinition(SymbolKind.Enumerate);
                System.Diagnostics.Debug.Assert(value != null);
                _matcher.Match(TokenKind.EndOfLine);

                values.Add(new EnumerateStatement(value.Cursor, value, index++));
            } while (_matcher.This.Kind == TokenKind.Keyword_Value);
            _matcher.Match(TokenKind.Dedent);

            Type type = new CardinalType(start.Cursor);

            return new EnumerationStatement(start.Cursor, name, type, values.ToArray());
        }
Ejemplo n.º 8
0
 public virtual object Visit(CardinalType that, object value)
 {
     throw new System.NotImplementedException();
 }