예제 #1
0
        public ExceptionRules(PieGrammar grammar)
        {
            this.grammar = grammar;

            ExceptionHandlingBlock = new NonTerminal("exception_handling_block");
            ThrowStatement         = new NonTerminal("throw_statement");
        }
예제 #2
0
        public WhileLoopRules(PieGrammar grammar)
        {
            this.grammar = grammar;

            SimpleWhileLoop = new NonTerminal("simple_while_loop");
            BodiedWhileLoop = new NonTerminal("bodied_while_loop");
        }
예제 #3
0
        public ListRules(PieGrammar grammar)
        {
            this.grammar = grammar;

            StarIdentifierList = new NonTerminal("star_identifer_list");
            PlusIdentifierList = new NonTerminal("plus_identfier_list");
        }
예제 #4
0
        public ExceptionRules(PieGrammar grammar)
        {
            this.grammar = grammar;

            ExceptionHandlingBlock = new NonTerminal("exception_handling_block");
            ThrowStatement = new NonTerminal("throw_statement");
        }
예제 #5
0
        public ForLoopRules(PieGrammar grammar)
        {
            this.grammar = grammar;

            SimpleForLoop = new NonTerminal("simple_for_loop");
            BodiedForLoop = new NonTerminal("bodied_for_loop");
        }
예제 #6
0
        public ListRules(PieGrammar grammar)
        {
            this.grammar = grammar;

            StarIdentifierList = new NonTerminal("star_identifer_list");
            PlusIdentifierList = new NonTerminal("plus_identfier_list");
        }
예제 #7
0
        public ForLoopRules(PieGrammar grammar)
        {
            this.grammar = grammar;

            SimpleForLoop = new NonTerminal("simple_for_loop");
            BodiedForLoop = new NonTerminal("bodied_for_loop");
        }
예제 #8
0
        public WhileLoopRules(PieGrammar grammar)
        {
            this.grammar = grammar;

            SimpleWhileLoop = new NonTerminal("simple_while_loop");
            BodiedWhileLoop = new NonTerminal("bodied_while_loop");
        }
예제 #9
0
        public PieScanner(IVsTextBuffer buffer)
        {
            m_buffer = buffer;

            grammar = new PieGrammar();
            parser = new Irony.Parsing.Parser(grammar);
            parser.Context.Mode = Irony.Parsing.ParseMode.VsLineScan;
        }
예제 #10
0
        public IfBlockRules(PieGrammar grammar)
        {
            this.grammar = grammar;

            SimpleIfBlock = new NonTerminal("simple_if_block");
            BodiedIfBlock = new NonTerminal("bodied_if_block");
            SimpleElseBlock = new NonTerminal("simple_else_block");
            BodiedElseBlock = new NonTerminal("bodied_else_block");
        }
예제 #11
0
        public IfBlockRules(PieGrammar grammar)
        {
            this.grammar = grammar;

            SimpleIfBlock   = new NonTerminal("simple_if_block");
            BodiedIfBlock   = new NonTerminal("bodied_if_block");
            SimpleElseBlock = new NonTerminal("simple_else_block");
            BodiedElseBlock = new NonTerminal("bodied_else_block");
        }
예제 #12
0
        public MethodDeclarationRules(PieGrammar grammar)
        {
            this.grammar = grammar;

            MethodDeclaration  = new NonTerminal("method_declaration");
            OptionalMethodBody = new NonTerminal("optional_method_body");
            Modifier           = new NonTerminal("method_modifiers");
            MemberHeader       = new NonTerminal("member_header");
            ParameterList      = new NonTerminal("parameter_list");
        }
예제 #13
0
        public MethodDeclarationRules(PieGrammar grammar)
        {
            this.grammar = grammar;

            MethodDeclaration = new NonTerminal("method_declaration");
            OptionalMethodBody = new NonTerminal("optional_method_body");
            Modifier = new NonTerminal("method_modifiers");
            MemberHeader = new NonTerminal("member_header");
            ParameterList = new NonTerminal("parameter_list");
        }
예제 #14
0
        public NamespaceRules(PieGrammar grammar)
        {
            this.grammar = grammar;

            Import = new NonTerminal("import");

            NamespaceDeclaration  = new NonTerminal("namespace");
            NamespaceBody         = new NonTerminal("namespace_body");
            NamespaceValidMembers = new NonTerminal("namespace_valid_members");
            NamespaceMembersList  = new NonTerminal("namespace_members_list");
        }
