Coder Social home page Coder Social logo

tfart / hlsl-parser-nitra Goto Github PK

View Code? Open in Web Editor NEW

This project forked from tgjones/hlsl-parser-nitra

0.0 0.0 0.0 304 KB

HLSL parser for .NET

Home Page: http://timjones.tw/blog/archive/2014/11/24/getting-started-with-jetbrains-nitra

C++ 13.68% C 66.54% C# 15.35% Nemerle 4.43%

hlsl-parser-nitra's Introduction

HlslParser

HlslParser is a SM5.0 HLSL parser for .NET. The grammar and parser are built using JetBrains' Nitra project. Currently, it only parses HLSL code into an AST. Once Nitra adds support for it (planned for a future milestone), I plan to extend HlslParser to support full HLSL intellisense in Visual Studio.

HlslParser is currently capable of parsing most / all of the sample shaders in the Direct3D SDK, as well as several other shaders - see the test suite.

(On a nerd note, Nitra makes it possible to define the grammar in a nice concise way; so far, I prefer it to other parser generators that I've used. Here is the HLSL grammar file.)

Usage

var sourceSnapshot = new SourceSnapshot(sourceCode);
var parserHost = new ParserHost();
var compilationUnit = HlslGrammar.CompilationUnit(sourceSnapshot, parserHost);

Assert.That(compilationUnit.IsSuccess, Is.True);

var parseTree = compilationUnit.CreateParseTree();
var parsedCode = parseTree.ToString();

Prerequisites

Because HlslParser is based on Nitra, you'll need to install the following before you can build HlslParser on your own machine:

  1. Nemerle
  2. Nitra

I haven't built an HLSL preprocessor. Instead, I make use of the Direct3D HLSL preprocessor, through SharpDX. SharpDX requires a specific DirectX runtime, so if you want to run the HlslParser test suite, you'll need to install that too:

License

HlslParser is released under the MIT License.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.