Пример #1
0
        public override bool IsValidActionScope(GrammarType grammarType, string scope)
        {
            switch (scope)
            {
            case "all":
            case "token":
            case "module":
            case "overrides":
                return(true);

            default:
                break;
            }

            switch (grammarType)
            {
            case GrammarType.Lexer:
                return(scope == "lexer");

            case GrammarType.Parser:
                return(scope == "parser");

            case GrammarType.Combined:
                return((scope == "lexer") || (scope == "parser"));

            case GrammarType.TreeParser:
                return(scope == "treeparser");

            default:
                return(false);
            }
        }
Пример #2
0
        /** Is scope in @scope::name {action} valid for this kind of grammar?
         *  Targets like C++ may want to allow new scopes like headerfile or
         *  some such.  The action names themselves are not policed at the
         *  moment so targets can add template actions w/o having to recompile
         *  ANTLR.
         */
        public override bool IsValidActionScope(GrammarType grammarType, string scope)
        {
            switch (grammarType)
            {
            case GrammarType.Lexer:
                switch (scope)
                {
                case "lexer":
                case "header":
                case "includes":
                case "preincludes":
                case "overrides":
                    return(true);
                }

                break;

            case GrammarType.Parser:
                switch (scope)
                {
                case "parser":
                case "header":
                case "includes":
                case "preincludes":
                case "overrides":
                    return(true);
                }

                break;

            case GrammarType.Combined:
                switch (scope)
                {
                case "parser":
                case "lexer":
                case "header":
                case "includes":
                case "preincludes":
                case "overrides":
                    return(true);
                }

                break;

            case GrammarType.TreeParser:
                switch (scope)
                {
                case "treeparser":
                case "header":
                case "includes":
                case "preincludes":
                case "overrides":
                    return(true);
                }

                break;
            }

            return(false);
        }
Пример #3
0
        /** Is scope in @scope::name {action} valid for this kind of grammar?
         *  Targets like C++ may want to allow new scopes like headerfile or
         *  some such.  The action names themselves are not policed at the
         *  moment so targets can add template actions w/o having to recompile
         *  ANTLR.
         */
        public virtual bool IsValidActionScope(GrammarType grammarType, string scope)
        {
            switch (grammarType)
            {
            case GrammarType.Lexer:
                if (scope.Equals("lexer"))
                {
                    return(true);
                }

                break;

            case GrammarType.Parser:
                if (scope.Equals("parser"))
                {
                    return(true);
                }

                break;

            case GrammarType.Combined:
                if (scope.Equals("parser"))
                {
                    return(true);
                }

                if (scope.Equals("lexer"))
                {
                    return(true);
                }

                break;

            case GrammarType.TreeParser:
                if (scope.Equals("treeparser"))
                {
                    return(true);
                }

                break;
            }

            return(false);
        }
Пример #4
0
 // M I S C
 /** Generate TParser.java and TLexer.java from T.g if combined, else
  *  just use T.java as output regardless of type.
  */
 public virtual string GetRecognizerFileName( string name, GrammarType type )
 {
     StringTemplate extST = templates.GetInstanceOf( "codeFileExtension" );
     string recognizerName = grammar.GetRecognizerName();
     return recognizerName + extST.ToString();
     /*
     String suffix = "";
     if ( type==GrammarType.Combined ||
          (type==GrammarType.Lexer && !grammar.implicitLexer) )
     {
         suffix = Grammar.grammarTypeToFileNameSuffix[type];
     }
     return name+suffix+extST.toString();
     */
 }
Пример #5
0
        /** Is scope in @scope::name {action} valid for this kind of grammar?
         *  Targets like C++ may want to allow new scopes like headerfile or
         *  some such.  The action names themselves are not policed at the
         *  moment so targets can add template actions w/o having to recompile
         *  ANTLR.
         */
        public override bool IsValidActionScope(GrammarType grammarType, string scope)
        {
            switch (grammarType)
            {
            case GrammarType.Lexer:
                if (scope == "lexer")
                {
                    return(true);
                }
                if (scope == "header")
                {
                    return(true);
                }
                if (scope == "includes")
                {
                    return(true);
                }
                if (scope == "preincludes")
                {
                    return(true);
                }
                if (scope == "overrides")
                {
                    return(true);
                }
                if (scope == "namespace")
                {
                    return(true);
                }

                break;

            case GrammarType.Parser:
                if (scope == "parser")
                {
                    return(true);
                }
                if (scope == "header")
                {
                    return(true);
                }
                if (scope == "includes")
                {
                    return(true);
                }
                if (scope == "preincludes")
                {
                    return(true);
                }
                if (scope == "overrides")
                {
                    return(true);
                }
                if (scope == "namespace")
                {
                    return(true);
                }

                break;

            case GrammarType.Combined:
                if (scope == "parser")
                {
                    return(true);
                }
                if (scope == "lexer")
                {
                    return(true);
                }
                if (scope == "header")
                {
                    return(true);
                }
                if (scope == "includes")
                {
                    return(true);
                }
                if (scope == "preincludes")
                {
                    return(true);
                }
                if (scope == "overrides")
                {
                    return(true);
                }
                if (scope == "namespace")
                {
                    return(true);
                }

                break;

            case GrammarType.TreeParser:
                if (scope == "treeparser")
                {
                    return(true);
                }
                if (scope == "header")
                {
                    return(true);
                }
                if (scope == "includes")
                {
                    return(true);
                }
                if (scope == "preincludes")
                {
                    return(true);
                }
                if (scope == "overrides")
                {
                    return(true);
                }
                if (scope == "namespace")
                {
                    return(true);
                }
                break;
            }
            return(false);
        }