예제 #15
0
        public NamespaceRules(PieGrammar grammar)
        {
            this.grammar = grammar;

            Import = new NonTerminal("import");

            NamespaceDeclaration = new NonTerminal("namespace");
            NamespaceBody = new NonTerminal("namespace_body");
            NamespaceValidMembers = new NonTerminal("namespace_valid_members");
            NamespaceMembersList = new NonTerminal("namespace_members_list");
        }
예제 #16
0
        // Declare the public rules.
        public ClassRules(PieGrammar grammar)
        {
            this.grammar = grammar;


            Modifier = new NonTerminal("class_modifier");

            ClassVariableModifierList = new NonTerminal("ClassVariableModifier");
            GenericTypeListOpt        = new NonTerminal("generic_list_opt");
            ClassDeclaration          = new NonTerminal("class_declaration");

            GenericTypeList = new NonTerminal("generic_type_list");

            BaseTypeListOpt = new NonTerminal("base_list_opt");
        }
예제 #17
0
        public LiteralRules(PieGrammar grammar)
        {
            this.grammar = grammar;

            NumberLiteral = new NumberLiteral("number_literal", NumberOptions.AllowStartEndDot)
            {
                // Define types to assign if the parser can't determine.
                DefaultIntTypes  = new[] { TypeCode.Int32 },
                DefaultFloatType = TypeCode.Double
            };

            // The pre and post fixes for different number types and formats.
            NumberLiteral.AddPrefix("0x", NumberOptions.Hex);
            NumberLiteral.AddSuffix("b", TypeCode.Byte);
            NumberLiteral.AddSuffix("B", TypeCode.Byte);
            NumberLiteral.AddSuffix("s", TypeCode.Int16);
            NumberLiteral.AddSuffix("S", TypeCode.Int16);
            NumberLiteral.AddSuffix("u", TypeCode.UInt32);
            NumberLiteral.AddSuffix("U", TypeCode.UInt32);
            NumberLiteral.AddSuffix("us", TypeCode.UInt16);
            NumberLiteral.AddSuffix("US", TypeCode.UInt16);
            NumberLiteral.AddSuffix("l", TypeCode.Int64);
            NumberLiteral.AddSuffix("L", TypeCode.Int64);
            NumberLiteral.AddSuffix("ul", TypeCode.UInt64);
            NumberLiteral.AddSuffix("UL", TypeCode.UInt64);
            NumberLiteral.AddSuffix("F", TypeCode.Single);
            NumberLiteral.AddSuffix("f", TypeCode.Single);
            NumberLiteral.AddSuffix("d", TypeCode.Double);
            NumberLiteral.AddSuffix("D", TypeCode.Double);
            NumberLiteral.AddSuffix("m", TypeCode.Decimal);
            NumberLiteral.AddSuffix("M", TypeCode.Decimal);

            StringLiteral = new StringLiteral("string_literal", "\"", StringOptions.AllowsAllEscapes);

            CharLiteral = new StringLiteral("char_literal", "'", StringOptions.IsChar);

            BoolLiteral      = new NonTerminal("bool_literal");
            BoolLiteral.Rule = grammar.Keywords.True | grammar.Keywords.False;

            Null = grammar.ToTerm("null", "null_literal");
        }
