Beispiel #1
0
        static public void Apply(ExcessCompiler compiler)
        {
            var lexical = compiler.Lexical();
            var syntax  = compiler.Syntax();

            lexical
            //methods
            .match()
            .token("method", named: "keyword")
            .identifier(named: "id")
            .enclosed('(', ')')
            .token('{')
            .then(lexical.transform()
                  .remove("keyword")
                  .then(Method, referenceToken: "id"))

            //properties
            .match()
            .token("property")
            .identifier(named: "id")
            .token("=")
            .then(Property)

            .match()
            .token("property", named: "keyword")
            .identifier(named: "id")
            .then(lexical.transform()
                  .remove("keyword")
                  .then(Property, referenceToken: "id"));

            syntax
            //constructor
            .match <MethodDeclarationSyntax>(method => method.ReturnType.IsMissing && method.Identifier.ToString() == "constructor")
            .then(Constructor);
        }
Beispiel #2
0
        static public void Apply(ExcessCompiler compiler)
        {
            var lexical   = compiler.Lexical();
            var semantics = compiler.Semantics();

            lexical
            .match()     //lambda
            .any('(', '=', ',')
            .token("function", named: "fn")
            .enclosed('(', ')')
            .token('{', named: "brace")
            .then(compiler.Lexical().transform()
                  .remove("fn")
                  .insert("=>", before: "brace"))
            .match()
            .token("function", named: "fn")         //declarations
            .identifier(named: "id")
            .enclosed('(', ')')
            .token('{')
            .then(lexical.transform()
                  .remove("fn")
                  .then(ProcessMemberFunction, referenceToken: "id"));
            semantics
            .error("CS0246", FunctionType);
        }
Beispiel #3
0
        public static void Apply(ExcessCompiler compiler)
        {
            var syntax = compiler.Syntax();

            syntax
            .extension("contract", ExtensionKind.Code, ProcessContract);
        }
Beispiel #4
0
 public static void Apply(ExcessCompiler compiler)
 {
     Functions.Apply(compiler);
     Members.Apply(compiler);
     Events.Apply(compiler);
     TypeDef.Apply(compiler);
     Arrays.Apply(compiler);
 }
Beispiel #5
0
        public static void Apply(ExcessCompiler compiler)
        {
            var syntax = compiler.Syntax();

            //code extension
            syntax
            .extension("asynch", ExtensionKind.Code, ProcessAsynch)
            .extension("synch", ExtensionKind.Code, ProcessSynch);
        }
Beispiel #6
0
        public static void Apply(ExcessCompiler compiler, Scope scope = null)
        {
            scope?.AddKeywords("injector");

            compiler.extension("injector", ParseDependencyInjector);
            compiler.Environment()
            .dependency("Excess.Runtime")
            .dependency("Ninject");
        }
Beispiel #7
0
 static public void Apply(ExcessCompiler compiler)
 {
     compiler.Lexical()
     .match()
     .any(new[] { '(', '=', ',' }, named: "start", matchDocumentStart: true)
     .enclosed('[', ']', start: "open", end: "close")
     .then(compiler.Lexical().transform()
           .insert("new []", after: "start")
           .replace("open", "{")
           .replace("close", "}"));
 }
Beispiel #8
0
        public static void Apply(ExcessCompiler compiler)
        {
            var lexical = compiler.Lexical();

            lexical.match()
            .token("match", named: "keyword")
            .enclosed('(', ')')
            .token('{')
            .then(lexical.transform()
                  .replace("keyword", "switch")
                  .then(ProcessMatch, referenceToken: "keyword"));
        }
Beispiel #9
0
        public static void Apply(ExcessCompiler compiler, Scope scope = null)
        {
            scope?.AddKeywords("sql");
            compiler.Lexical()
                .extension("sql", ExtensionKind.Code, ParseDapper);

            compiler.Environment()
                .dependency("Excess.Runtime")
                .dependency("Dapper")
                .dependency<IDbConnection>("System.Data")
                .dependency("System.Collections.Generic")
                .dependency("System.Linq");
        }