Пример #6
0
        public override bool IsValidActionScope(GrammarType grammarType, string scope)
        {
            switch (scope)
            {
            case "all":
            case "token":
            case "module":
            case "overrides":
                return true;

            default:
                break;
            }

            switch (grammarType)
            {
            case GrammarType.Lexer:
                return scope == "lexer";

            case GrammarType.Parser:
                return scope == "parser";

            case GrammarType.Combined:
                return (scope == "lexer") || (scope == "parser");

            case GrammarType.TreeParser:
                return scope == "treeparser";

            default:
                return false;
            }
        }
Пример #7
0
 /** Is scope in @scope::name {action} valid for this kind of grammar?
  *  Targets like C++ may want to allow new scopes like headerfile or
  *  some such.  The action names themselves are not policed at the
  *  moment so targets can add template actions w/o having to recompile
  *  ANTLR.
  */
 public virtual bool IsValidActionScope( GrammarType grammarType, string scope )
 {
     switch ( grammarType )
     {
     case GrammarType.Lexer:
         if ( scope.Equals( "lexer" ) )
         {
             return true;
         }
         break;
     case GrammarType.Parser:
         if ( scope.Equals( "parser" ) )
         {
             return true;
         }
         break;
     case GrammarType.Combined:
         if ( scope.Equals( "parser" ) )
         {
             return true;
         }
         if ( scope.Equals( "lexer" ) )
         {
             return true;
         }
         break;
     case GrammarType.TreeParser:
         if ( scope.Equals( "treeparser" ) )
         {
             return true;
         }
         break;
     }
     return false;
 }
Пример #8
0
        /** Is scope in @scope::name {action} valid for this kind of grammar?
         *  Targets like C++ may want to allow new scopes like headerfile or
         *  some such.  The action names themselves are not policed at the
         *  moment so targets can add template actions w/o having to recompile
         *  ANTLR.
         */
        public override bool IsValidActionScope(GrammarType grammarType, string scope)
        {
            switch (grammarType)
            {
            case GrammarType.Lexer:
                if (scope == "lexer")
                {
                    return true;
                }
                if (scope == "header")
                {
                    return true;
                }
                if (scope == "includes")
                {
                    return true;
                }
                if (scope == "preincludes")
                {
                    return true;
                }
                if (scope == "overrides")
                {
                    return true;
                }
                if (scope == "namespace")
                {
                    return true;
                }

                break;
            case GrammarType.Parser:
                if (scope == "parser")
                {
                    return true;
                }
                if (scope == "header")
                {
                    return true;
                }
                if (scope == "includes")
                {
                    return true;
                }
                if (scope == "preincludes")
                {
                    return true;
                }
                if (scope == "overrides")
                {
                    return true;
                }
                if (scope == "namespace")
                {
                    return true;
                }

                break;
            case GrammarType.Combined:
                if (scope == "parser")
                {
                    return true;
                }
                if (scope == "lexer")
                {
                    return true;
                }
                if (scope == "header")
                {
                    return true;
                }
                if (scope == "includes")
                {
                    return true;
                }
                if (scope == "preincludes")
                {
                    return true;
                }
                if (scope == "overrides")
                {
                    return true;
                }
                if (scope == "namespace")
                {
                    return true;
                }

                break;
            case GrammarType.TreeParser:
                if (scope == "treeparser")
                {
                    return true;
                }
                if (scope == "header")
                {
                    return true;
                }
                if (scope == "includes")
                {
                    return true;
                }
                if (scope == "preincludes")
                {
                    return true;
                }
                if (scope == "overrides")
                {
                    return true;
                }
                if (scope == "namespace")
                {
                    return true;
                }
                break;
            }
            return false;
        }
Пример #9
0
        /** Is scope in @scope::name {action} valid for this kind of grammar?
         *  Targets like C++ may want to allow new scopes like headerfile or
         *  some such.  The action names themselves are not policed at the
         *  moment so targets can add template actions w/o having to recompile
         *  ANTLR.
         */
        public override bool IsValidActionScope( GrammarType grammarType, string scope )
        {
            switch ( grammarType )
            {
            case GrammarType.Lexer:
                switch ( scope )
                {
                case "lexer":
                case "header":
                case "includes":
                case "preincludes":
                case "overrides":
                    return true;
                }

                break;

            case GrammarType.Parser:
                switch ( scope )
                {
                case "parser":
                case "header":
                case "includes":
                case "preincludes":
                case "overrides":
                    return true;
                }

                break;

            case GrammarType.Combined:
                switch ( scope )
                {
                case "parser":
                case "lexer":
                case "header":
                case "includes":
                case "preincludes":
                case "overrides":
                    return true;
                }

                break;

            case GrammarType.TreeParser:
                switch ( scope )
                {
                case "treeparser":
                case "header":
                case "includes":
                case "preincludes":
                case "overrides":
                    return true;
                }

                break;
            }

            return false;
        }