예제 #18
0
        public LiteralRules(PieGrammar grammar)
        {
            this.grammar = grammar;

            NumberLiteral  = new NumberLiteral("number_literal", NumberOptions.AllowStartEndDot)
            {
                // Define types to assign if the parser can't determine.
                DefaultIntTypes = new[] { TypeCode.Int32 },
                DefaultFloatType = TypeCode.Double
            };

            // The pre and post fixes for different number types and formats.
            NumberLiteral.AddPrefix("0x", NumberOptions.Hex);
            NumberLiteral.AddSuffix("b", TypeCode.Byte);
            NumberLiteral.AddSuffix("B", TypeCode.Byte);
            NumberLiteral.AddSuffix("s", TypeCode.Int16);
            NumberLiteral.AddSuffix("S", TypeCode.Int16);
            NumberLiteral.AddSuffix("u", TypeCode.UInt32);
            NumberLiteral.AddSuffix("U", TypeCode.UInt32);
            NumberLiteral.AddSuffix("us", TypeCode.UInt16);
            NumberLiteral.AddSuffix("US", TypeCode.UInt16);
            NumberLiteral.AddSuffix("l", TypeCode.Int64);
            NumberLiteral.AddSuffix("L", TypeCode.Int64);
            NumberLiteral.AddSuffix("ul", TypeCode.UInt64);
            NumberLiteral.AddSuffix("UL", TypeCode.UInt64);
            NumberLiteral.AddSuffix("F", TypeCode.Single);
            NumberLiteral.AddSuffix("f", TypeCode.Single);
            NumberLiteral.AddSuffix("d", TypeCode.Double);
            NumberLiteral.AddSuffix("D", TypeCode.Double);
            NumberLiteral.AddSuffix("m", TypeCode.Decimal);
            NumberLiteral.AddSuffix("M", TypeCode.Decimal);

            StringLiteral = new StringLiteral("string_literal", "\"", StringOptions.AllowsAllEscapes);

            CharLiteral = new StringLiteral("char_literal", "'", StringOptions.IsChar);

            BoolLiteral = new NonTerminal("bool_literal");
            BoolLiteral.Rule = grammar.Keywords.True | grammar.Keywords.False;

            Null = grammar.ToTerm("null", "null_literal");
        }
예제 #19
0
        public OperatorRules(PieGrammar grammar)
        {
            this.grammar = grammar;

            ValidBinaryOperators = new NonTerminal("binary_operators");
            BinaryOperator       = new NonTerminal("binary_operator");
            ValidUnaryOperators  = new NonTerminal("valid_unary_operators");
            UnaryOperator        = new NonTerminal("unary_operator");
            Multiply             = grammar.ToTerm("*");
            Modulo            = grammar.ToTerm("%");
            Divide            = grammar.ToTerm("/");
            Add               = grammar.ToTerm("+");
            Subtract          = grammar.ToTerm("-");
            LessOrEqual       = grammar.ToTerm("<=");
            GreaterOrEqual    = grammar.ToTerm(">=");
            Greater           = grammar.ToTerm(">");
            Less              = grammar.ToTerm("<");
            Equal             = grammar.ToTerm("==");
            NotEqual          = grammar.ToTerm("!=");
            Assignment        = new NonTerminal("assignment");
            EqualsAssignment  = grammar.ToTerm("=");
            BitwiseAnd        = grammar.ToTerm("&");
            BitwiseXor        = grammar.ToTerm("^");
            BitwiseOr         = grammar.ToTerm("|");
            BitwiseShiftLeft  = grammar.ToTerm("<<");
            BitwiseShiftRight = grammar.ToTerm(">>");
            Not               = grammar.ToTerm("!");
            Negate            = grammar.ToTerm("-");
            As                 = grammar.ToTerm("as");
            AddAssignment      = grammar.ToTerm("+=");
            SubtractAssignment = grammar.ToTerm("-=");
            DivideAssignment   = grammar.ToTerm("/=");
            MultiplyAssignment = grammar.ToTerm("*=");
            OrAssignment       = grammar.ToTerm("|=");
            AndAssignment      = grammar.ToTerm("&=");
            XorAssignment      = grammar.ToTerm("^=");
        }
예제 #20
0
        public OperatorRules(PieGrammar grammar)
        {
            this.grammar = grammar;

            ValidBinaryOperators = new NonTerminal("binary_operators");
            BinaryOperator = new NonTerminal("binary_operator");
            ValidUnaryOperators = new NonTerminal("valid_unary_operators");
            UnaryOperator = new NonTerminal("unary_operator");
            Multiply = grammar.ToTerm("*");
            Modulo = grammar.ToTerm("%");
            Divide = grammar.ToTerm("/");
            Add = grammar.ToTerm("+");
            Subtract = grammar.ToTerm("-");
            LessOrEqual = grammar.ToTerm("<=");
            GreaterOrEqual = grammar.ToTerm(">=");
            Greater = grammar.ToTerm(">");
            Less = grammar.ToTerm("<");
            Equal = grammar.ToTerm("==");
            NotEqual = grammar.ToTerm("!=");
            Assignment = new NonTerminal("assignment");
            EqualsAssignment = grammar.ToTerm("=");
            BitwiseAnd = grammar.ToTerm("&");
            BitwiseXor = grammar.ToTerm("^");
            BitwiseOr = grammar.ToTerm("|");
            BitwiseShiftLeft = grammar.ToTerm("<<");
            BitwiseShiftRight = grammar.ToTerm(">>");
            Not = grammar.ToTerm("!");
            Negate = grammar.ToTerm("-");
            As = grammar.ToTerm("as");
            AddAssignment = grammar.ToTerm("+=");
            SubtractAssignment = grammar.ToTerm("-=");
            DivideAssignment = grammar.ToTerm("/=");
            MultiplyAssignment = grammar.ToTerm("*=");
            OrAssignment = grammar.ToTerm("|=");
            AndAssignment = grammar.ToTerm("&=");
            XorAssignment = grammar.ToTerm("^=");
        }
