For all files: HTML, JS, CSS, LESS, CSHTML, ASCX, ASPX, CS (SVC) And config files XML, JSON [Write a webpack loader](https://webpack.js.org/contribute/writing-a-loader/) to load backend templates dependencies. ## C# Razor and Web Forms templates Entry points: `^[^_].*\.cshtml$` and `.aspx$` should be an entries points - WebForm templates (ASPX use ASCX controls) files are HTML/XML with processing instruction nodes - MVC templates (Razor cshtml or vbhtml) are HTML file, where HTML tags can contains inscruction block start with `@` (contains special instruction C# or VB or an HTML tag or inscruction block but not all or `<text></text>`) - [ASPX View Engine VS Razor View Engine](https://www.c-sharpcorner.com/UploadFile/ff2f08/aspx-view-engine-vs-razor-view-engine/) - [C# Razor Syntax Quick Reference | You’ve Been Haacked](https://haacked.com/archive/2011/01/06/razor-syntax-quick-reference.aspx/) - aspx to razor [c# - Aspx to Razor syntax converter? - Stack Overflow](https://stackoverflow.com/questions/4422881/aspx-to-razor-syntax-converter) - [dotnet/csharplang: The official repo for the design of the C# programming language](https://github.com/dotnet/csharplang) ### ASPX template syntax - `<script runat="server"> <script language="C#" runat="server">`: code block [Code Blocks in ASP.NET](https://msdn.microsoft.com/en-us/library/f0111sbh%28v=vs.100%29.aspx) - `<xxx runat="server">`: parse as rendered control (where xxx could be "asp:Foo" or "form") - `<% %>`: code blocks - `<%= %>`: evaluate code expression - `<%: %>`: evaluate code expression without escape (ASP.NET 4) - `<%$ %>`: configuration file expression - `<%@ %>`: page directive - `<%# %>`: Data binding - `<%-- --%>`: server side comments - [Qu'est-ce que le scriptlet d'instructions \<% instruction %\> ? - FAQ ASP.NET/C#](https://dotnet.developpez.com/faq/asp/csharp/?page=scriptlets) - [Embedded Code Blocks in ASP.NET Web Forms Pages](https://msdn.microsoft.com/en-us/library/ms178135.aspx) - [Introduction to ASP.NET inline expressions in the .NET Framework](https://support.microsoft.com/en-us/help/976112/introduction-to-asp-net-inline-expressions-in-the-net-framework) nuggets - [asp classic - Escape asp/vbscript script tags - Stack Overflow](https://stackoverflow.com/questions/31291678/escape-asp-vbscript-script-tags) - [The difference between \<%= and \<%# in ASP.NET – Dan Crevier's Blog](https://blogs.msdn.microsoft.com/dancre/2007/02/13/the-difference-between-and-in-asp-net/) - [Data-Binding Expression Syntax | Microsoft Docs](https://docs.microsoft.com/en-us/previous-versions/dotnet/netframework-4.0/bda9bbfx%28v=vs.100%29) - [ASP.NET data binding overview](https://support.microsoft.com/en-us/help/307860/asp-net-data-binding-overview) - [syntax - ASP.NET "special" tags - Stack Overflow](https://stackoverflow.com/questions/649428/asp-net-special-tags/649458#649458) - [PositiveTechnologies/AspxParser: Aspx files (aspx, ascx, etc.) parser.](https://github.com/PositiveTechnologies/AspxParser) - [asp.net - Convert a single file aspx to code behind - Stack Overflow](https://stackoverflow.com/questions/854545/convert-a-single-file-aspx-to-code-behind) - [Parsing ASPX and Other Mixed Content - CodeProject](https://www.codeproject.com/Articles/20967/Parsing-ASPX-and-Other-Mixed-Content) - [ASP Parser - CodeProject](https://www.codeproject.com/Articles/6888/ASP-Parser) - [ASP.NET Page Syntax | Microsoft Docs](https://docs.microsoft.com/en-us/previous-versions/dotnet/netframework-3.0/fy30at8h%28v=vs.85%29) - [happycollision/atom-language-asp-html: Atom language package for ASP HTML files (.ascx and .aspx)](https://github.com/happycollision/atom-language-asp-html) - Atom language package, replace [jbalboni/atom-language-aspx](https://github.com/jbalboni/atom-language-aspx) that have issue with if condition Generate .cs from .aspx/.ascx (Aka precompile, auto-generated class): - https://github.com/microsoft/referencesource/blob/master/System.Web/UI/BaseTemplateParser.cs#L97 - https://github.com/microsoft/referencesource/blob/master/System.Web/Compilation/BuildManager.cs ### Razor syntax - [asp.net mvc 3 - Allow "invalid" html markup in partial view in MVC 3 - Stack Overflow](https://stackoverflow.com/questions/6344695/allow-invalid-html-markup-in-partial-view-in-mvc-3) Razor syntax: - `@(...)`: Explicit Razor expressions - `@if(){...}`, `@each(){...}`, `@for(){...}`, `@functions{...}`, etc. - `@*...*@` - `@{...}` - `@@`: escape `@` - `@myVar`: implicit Razor expressions Code block: - `@` followed by identifiers, keywords, comments, "(" and "{" - code block body can contains: - special tag `<text>...</text>` to output inside (remove enclosing tag) - tags - explicit line transition: `@:...` - implicit Razor expressions `@myVar`: (le `@` n'est pas précédé par un caractère alpha num: [a-z0-9]) Tags: - start with "<" + alphanum (else it's a text node) - attributes open quotes must be closed (not required at root level) - can be void/empty elements (without end tag: `<link>` or `<link/>` or `<link></link>`, see [`TagStructure.WithoutEndTag` (= 2)](https://github.com/aspnet/Razor/blob/fe60c2426cba01ada13bc575ca608b91debd473b/src/Microsoft.AspNetCore.Razor.Evolution/TagStructure.cs), [`<area>`, `<base>`, `<br>`, `<col>`, `<command>`, `<embed>`, `<hr>`, `<img>`, `<input>`, `<keygen>`, `<link>`, `<meta>`, `<param>`, `<source>`, `<track>`, `<wbr>`](https://github.com/aspnet/Razor/blob/9e4c4079f206b5cde1258cc29e0ecd5474c33596/src/Microsoft.AspNetCore.Razor.Language/Legacy/HtmlMarkupParser.cs)) - can contains Razor expressions in in body, as attribute (but comments are rendered in attribute value: `<div class="one two @* foo *@ three"></div>`, `<div test=@* foo *@></div>`, see https://github.com/aspnet/Razor/blob/master/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorComments.cshtml) - body can contains tags, code blocks or text node Root level is similar to a tag body: - body can contains tags (just the attributes value are parsed, EOF are ignored), code blocks or text node See also: - [ScottGu's Blog - ASP.NET MVC 3: Layouts and Sections with Razor](https://weblogs.asp.net/scottgu/asp-net-mvc-3-layouts-and-sections-with-razor) - [ScottGu's Blog - ASP.NET MVC 3: Razor’s @: and \<text\> syntax](https://weblogs.asp.net/scottgu/asp-net-mvc-3-razor-s-and-lt-text-gt-syntax) - [ScottGu's Blog - ASP.NET MVC 3: Implicit and Explicit code nuggets with Razor](https://weblogs.asp.net/scottgu/asp-net-mvc-3-implicit-and-explicit-code-nuggets-with-razor) - [AspNetCore.Docs/razor.md at master · aspnet/AspNetCore.Docs](https://github.com/aspnet/AspNetCore.Docs/blob/master/aspnetcore/mvc/views/razor.md) - [Razor syntax reference for ASP.NET Core | Microsoft Docs](https://docs.microsoft.com/en-us/aspnet/core/mvc/views/razor?view=aspnetcore-3.0) - [aspnet/Razor: Parser and code generator for CSHTML files used in view pages for MVC web apps.](https://github.com/aspnet/Razor) - [Ten Tricks for Razor Views](https://odetocode.com/blogs/scott/archive/2013/01/09/ten-tricks-for-razor-views.aspx) - [C# Razor Syntax Quick Reference | You’ve Been Haacked](https://haacked.com/archive/2011/01/06/razor-syntax-quick-reference.aspx/) Use Roslyn: - [Building a C# Interactive shell in a browser with Blazor (WebAssembly) and Roslyn | StrathWeb. A free flowing web tech monologue.](https://www.strathweb.com/2019/06/building-a-c-interactive-shell-in-a-browser-with-blazor-webassembly-and-roslyn/) - [svenheden/csharp-models-to-typescript: C# models to TypeScript](https://github.com/svenheden/csharp-models-to-typescript#readme) - [Getting Started with Roslyn: Transforming C# Code - DZone Web Dev](https://dzone.com/articles/getting-started-with-roslyn-transforming-c-code-1) - [Roslyn Overview · dotnet/roslyn Wiki](https://github.com/dotnet/roslyn/wiki/Roslyn%20Overview#syntax-trees) - [Getting Started C# Syntax Analysis · dotnet/roslyn Wiki](https://github.com/dotnet/roslyn/wiki/Getting-Started-C%23-Syntax-Analysis) - [roslyn/Lexer.cs at master · dotnet/roslyn](https://github.com/dotnet/roslyn/blob/master/src/Compilers/CSharp/Portable/Parser/Lexer.cs) and [roslyn/LanguageParser.cs at master · dotnet/roslyn](https://github.com/dotnet/roslyn/blob/master/src/Compilers/CSharp/Portable/Parser/LanguageParser.cs) - [oleg-shilo/cs-script.npp: CS-Script (C# Intellisense) plugin for Notepad++ (x86/x64)](https://github.com/oleg-shilo/cs-script.npp) - [Roslyn Syntax Visualizers | Visual Studio Blog](https://devblogs.microsoft.com/visualstudio/roslyn-syntax-visualizers/) - [Getting Started Writing a Custom Analyzer & Code Fix · dotnet/roslyn Wiki](https://github.com/dotnet/roslyn/wiki/Getting-Started-Writing-a-Custom-Analyzer-&-Code-Fix) - [ashmind/SharpLab: SharpLab (previously known as TryRoslyn)](https://github.com/ashmind/SharpLab) - [Easy way to create a C# lambda expression from a string (with Roslyn) | StrathWeb. A free flowing web tech monologue.](https://www.strathweb.com/2018/01/easy-way-to-create-a-c-lambda-expression-from-a-string-with-roslyn/) - [Implementing custom #load behavior in Roslyn scripting | StrathWeb. A free flowing web tech monologue.](https://www.strathweb.com/2016/06/implementing-custom-load-behavior-in-roslyn-scripting/) - [Building strongly typed application configuration utility with Roslyn | StrathWeb. A free flowing web tech monologue.](https://www.strathweb.com/2016/04/building-strongly-typed-application-configuration-utility-with-roslyn/) Generate CSharp from Razor with [`RazorTemplateEngine`](https://docs.microsoft.com/en-us/dotnet/api/system.web.razor.razortemplateengine?iew=aspnet-webpages-3.2) then read the [CodeCompileUnit](https://docs.microsoft.com/fr-fr/dotnet/api/system.codedom.codecompileunit?view=net-5.0) to output AST or JS: - [RazorTemplates/TemplateCompiler.cs at 47c91d62820897d3a0794e4433e7f8427e80edd0 · volkovku/RazorTemplates](https://github.com/volkovku/RazorTemplates/blob/47c91d62820897d3a0794e4433e7f8427e80edd0/src/RazorTemplates.Core/TemplateCompiler.cs#L62-L69) - [toddams/RazorLight: Template engine based on Microsoft's Razor parsing engine for .NET Core](https://github.com/toddams/RazorLight) - [Get started with syntax analysis (Roslyn APIs) | Microsoft Learn](https://learn.microsoft.com/en-us/dotnet/csharp/roslyn-sdk/get-started/syntax-analysis) - [Microsoft.CodeAnalysis | .NET API browser | Microsoft Learn](https://learn.microsoft.com/en-us/dotnet/api/?term=Microsoft.CodeAnalysis) - [C# parsing and evaluating using Roslyn · hello world](https://kflu.github.io/2016/08/27/2016-08-27-csharp-parsing-evaluating-roslyn/) - [Learn Roslyn Now: Part 5 CSharpSyntaxRewriter – Shotgun Debugging](https://joshvarty.com/2014/08/15/learn-roslyn-now-part-5-csharpsyntaxrewriter/) - [c# - Getting a SemanticModel of a cshtml file? - Stack Overflow](https://stackoverflow.com/questions/28392086/getting-a-semanticmodel-of-a-cshtml-file) Generate CSharp from Razor with [`RazorTemplateEngine`](https://docs.microsoft.com/en-us/dotnet/api/system.web.razor.razortemplateengine?iew=aspnet-webpages-3.2) then tokenize with [`CSharpSyntaxTree.ParseText()`](https://docs.microsoft.com/en-us/dotnet/api/microsoft.codeanalysis.csharp.csharpsyntaxtree.parsetext?view=roslyn-dotnet-3.9.0) to output AST or JS: - [RoslynRazorViewEngine/RoslynRazorViewEngine.cs at master · davidebbo/RoslynRazorViewEngine](https://github.com/davidebbo/RoslynRazorViewEngine/blob/master/RoslynRazorViewEngine/RoslynRazorViewEngine.cs#L147) - See [c# - Getting a SemanticModel of a cshtml file? - Stack Overflow](https://stackoverflow.com/questions/28392086/getting-a-semanticmodel-of-a-cshtml-file/28392123#28392123) - [RazorClientTemplates/RazorClientTemplateEngine.cs at master · jchadwick/RazorClientTemplates](https://github.com/jchadwick/RazorClientTemplates/blob/master/Core/RazorClientTemplateEngine.cs) - [c# - RazorTemplateEngine parser produces unusual syntax tree - Stack Overflow](https://stackoverflow.com/questions/14222846/razortemplateengine-parser-produces-unusual-syntax-tree) - [milkshakesoftware/razorjs at 9f93fc6d08963c3e08497ff2ad6bbf9025cd357d](https://github.com/milkshakesoftware/razorjs/tree/9f93fc6d08963c3e08497ff2ad6bbf9025cd357d) Use RazorJS: - [andyedinborough/RazorJS: A simple JavaScript implementation of the Razor view engine for browsers and Node.](https://github.com/andyedinborough/RazorJS) - [A simple JavaScript implementation of the Razor view engine.](https://gist.github.com/andyedinborough/1771064) Generate .cs from .cshtml (Aka precompile, auto-generated class): - https://stackoverflow.com/a/17139797/470117 - [Pre-compiled Razor View in ASP.NET MVC - CodeProject](https://www.codeproject.com/Articles/1169354/Pre-compiled-Razor-View-in-ASP-NET-MVC) - [Precompiling Your Website (C#) | Microsoft Docs](https://docs.microsoft.com/en-us/aspnet/web-forms/overview/older-versions-getting-started/deploying-web-site-projects/precompiling-your-website-cs) - [Use razor to generate code? - Stack Overflow](https://stackoverflow.com/questions/4938134/use-razor-to-generate-code) - [AspNetCore-Tooling/RazorProjectEngine.cs at 5f74fae0d26c72c45329b7c63661833645d2f7fc · aspnet/AspNetCore-Tooling](https://github.com/aspnet/AspNetCore-Tooling/blob/5f74fae0d26c72c45329b7c63661833645d2f7fc/src/Razor/src/Microsoft.AspNetCore.Razor.Language/RazorProjectEngine.cs#L133) - [AspNetCore-Tooling/RazorParser.cs at 5f74fae0d26c72c45329b7c63661833645d2f7fc · aspnet/AspNetCore-Tooling](https://github.com/aspnet/AspNetCore-Tooling/blob/5f74fae0d26c72c45329b7c63661833645d2f7fc/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/RazorParser.cs) - [Razor/RazorParser.cs at master · aspnet/Razor](https://github.com/aspnet/Razor/blob/master/src/Microsoft.AspNetCore.Razor.Language/Legacy/RazorParser.cs) - [Antaris/RazorEngine: Open source templating engine based on Microsoft's Razor parsing engine](https://github.com/Antaris/RazorEngine) - Parse cshtml to C# [RazorGenerator/RazorGenerator: A Custom Tool for Visual Studio that allows processing Razor files at design time instead of runtime, allowing them to be built into an assembly for simpler reuse and distribution.](https://github.com/RazorGenerator/RazorGenerator) - [System.Web.Razor.Tokenizer Namespace ()](https://msdn.microsoft.com/en-us/library/system.web.razor.tokenizer%28v=vs.111%29.aspx) - [Microsoft.CodeAnalysis.Razor Namespace | Microsoft Docs](https://docs.microsoft.com/en-us/dotnet/api/microsoft.codeanalysis.razor?view=aspnetcore-3.0) - [Precompiling Your Website (C#) | Microsoft Docs](https://docs.microsoft.com/en-us/aspnet/web-forms/overview/older-versions-getting-started/deploying-web-site-projects/precompiling-your-website-cs) - [Turn on Compile-time View Checking for ASP.NET MVC Projects in TFS Build 2010 – Jim Lamb](https://blogs.msdn.microsoft.com/jimlamb/2010/04/20/turn-on-compile-time-view-checking-for-asp-net-mvc-projects-in-tfs-build-2010/) - [ASP.NET Compilation Tool (Aspnet_compiler.exe) | Microsoft Docs](https://docs.microsoft.com/en-us/previous-versions/ms229863%28v=vs.100%29?redirectedfrom=MSDN) - [How can I see the code generated for a Razor Page when using Asp.Net Core? - Stack Overflow](https://stackoverflow.com/questions/43004634/how-can-i-see-the-code-generated-for-a-razor-page-when-using-asp-net-core/43004742) - [volkovku/RazorTemplates: Open source templating engine based on Microsoft's Razor parsing engine. Thread safe. Allows run Razor templates outside ASP.Net MVC Projects.](https://github.com/volkovku/RazorTemplates/blob/47c91d62820897d3a0794e4433e7f8427e80edd0/src/RazorTemplates.Core/TemplateCompiler.cs#L62-L69) - use Microsoft.CSharp WASM / Blazor: ```js #!/usr/bin/env node // https://github.com/evanw/esbuild/blob/master/npm/esbuild-wasm/bin/esbuild // Forward to the automatically-generated WebAssembly loader from the Go compiler const wasm_exec = require.resolve('esbuild-wasm/wasm_exec.js'); const esbuild_wasm = require.resolve('esbuild-wasm/esbuild.wasm'); const code = require('fs').readFileSync(wasm_exec, 'utf8'); const wrapper = new Function('require', 'process', code); const argv = ['node', wasm_exec, esbuild_wasm].concat(process.argv.slice(2)); wrapper(require, Object.assign(Object.create(process), { argv })); ``` - [ncave/dna-redux: Running C#/F# code in Node.js or Browser with WebAssembly](https://github.com/ncave/dna-redux) - [webassembly - Running C# dll in browser for calculations only - Stack Overflow](https://stackoverflow.com/questions/56039594/running-c-sharp-dll-in-browser-for-calculations-only) - [corert/how-to-build-WebAssembly.md at master · dotnet/corert](https://github.com/dotnet/corert/blob/master/Documentation/how-to-build-WebAssembly.md) - [Introduction to ASP.NET Core Blazor | Microsoft Docs](https://docs.microsoft.com/en-us/aspnet/core/blazor/?view=aspnetcore-3.0) - [Compiling C# to WASM with Mono and Blazor then Debugging .NET Source with Remote Debugging in Chrome DevTools - Scott Hanselman](https://www.hanselman.com/blog/CompilingCToWASMWithMonoAndBlazorThenDebuggingNETSourceWithRemoteDebuggingInChromeDevTools.aspx) - [on Reddit](https://www.reddit.com/r/programming/comments/9xkay8/compiling_c_to_wasm_with_mono_and_blazor_then/), [Hello, world!](https://blazor-demo.github.io/) - [Building a C# Interactive shell in a browser with Blazor (WebAssembly) and Roslyn | StrathWeb. A free flowing web tech monologue.](https://www.strathweb.com/2019/06/building-a-c-interactive-shell-in-a-browser-with-blazor-webassembly-and-roslyn/) - [migueldeicaza/mono-wasm](https://github.com/migueldeicaza/mono-wasm) - [Running ASP.NET Core 2.0 Via Mono](https://www.c-sharpcorner.com/article/running-asp-net-core-2-0-via-mono/) - [Learn how to build your first Blazor WebAssembly app in .Net Core 3.0](https://softchris.github.io/pages/dotnet-blazor.html) - https://github.com/softchris/softchris.github.io/tree/master/pages - compile `*.razor` to C# `ComponentBase` class with `protected override void BuildRenderTree(RenderTreeBuilder builder)` ... or to Tag Helper: - code behind (.cshtml + .cshtml.cs, .razor + .razor.cs) - [Building Components Manually via RenderTreeBuilder](https://chrissainty.com/building-components-via-rendertreebuilder/) - [c# - Creating a component by overriding BlazorComponent.BuildRenderTree(RenderTreeBuilder builder) - Stack Overflow](https://stackoverflow.com/questions/53582633/creating-a-component-by-overriding-blazorcomponent-buildrendertreerendertreebui/53582845#53582845) - [Introduction to ASP.NET Core Blazor | Microsoft Docs](https://docs.microsoft.com/en-us/aspnet/core/blazor/?view=aspnetcore-3.1) - [C# to TypeScript - Visual Studio Marketplace](https://marketplace.visualstudio.com/items?itemName=adrianwilczynski.csharp-to-typescript) Compile C# to JS: - [JSIL - .NET to JavaScript compiler](http://jsil.org/) - [List of languages that compile to JS · jashkenas/coffeescript Wiki](https://github.com/jashkenas/coffeescript/wiki/List-of-languages-that-compile-to-JS#c-f-net-related-languages) - [Javascript and C# Cross Compiling and Conversion - Stack Overflow](https://stackoverflow.com/questions/16434389/javascript-and-c-sharp-cross-compiling-and-conversion) - [praeclarum/Netjs: Compile .NET assemblies to TypeScript and JavaScript](https://github.com/praeclarum/Netjs) - [CodeTranslator: Code Translation From VB.NET \<-\> C# \<-\> TypeScript \<-\> Java](https://www.carlosag.net/tools/codetranslator/) Other: - [Evil Eval() Vol. 2 @ PeachPie | PHP compiler to .NET](https://www.peachpie.io/2020/02/evil-eval-2.html) - [dotnet/csharp-tmLanguage: Syntax grammar used for C# colorization](https://github.com/dotnet/csharp-tmLanguage) - [joseph-turner/Razor: Syntax Definition for Razor (cshtml) in SublimeText](https://github.com/joseph-turner/Razor) - [vscode/extensions at master · Microsoft/vscode](https://github.com/Microsoft/vscode/tree/master/extensions) - TextMate Bundles for Razor and C# used by Visual Studio Code based on [demyte/language-cshtml](https://github.com/demyte/language-cshtml) and [dotnet/csharp-tmLanguage](https://github.com/dotnet/csharp-tmLanguage) - [birkenfeld / pygments-main / issues / #865 - new lexer request: cshtml (Razor) — Bitbucket](https://bitbucket.org/birkenfeld/pygments-main/issues/865/new-lexer-request-cshtml-razor) - [Request Language Support: grammar "ASP.NET Razor" and extension "cshtml" · Issue #612 · Glavin001/atom-beautify](https://github.com/Glavin001/atom-beautify/issues/612) - https://github.com/tree-sitter/tree-sitter-razor - https://docs.microsoft.com/fr-fr/aspnet/core/mvc/views/razor - https://github.com/jordansjones/Mvc4j/blob/master/Razor/src/main/java/nextmethod/web/razor/parser/ParserHelpers.java - https://github.com/CityRay/gulp-cshtml-minifier/blob/master/index.js - https://github.com/MattsGitCode/razorscript - http://www.cs.vu.nl/grammarware/browsable/CSharp/grammar.html - [kirbysayshi/vash: Vash, the 60 billion double-dollar template-maker. Razor syntax, for JavaScript templates](https://github.com/kirbysayshi/vash) - [Grammar Definitions for C#, F#, VB - .NET Foundation Forums](https://forums.dotnetfoundation.org/t/grammar-definitions-for-c-f-vb/2632/2) - [atom/language-csharp: C# language support for Atom](https://github.com/atom/language-csharp) - [Bridge.NET - Open Source C# to JavaScript Compiler](https://bridge.net/) ## Mustache syntax - https://github.com/jknack/handlebars.java/blob/master/handlebars/src/main/antlr4/com/github/jknack/handlebars/internal/HbsLexer.g4 - https://github.com/mariusae/mustache.scala/blob/master/src/main/antlr/Mustache.g - https://github.com/zalando/beard/tree/master/src/main/antlr4/de/zalando/beard - https://github.com/mustache/spec/tree/master/specs - [dmarcotte/idea-handlebars: Handlebars and Mustache template support for Intellij IDEA platform IDEs](https://github.com/dmarcotte/idea-handlebars) ## Language server Aka LSP (Language Server Protocol) Note: **[LSP doesn't expose AST](https://github.com/Microsoft/language-server-protocol/issues/258)** - [Langserver.org](https://langserver.org/) - [Add preview Razor support by SteveSandersonMS · Pull Request #2554 · OmniSharp/omnisharp-vscode](https://github.com/OmniSharp/omnisharp-vscode/pull/2554) - [OmniSharp/omnisharp-roslyn: OmniSharp based on roslyn workspaces](https://github.com/OmniSharp/omnisharp-roslyn) - [Specification](https://microsoft.github.io/language-server-protocol/specification) - [microsoft/vscode-languageserver-node-example: Sample language server implemented in Node](https://github.com/microsoft/vscode-languageserver-node-example) - [aspnet/Razor.VSCode: Razor tooling for Visual Studio Code](https://github.com/aspnet/Razor.VSCode) - [Language Server Extension Guide | Visual Studio Code Extension API](https://code.visualstudio.com/api/language-extensions/language-server-extension-guide) - [Extending a client with the language server protocol - LogRocket Blog](https://blog.logrocket.com/how-to-use-the-language-server-protocol-to-extending-a-client-764da0e7863c/) Stdio (RPC/IPC): - [sbt-server-stdio.js](https://gist.github.com/eed3si9n/0ee26a15218f1d4031b451dd61315d6c) - [go - server client connection through stdio - Stack Overflow](https://stackoverflow.com/questions/51680991/server-client-connection-through-stdio/51681053#51681053) - [teambition/jsonrpc-lite: Parse and Serialize JSON-RPC2 messages in node.js, or browser.](https://github.com/teambition/jsonrpc-lite) ## Grammars / syntax tree generators Parsers produce syntax trees, Lexers produce tokens. | (E)BNF | ANTLR -----------------+--------+------ 'a' zero or once | [a] | a? 'a' zero or more | {a} | a* 'a' once or more | a {a} | a+ Need context-free grammars, not just an highlighter - [webpack/fastparse: A very simple and stupid parser, based on a statemachine and regular expressions.](https://github.com/webpack/fastparse) - [Search · fastparse](https://github.com/search?l=JavaScript&q=fastparse&type=Code) - [ng-cache-loader/scriptParser.js at master · teux/ng-cache-loader](https://github.com/teux/ng-cache-loader/blob/master/lib/scriptParser.js) - [tree-sitter/tree-sitter: An incremental parsing system for programmings tools](https://github.com/tree-sitter/tree-sitter) - [appden/less.tmbundle: LESS TextMate Bundle](https://github.com/appden/less.tmbundle) - [sublime-packages/HTML-ASP.tmLanguage at master · bradrobertson/sublime-packages](https://github.com/bradrobertson/sublime-packages/blob/master/ASP/HTML-ASP.tmLanguage) and [sublime/ASP.tmLanguage at master · cj/sublime](https://github.com/cj/sublime/blob/master/ASP/ASP.tmLanguage) - [TextMate Manual » Language Grammars](https://manual.macromates.com/en/language_grammars) - [parsing - Where can I find a library that parses source code and is able to extract the scope of where your cursor is currently in the code? - Stack Overflow](https://stackoverflow.com/questions/9912622/where-can-i-find-a-library-that-parses-source-code-and-is-able-to-extract-the-sc) - [limetext/lime: Open source API-compatible alternative to the text editor Sublime Text](https://github.com/limetext/lime) - Parse `tmLanguage`, https://github.com/limetext/backend/blob/master/parser/parser.go - [Parsing absolutely anything in JavaScript using Earley algorithm](https://medium.com/@gajus/parsing-absolutely-anything-in-javascript-using-earley-algorithm-886edcc31e5e) - [Available lexers — Pygments](http://pygments.org/docs/lexers/) - [ShowUsYour\<Blog\> - Using BNF to create regex's](https://weblogs.asp.net/dneimke/102146) - [BNF Grammar - Rosetta Code](http://rosettacode.org/wiki/BNF_Grammar#Visual_Basic_.NET) - [Web Assembly in ASP.NET Core - Samuele Resca](https://samueleresca.net/2017/08/web-assembly-in-net/) [Web Assembly in ASP.NET Core](https://dev.to/samueleresca/web-assembly-in-aspnet-core) [aspnet/Blazor: An experimental web UI framework using C#/Razor and HTML, running in the browser via WebAssembly](https://github.com/aspnet/blazor) - [The BNF Converter](http://bnfc.digitalgrammars.com/) - [c# 4.0 - C# grammar in BNF or EBNF Parser generator for F# - Stack Overflow](https://stackoverflow.com/questions/7392976/c-sharp-grammar-in-bnf-or-ebnf-parser-generator-for-f) - [Razor syntax reference for ASP.NET Core | Microsoft Docs](https://docs.microsoft.com/en-us/aspnet/core/mvc/views/razor) - Razor Syntax - [New language - CSHTML Razor by romanresh · Pull Request #1631 · isagalaev/highlight.js](https://github.com/isagalaev/highlight.js/pull/1631) - [.net - Dependency graph of Visual Studio projects - Stack Overflow](https://stackoverflow.com/questions/598129/dependency-graph-of-visual-studio-projects) - [How to Write Custom Language Support Plugins | IntelliJ IDEA Blog](https://blog.jetbrains.com/idea/2013/01/how-to-write-custom-language-support-plugins/), [ReSharper: Visual Studio Extension for .NET Developers by JetBrains](https://www.jetbrains.com/resharper/) and [Rider: Cross-platform .NET IDE by JetBrains](https://www.jetbrains.com/rider/) - [code-prettify/src at master · google/code-prettify](https://github.com/google/code-prettify/tree/master/src) - [acornjs/acorn: A small, fast, JavaScript-based JavaScript parser](https://github.com/acornjs/acorn) [eslint/espree: An Esprima-compatible JavaScript parser](https://github.com/eslint/espree) [estree/estree: The ESTree Spec](https://github.com/estree/estree) - [cherow/cherow: Very fast and lightweight, standards-compliant, self-hosted javascript parser with high focu on both performance and stability](https://github.com/cherow/cherow) [Cherow - A fast, Typescript-based Javascript parser](https://cherow.github.io/cherow/) - [inikulin/parse5: HTML parsing/serialization toolset for Node.js. WHATWG HTML Living Standard (aka HTML5)-compliant.](https://github.com/inikulin/parse5) https://github.com/inikulin/parse5/blob/master/lib/extensions/location_info/parser_mixin.js - [Web Dev Report - Integrate HTML5 into Existing ASP.NET Web Forms and ASP.NET MVC Applications](https://msdn.microsoft.com/en-us/magazine/jj129609.aspx) - [amphtml/validator/engine at master · ampproject/amphtml](https://github.com/ampproject/amphtml/tree/master/validator/engine) - [AST explorer](http://astexplorer.net/) - [Web Dev Report - Integrate HTML5 into Existing ASP.NET Web Form and ASP.NET MVC Applications](https://msdn.microsoft.com/en-us/magazine/jj129609.aspx) - https://weblogs.asp.net/scottgu/new-lt-gt-syntax-for-html-encoding-output-in-asp-net-4-and-asp-net-mvc-2 - [prettier/prettier: Prettier i an opinionated code formatter.](https://github.com/prettier/prettier) - https://github.com/nikic/PHP-Parser https://github.com/z7zmey/php-parser/blob/master/README.md - https://www.jetbrains.com/help/devguide/PSI/SyntaxTrees.html - https://www.npmjs.com/package/php-parser - https://www.npmjs.com/package/node-c-parser - http://www.parse2.com - https://github.com/cederberg/grammatica https://grammatica.percederberg.net - https://stackoverflow.com/questions/23456868/c-sharp-5-0-ebnf-grammar - https://forums.dotnetfoundation.org/t/grammar-definitions-for-c-f-vb/2632/2 - https://github.com/php/php-src/blob/master/Zend/zend_language_parser.y - https://github.com/luscoma/pyRazor/blob/master/README.md - [csstree/csstree: A tool set to work with CSS, including fast detailed parser, walker, generator and lexer based on knowledge of spec and browser implementations](https://github.com/csstree/csstree) - [ianh/owl: A parser generator for visibly pushdown languages.](https://github.com/ianh/owl) - [Microsoft/monaco-languages: Basic colorization support for many Monaco Editor languages.](https://github.com/Microsoft/monaco-languages) - [warrenseine/prettier-plugin-csharp: Prettier C# Plugin](https://github.com/warrenseine/prettier-plugin-csharp) - use unofficial C# 6 grammar from ANTLR Parse using native libs: - [Run LLVM Assembly In Your Browser](http://kripken.github.io/llvm.js/demo.html) - [Integrating Node.js with a C# dll | juri.strumpflohner](https://juristr.com/blog/2014/03/integrating-node-with-csharp/) - [Edge.js](http://tjanczuk.github.io/edge/#/) - [call dotnet from node - Google Search](https://www.google.com/search?q=call+dotnet+from+node) - [Child Process | Node.js v12.2.0 Documentation](https://nodejs.org/api/child_process.html) Stuff related to webpack: - [Show your modules tree · Issue #690 · webpack/webpack](https://github.com/webpack/webpack/issues/690) - [Webpack analyzer](https://webpack.github.io/analyse/) - [How to easily visualize a project's dependency graph with dependency-cruiser | Netlify](https://www.netlify.com/blog/2018/08/23/how-to-easily-visualize-a-projects-dependency-graph-with-dependency-cruiser/) - [Module Dependency Diagrams - Help | WebStorm](https://www.jetbrains.com/help/webstorm/module-dependency-diagram.html) - [NPMGraph - Visualize NPM Module Dependencies](http://npm.broofa.com/) - [auchenberg/dependo: Visualize your CommonJS or AMD module dependencies in a force directed graph report.](https://github.com/auchenberg/dependo) - [auchenberg/dependo: Visualize your CommonJS or AMD module dependencies in a force directed graph report.](https://github.com/auchenberg/dependo) - [Any library for visualizing module dependencies in Node.js? - Stack Overflow](https://stackoverflow.com/questions/11742216/any-library-for-visualizing-module-dependencies-in-node-js) - [pahen/madge: Create graphs from your CommonJS, AMD or ES6 module dependencies](https://github.com/pahen/madge) - [Analyzing ES6 Circular Dependencies | Blog by Railsware](https://railsware.com/blog/2018/06/27/how-to-analyze-circular-dependencies-in-es6/) - [circular-dependency-plugin - npm](https://www.npmjs.com/package/circular-dependency-plugin) - [analyze-es6-modules - npm](https://www.npmjs.com/package/analyze-es6-modules) Antlr: - [An introduction to language lexing and parsing with ANTLR](https://willowtreeapps.com/ideas/an-introduction-to-language-lexing-and-parsing-with-antlr) - [antlr4/runtime/JavaScript at master · antlr/antlr4](https://github.com/antlr/antlr4/tree/master/runtime/JavaScript) - [grammars-v4/csharp at master · antlr/grammars-v4](https://github.com/antlr/grammars-v4/tree/master/csharp) - https://www.npmjs.com/package/antlr4-c3 - http://www.antlr3.org/grammar/list.html - [Generate EBNF from ANTLR - Stack Overflow](https://stackoverflow.com/questions/9921850/generate-ebnf-from-antlr) - [antlr/grammars-v4: Grammars written for ANTLR v4; expectation that the grammars are free of actions.](https://github.com/antlr/grammars-v4) - [antlr/grammars-v4: Grammars written for ANTLR v4; expectation that the grammars are free of actions.](https://github.com/antlr/grammars-v4) ## Custom parser - [Lexical to an AST with C# - Matthew Campbell - Medium](https://medium.com/@matthew47671280/lexical-to-an-ast-with-c-6e378f76ac7f) - [Peter van der Zee on Twitter: "Just published the first version of Tenko, my spec compliant JS parser written in JS. Used to be ZeParser, you may have heard of it :) https://t.co/bLbB7t9Veg https://t.co/eRMprSXpce" / Twitter](https://twitter.com/kuvos/status/1192541520638943232?s=12) ## Syntax tree format - [syntax-tree/unist: Universal Syntax Tree used by @unifiedjs](https://github.com/syntax-tree/unist) - see also Universal Syntax Tree derivated formats ([HAST](https://github.com/syntax-tree/hast)) - [babylon/spec.md at master · babel/babylon](https://github.com/babel/babylon/blob/master/ast/spec.md) ## Consume syntax tree - [UAST Querying · Babelfish (aka. bblfsh)](https://doc.bblf.sh/user/uast-querying.html) - [PT.Doc/English.md at master · PositiveTechnologies/PT.Doc · GitHub](https://github.com/PositiveTechnologies/PT.Doc/blob/master/Articles/Tree-structures-processing-and-unified-AST/English.md) - [PT.Doc/English.md at master · PositiveTechnologies/PT.Doc](https://github.com/PositiveTechnologies/PT.Doc/blob/master/Articles/Theory-and-Practice-of-source-code-parsing-with-ANTLR-and-Roslyn/English.md#lexical-modes-for-php-html-css-and-javascript) - [PT.Doc/English.md at master · PositiveTechnologies/PT.Doc](https://github.com/PositiveTechnologies/PT.Doc/blob/master/Articles/Pattern-language-for-a-universal-signature-based-code-analyzer/English.md) - [PT.Doc/The proper way to develop grammars of any kind using ANTLR.tex at master · PositiveTechnologies/PT.Doc](https://github.com/PositiveTechnologies/PT.Doc/blob/master/Articles/The-proper-way-to-develop-grammars-of-any-kind-using-ANTLR/The%20proper%20way%20to%20develop%20grammars%20of%20any%20kind%20using%20ANTLR.tex) - [tree-sitter/tree-sitter: An incremental parsing system for programmings tools](https://github.com/tree-sitter/tree-sitter) [tree-sitter/node-tree-sitter: Node.js bindings for tree-sitter](https://github.com/tree-sitter/node-tree-sitter) - [antlr/antlr4: ANTLR (ANother Tool for Language Recognition) is a powerful parser generator for reading, processing, executing, or translating structured text or binary files.](https://github.com/antlr/antlr4) - [Boost.Spirit](http://boost-spirit.com/home/) [Spirit 2.5.4 - 1.66.0](http://www.boost.org/doc/libs/1_66_0/libs/spirit/doc/html/index.html) - LL parser framework represents parsers directly as EBNF grammars in inlined C++. - [srcML](http://www.srcml.org/) - [Mapper of XPath expressions onto AST nodes · Issue #4369 · checkstyle/checkstyle · GitHub](https://github.com/checkstyle/checkstyle/issues/4369) - [XPath - Wikipedia](https://en.wikipedia.org/wiki/XPath) - [ThierryGoubier/SmaCC: Smalltalk Compiler Compiler : a parser generator](https://github.com/ThierryGoubier/SmaCC) - [Add simple comparison table for alternatives · Issue #35 · bblfsh/documentation · GitHub](https://github.com/bblfsh/documentation/issues/35) - [dchester/jsonpath: Query and manipulate JavaScript objects with JSONPath expressions. Robust JSONPath engine for Node.js.](https://github.com/dchester/jsonpath) [JSONPath - XPath for JSON](http://goessner.net/articles/JsonPath/) - [Mapper of XPath expressions onto AST nodes · Issue #4369 · checkstyle/checkstyle · GitHub](https://github.com/checkstyle/checkstyle/issues/4369) - [dfilatov/jspath: DSL that enables you to navigate and find data within your JSON documents](https://github.com/dfilatov/jspath) - [JSONiq - The JSON Query Language](http://jsoniq.org/) ### Graph ``` digraph G { size="100,50" center="" ratio=All node[width=.25,hight=.375,fontsize=12,color=lightblue2,style=filled] 1 -> 3; 1 -> 17; 3 -> 15; 1 [label="Drew.DependencyAnalyser.Tests"]; 3 [label="Drew.DependencyAnalyser"]; 15 [label="Interop.WINGRAPHVIZLib"]; 17 [label="nunit.framework"]; } digraph "graph" { "test1" -> "test2"; "test1" -> "test3"; "test2" -> "test4"; "test3" -> "test4"; } ``` Use Hierarchical Edge Bundling or Collapsible Force Layout or Drag and Drop Collapsible Tree Layout - [Graphviz - Graph Visualization Software](http://www.graphviz.org/) - Online: [Webgraphviz](http://www.webgraphviz.com/) or [Viz.js](http://viz-js.com/) - [Google Code Archive - Long-term storage for Google Code Project Hosting.](https://code.google.com/archive/p/canviz/) - [pahen/madge: Create graphs from your CommonJS, AMD or ES6 module dependencies](https://github.com/pahen/madge) - [npm2dot](https://www.npmjs.com/package/npm2dot) - [twopi(1): filter for drawing directed graphs - Linux man page](https://linux.die.net/man/1/twopi) - [DOT (graph description language) - Wikipedia](https://en.wikipedia.org/wiki/DOT_%28graph_description_language%29) - [itchyny/rexdep: Roughly extract dependency relation from source code](https://github.com/itchyny/rexdep) - https://github.com/d3/d3/wiki/Gallery - https://github.com/d3/d3-hierarchy/blob/master/README.md#treemap - [CodeFlower Source code visualization](http://www.redotheweb.com/CodeFlower/) - [grgrdvrt/dot: interface to build dot document for graphviz](https://github.com/grgrdvrt/dot) - [Yoichi Kobayashi sur Twitter : "My recent project wa released. I wa in charge of building a WebGL content "Request Viewer"… https://t.co/Hc7yfz3L8n"](https://twitter.com/ykob0123/status/1002920521900519424?s=12) - [sᴄᴏᴛᴛ ᴅᴀʀʙʏ on Twitter: "Check out the repo for webgl gource here: https://t.co/yySWpOa3Tl It's essentially a GPGPU force directed graph simulation using data pulled from the Github API: #threejs #javascript #creativecoding #iohk #glsl"](https://twitter.com/_scottdarby/status/1045661427158126592?s=12) ## Similar files WebStorm: Code > Find duplicates... Aka Similar Data Detection (SDD) Compare tokens: - ignore spaces - ignore braces: `if (foo) {x++}` is same as `if(foo)x++;` - ignore function/variable names Find files with similarities (ex: same parts without whitespaces), find peak (number) or tokens occurence (text: words) - [Audio Fingerprinting with Python and Numpy](http://willdrevo.com/fingerprinting-and-audio-recognition-with-python/) [worldveil/dejavu: Audio fingerprinting and recognition in Python](https://github.com/worldveil/dejavu) - [PMD – Finding duplicated code](https://pmd.github.io/latest/usage/cpd-usage.html) and [PMD – Howto add a new language to PMD](https://pmd.github.io/pmd-5.8.1/customizing/new-language.html) - [Duplicate code - Wikipedia](https://en.wikipedia.org/wiki/Duplicate_code) - [java - Parsing Razor-style Templates - Software Engineering Stack Exchange](https://softwareengineering.stackexchange.com/questions/227892/parsing-razor-style-templates) - [danielstjules/jsinspect: Detect copy-pasted and structurally similar code](https://github.com/danielstjules/jsinspect) - [SDD: High performance code clone detect download | SourceForge.net](https://sourceforge.net/projects/sddforeclipse/?SetFreedomCookie) - [Continuous Code Quality | SonarQube](https://www.sonarqube.org/) [SonarSource/sonarqube: Continuous Code Quality](https://github.com/SonarSource/sonarqube) - [Microsoft Word - pp44-lee.doc - sdd_slee_2005.pdf](http://www.cs.cmu.edu/~seunghak/sdd_slee_2005.pdf) - [aspnet/Razor: Parser and code generator for CSHTML files used in view pages for MVC web apps.](https://github.com/aspnet/Razor) - [Anti-Twin - find similar files and images](http://www.joerg-rosenthal.com/en/antitwin/similar.html) - [Simian: Get It Now!](http://www.harukizaemon.com/simian/get_it_now.html)