Code Monkey home page Code Monkey logo

glassful's People

Contributors

burtonageo avatar gsingh93 avatar kmcallister avatar ticki avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

glassful's Issues

Syntax error, unexpected IF

Am I doing something wrong here:

let fragment_shader_src = glassful! {
    #![version="140"]

    #[varying] static v_coord: vec3 = UNINIT;

    fn main() {
        if (abs(v_coord.z) == 0.25) {
            gl_FragColor = vec4(0., 1., 0., 1.);
        } else if (abs(v_coord.x) == 0.25) {
            gl_FragColor = vec4(0., 0., 1., 1.);
        } else if (abs(v_coord.y) == 0.25) {
            gl_FragColor = vec4(1., 0., 0., 1.);
        }
    }
};

I get:

thread '<main>' panicked at 'called `Result::unwrap()` on an `Err` value: CompilationError("0:5(8): error: syntax error, unexpected IF\n")', ../src/libcore/result.rs:731```

Write a new parser?

We only support a tiny subset of Rust. It could be nice to have a 100 line grammar for shader programs instead of the grammar being the 6,000 line Rust parser + a pile of ad-hoc restrictions.

We could also make small changes to the syntax, e.g. removing the mandatory initializers on statics. As long as the tokens are compatible with Rust, the macro re-parses from source anyway.

Using the actual libsyntax parser was mostly a hack to get the proof of concept done in one day :P

Give correct line numbers in macro errors

The translation runs in a separate thread from rustc, in order to catch errors. So we may not be able to share libsyntax data structures. If that's the case, maybe we can hack up an acceptable codemap in the new parser context.

Express data flow better

e.g.

const UNIFORMS: Uniforms;

fn vertex(v: Attributes) -> (vec4, Varyings) { ... }
fn fragment(v: Varyings) -> vec4 { ... }

where those struct definitions are lifted up from glium (c.f. #2)

Check shader code using glslang

which is the reference compiler for GLSL.

This will catch type errors, undefined names, as well as syntax problems the frontend won't catch.

glium already has glslang integration of some kind.

We should map errors back to the source code and print them as spans.

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.