예제 #21
0
        public EnumRules(PieGrammar grammar)
        {
            this.grammar = grammar;

            EnumDeclaration = new NonTerminal("enum_declaration");
        }
예제 #22
0
        public EnumRules(PieGrammar grammar)
        {
            this.grammar = grammar;

            EnumDeclaration = new NonTerminal("enum_declaration");
        }
예제 #23
0
        public SwitchRules(PieGrammar grammar)
        {
            this.grammar = grammar;

            SwitchBlock = new NonTerminal("switch_block");
        }
예제 #24
0
 public DelegateRules(PieGrammar grammar)
 {
     this.grammar = grammar;
     DelegateDeclaration = new NonTerminal("delegate_declaration");
     EventMember = new NonTerminal("event_member");
 }
예제 #25
0
        public PropertyRules(PieGrammar grammar)
        {
            this.grammar = grammar;

            PropertyDeclaration = new NonTerminal("property_declaration");
        }
예제 #26
0
        public KeywordRules(PieGrammar grammar)
        {
            this.grammar = grammar;

            Partial = grammar.ToTerm("partial");

            Import = grammar.ToTerm("import");

            Public = grammar.ToTerm("public");

            Private = grammar.ToTerm("private");

            Internal = grammar.ToTerm("internal");

            Protected = grammar.ToTerm("protected");

            Final = grammar.ToTerm("final");

            NamespaceKeyword = grammar.ToTerm("namespace");

            Module = grammar.ToTerm("module");

            Class = grammar.ToTerm("class");

            Struct = grammar.ToTerm("struct");

            Enum = grammar.ToTerm("enum");

            As = grammar.ToTerm("as");

            Of = grammar.ToTerm("of");

            Abstract = grammar.ToTerm("abstract");

            And = grammar.ToTerm("&&");

            Or = grammar.ToTerm("||");

            If = grammar.ToTerm("if");

            Else = grammar.ToTerm("else");

            Shared = grammar.ToTerm("shared");

            Def = grammar.ToTerm("def");

            Virtual = grammar.ToTerm("virtual");

            Override = grammar.ToTerm("override");

            For  = grammar.ToTerm("for");
            Step = grammar.ToTerm("step");

            While = grammar.ToTerm("while");

            In = grammar.ToTerm("in");
            To = grammar.ToTerm("to");

            True  = grammar.ToTerm("true");
            False = grammar.ToTerm("false");

            Ref = grammar.ToTerm("ref");
            Out = grammar.ToTerm("out");

            New   = grammar.ToTerm("new");
            Super = grammar.ToTerm("super");

            Get = grammar.ToTerm("get");
            Set = grammar.ToTerm("set");

            Value = grammar.ToTerm("value");

            Try     = grammar.ToTerm("try");
            Catch   = grammar.ToTerm("catch");
            Finally = grammar.ToTerm("finally");
            Throw   = grammar.ToTerm("throw");

            Switch = grammar.ToTerm("switch");
            Case   = grammar.ToTerm("case");
            Break  = grammar.ToTerm("break");

            Delegate = grammar.ToTerm("delegate");
            Event    = grammar.ToTerm("event");

            Interface = grammar.ToTerm("interface");

            Var = grammar.ToTerm("var");

            // Mark them as "reserved" so that the parser can tell the syntax highlighter how to color them in the IDE.
            grammar.MarkReservedWords("partial", "import", "public", "private", "internal", "protected", "def", "shared", "virtual", "enum");
            grammar.MarkReservedWords("final", "namespace", "class", "module", "struct", "as", "of", "abstract", "and", "or", "if", "else");
            grammar.MarkReservedWords("for", "step", "true", "false", "in", "to", "while", "const", "new", "base", "this");
            grammar.MarkReservedWords("override", "get", "set", "value", "try", "catch", "finally", "throw", "switch", "case", "break");
            grammar.MarkReservedWords("delegate", "event", "interface", "var");
        }