Beispiel #10
0
        public static void Apply(ExcessCompiler compiler, Scope scope = null)
        {
            scope?.AddKeywords("settings");

            compiler.Lexical()
            .indented <SettingsModel, SettingsRoot>("settings", ExtensionKind.Type, null)
            .match <SettingsRoot, HeaderModel>(ParseHeader,
                                               children: child => child
                                               .match <SettingsModel, HeaderModel, AssignmentExpressionSyntax>(
                                                   then: (header, assignment) => header.Values.Add(assignment)))

            .then()
            .transform <SettingsRoot>(LinkSettings);
        }
Beispiel #11
0
        static public void Apply(ExcessCompiler compiler)
        {
            var lexical = compiler.Lexical();

            lexical
            .match()
            .token("inject", named: "keyword")
            .enclosed('{', '}', end: "lastBrace")
            .then(lexical.transform()
                  .replace("keyword", "__injectFunction __inject = _ => ")
                  .insert(";", after: "lastBrace")
                  .then(ProcessInjection));

            compiler.Environment()
            .dependency <__Scope>("Excess.Runtime");
        }
Beispiel #12
0
        static public void Apply(ExcessCompiler compiler)
        {
            var lexical = compiler.Lexical();
            var syntax  = compiler.Syntax();

            lexical
            .match()
            .token("event", named: "ev")
            .identifier(named: "id")
            .enclosed('(', ')', contents: "args")
            .then(LexicalEventDeclaration);

            syntax
            .match <MethodDeclarationSyntax>(method => method.ReturnType.ToString() == "on")
            .then(EventHandler);
        }
Beispiel #13
0
        public static void Apply(ExcessCompiler compiler)
        {
            compiler.Environment()
            .dependency <JObject>("Newtonsoft.Json.Linq");

            compiler.Lexical()
            .grammar <JsonGrammar, ParserRuleContext>("json", ExtensionKind.Code)
            .transform <JSONParser.ExpressionContext>(AntlrExpression.Parse)
            .transform <JSONParser.JsonContext>(Main)
            .transform <JSONParser.ObjectContext>(JObject)
            .transform <JSONParser.ArrayContext>(JArray)
            .transform <JSONParser.PairContext>(JPair)
            .transform <JSONParser.ValueContext>(JValue)

            .then(Transform);
            ;
        }
Beispiel #14
0
        public static void Apply(ExcessCompiler compiler)
        {
            Functions.Apply(compiler);
            Members.Apply(compiler);
            Events.Apply(compiler);
            TypeDef.Apply(compiler);
            Arrays.Apply(compiler);
            Match.Apply(compiler);

            //base libs
            compiler.Environment()
            .dependency(new string[]
            {
                "System",
                "System.Collections.Generic",
                "System.Linq"
            });
        }
Beispiel #15
0
        public static void Apply(ExcessCompiler compiler)
        {
            var lexical = compiler.Lexical();

            lexical
            .match()
            .token("concurrent", named: "keyword")
            .token("class", named: "ref")
            .then(lexical.transform()
                  .remove("keyword")
                  .then(Compile))
            .match()
            .token("concurrent", named: "keyword")
            .token("object", named: "ref")
            .then(lexical.transform()
                  .remove("keyword")
                  .replace("ref", "class")
                  .then(CompileObject));
        }
Beispiel #16
0
        static public void Apply(ExcessCompiler compiler)
        {
            var lexical   = compiler.Lexical();
            var semantics = compiler.Semantics();

            lexical
            .match()
            .token("typedef")
            .identifier(named: "id")
            .token("=")
            .until(';', named: "definition")
            .then(TypedefAssignment)
            .match()
            .token("typedef", named: "keyword")
            .until(';', named: "definition")
            .then(compiler.Lexical().transform()
                  .remove("keyword")
                  .then(Typedef));

            semantics
            .error("CS0246", FixMissingType);
        }
