Exemplo n.º 1
0
        private void untypedIdentifier(IdentifierNode identifierNode)
        {
            if (current is Character && current.Text == ":")
            {
                SyntaxNode entityNode =
                    new EntityNode(identifierNode.Text);
                identifierNode.ReplaceWith(entityNode);

                read();
            }
            else if ((current is Character && current.Text == "?") || current is Arrow || current is NewLine)
            {
                PropertyNode propertyNode = new PropertyNode(identifierNode.Text);
                identifierNode.ReplaceWith(propertyNode);

                modRequired(propertyNode);
                modForeignKey(propertyNode);
            }
            else
                throw new SyntaxException();
        }
Exemplo n.º 2
0
        private void statement(SyntaxNode parentNode)
        {
            if (current is Character && current.Text == "@")
            {
                read(); // @
                command(parentNode);
            }
            else if (current is Identifier)
            {
                IdentifierNode identifierNode =
                    new IdentifierNode(current.Text).AddTo(parentNode) as IdentifierNode; // can be an entity or a property

                read(); // identifier
                untypedIdentifier(identifierNode);
            }
            else if (current is Character && "$#&!".Contains(current.Text))
            {
                new PropTypeNode(current.Text.ToPropertyType()).AddTo(parentNode);
                propType();
                typedIdentifier(parentNode);
            }
            else if (current is Character && current.Text == "[")
            {
                read(); // [

                if (!(current is Identifier))
                    throw new SyntaxException();

                PropertyNode propertyName =
                    new PropertyNode(current.Text, true).AddTo(parentNode) as PropertyNode;

                read(); // identifier
                if (!(current is Character) || current.Text != "]")
                    throw new SyntaxException();

                read(); // ]
                modRequired(propertyName);
                modForeignKey(propertyName);
            }
            else
                throw new SyntaxException();
        }