예제 #27
0
        public PropertyRules(PieGrammar grammar)
        {
            this.grammar = grammar;

            PropertyDeclaration = new NonTerminal("property_declaration");
        }
예제 #28
0
        public KeywordRules(PieGrammar grammar)
        {
            this.grammar = grammar;

            Partial = grammar.ToTerm("partial");

            Import = grammar.ToTerm("import");

            Public = grammar.ToTerm("public");

            Private = grammar.ToTerm("private");

            Internal = grammar.ToTerm("internal");

            Protected = grammar.ToTerm("protected");

            Final = grammar.ToTerm("final");

            NamespaceKeyword = grammar.ToTerm("namespace");

            Module = grammar.ToTerm("module");

            Class = grammar.ToTerm("class");

            Struct = grammar.ToTerm("struct");

            Enum = grammar.ToTerm("enum");

            As = grammar.ToTerm("as");

            Of = grammar.ToTerm("of");

            Abstract = grammar.ToTerm("abstract");

            And = grammar.ToTerm("&&");

            Or = grammar.ToTerm("||");

            If = grammar.ToTerm("if");

            Else = grammar.ToTerm("else");

            Shared = grammar.ToTerm("shared");

            Def = grammar.ToTerm("def");

            Virtual = grammar.ToTerm("virtual");

            Override = grammar.ToTerm("override");

            For = grammar.ToTerm("for");
            Step = grammar.ToTerm("step");

            While = grammar.ToTerm("while");

            In = grammar.ToTerm("in");
            To = grammar.ToTerm("to");

            True = grammar.ToTerm("true");
            False = grammar.ToTerm("false");

            Ref = grammar.ToTerm("ref");
            Out = grammar.ToTerm("out");

            New = grammar.ToTerm("new");
            Super = grammar.ToTerm("super");

            Get = grammar.ToTerm("get");
            Set = grammar.ToTerm("set");

            Value = grammar.ToTerm("value");

            Try = grammar.ToTerm("try");
            Catch = grammar.ToTerm("catch");
            Finally = grammar.ToTerm("finally");
            Throw = grammar.ToTerm("throw");

            Switch = grammar.ToTerm("switch");
            Case = grammar.ToTerm("case");
            Break = grammar.ToTerm("break");

            Delegate = grammar.ToTerm("delegate");
            Event = grammar.ToTerm("event");

            Interface = grammar.ToTerm("interface");

            Var = grammar.ToTerm("var");

            // Mark them as "reserved" so that the parser can tell the syntax highlighter how to color them in the IDE.
            grammar.MarkReservedWords("partial", "import", "public", "private", "internal", "protected", "def", "shared", "virtual", "enum");
            grammar.MarkReservedWords("final", "namespace", "class", "module", "struct", "as", "of", "abstract", "and", "or", "if", "else");
            grammar.MarkReservedWords("for", "step", "true", "false", "in", "to", "while", "const", "new", "base", "this");
            grammar.MarkReservedWords("override", "get", "set", "value", "try", "catch", "finally", "throw", "switch", "case", "break");
            grammar.MarkReservedWords("delegate", "event", "interface", "var");
        }
예제 #29
0
        public InterfaceRules(PieGrammar grammar)
        {
            this.grammar = grammar;

            InterfaceDeclaration = new NonTerminal("interface_declaration");
        }
예제 #30
0
        public ConstructorRules(PieGrammar grammar)
        {
            this.grammar = grammar;

            ConstructorDeclaration = new NonTerminal("constructor_declaration");
        }
예제 #31
0
        public SwitchRules(PieGrammar grammar)
        {
            this.grammar = grammar;

            SwitchBlock = new NonTerminal("switch_block");
        }
예제 #32
0
        public InterfaceRules(PieGrammar grammar)
        {
            this.grammar = grammar;

            InterfaceDeclaration = new NonTerminal("interface_declaration");
        }
예제 #33
0
 public DelegateRules(PieGrammar grammar)
 {
     this.grammar        = grammar;
     DelegateDeclaration = new NonTerminal("delegate_declaration");
     EventMember         = new NonTerminal("event_member");
 }
예제 #34
0
        public ConstructorRules(PieGrammar grammar)
        {
            this.grammar = grammar;

            ConstructorDeclaration = new NonTerminal("constructor_declaration");
        }