Beispiel #17
0
        public static void Apply(ExcessCompiler compiler, Scope scope)
        {
            var options = scope?.get <ServerExtensionOptions>()
                          ?? new ServerExtensionOptions();

            var keywords = scope?.get("keywords") as List <string>;

            keywords?.Add("service");

            compiler.Syntax()
            .extension("server", ExtensionKind.Type, CompileServer);

            var lexical = compiler.Lexical();

            lexical.match()
            .token("service", named: "keyword")
            .identifier(named: "ref")
            .then(lexical.transform()
                  .replace("keyword", "class ")
                  .then(CompileService));

            compiler.Environment()
            .dependency("Middleware");

            if (options.GenerateJsServices)
            {
                throw new NotImplementedException();
                //var compilation = compiler.Compilation();
                //if (compilation != null)
                //    compilation
                //        .match<ClassDeclarationSyntax>(isConcurrentClass)
                //            .then(jsConcurrentClass)
                //        .match<ClassDeclarationSyntax>(isConcurrentObject)
                //            .then(jsConcurrentObject);
            }
        }
Beispiel #18
0
 public static void Apply(ExcessCompiler compiler, Scope scope = null)
 {
     scope?.AddKeywords("model");
     compiler.extension("model", ParseModel);
 }
Beispiel #19
0
        public static void Apply(ExcessCompiler compiler, Scope scope, CompilationAnalysis compilation = null)
        {
            var options = scope?.get <ServerExtensionOptions>()
                          ?? new ServerExtensionOptions();

            var keywords = scope?.get("keywords") as List <string>;

            keywords?.Add("service");

            //compiler.Syntax()
            //    .extension("server", ExtensionKind.Type, CompileServer);

            var lexical = compiler.Lexical();

            lexical.match()
            .token("service", named: "keyword")
            .identifier(named: "ref")
            .then(lexical.transform()
                  .replace("keyword", "class ")
                  .then(CompileService));

            compiler.Environment()
            .dependency("System.Configuration")
            .dependency("System.Security.Principal")
            .dependency("Microsoft.Owin")
            .dependency("Excess.Server.Middleware")
            ;

            compiler.Lexical()
            .indented <ServerModel, ServerInstance>("server", ExtensionKind.Type, InitApp)
            .match <ServerModel, ServerInstance, ServerLocation>(new[] {
                "@{Url}",
                "on port {Port}",
                "@{Url} port {Port}",
                "@{Url}, port {Port}"
            },
                                                                 then: SetServerLocation)

            .match <ServerModel, ServerInstance, ConfigModel>("using {Threads} threads", then: SetConfiguration)
            .match <ServerModel, ServerInstance, ConfigModel>("identity @{Identity}", then: SetConfiguration)

            .match <ServerModel, ServerInstance, HostingModel>("hosting {ClassName}",
                                                               then: (server, hosting) => server.HostedClasses.Add(hosting.ClassName))

            .match <ServerModel, ServerInstance, StaticFilesModel>(new[] {
                "static files @{Directory}",
                "static files {Directory}",
            },
                                                                   then: (server, staticFiles) => server.StaticFiles = staticFiles.Directory)

            .match <ServerModel, ServerInstance, ServerInstance>("new instance",
                                                                 then: AddInstance,
                                                                 children: child => child.match_parent())

            .match <ServerModel, ServerInstance, SQLLocation>(new[] {
                "sql @{ConnectionString}",
                "sql with {ConnectionInstantiator} @{ConnectionString}",
                "sql on connection {ConnectionId}",
                "sql with {ConnectionInstantiator} on connection {ConnectionId}",
            },
                                                              then: (server, sql) => server.SetSqlLocation(sql))

            .then()
            .transform <ServerInstance>(LinkServerInstance);
        }
Beispiel #20
0
        public static void Apply(ExcessCompiler compiler, Scope scope = null)
        {
            scope?.AddKeywords("contract");

            compiler.extension("contract", ParseContract);
        }