Skip to content

Commit 96e3f83

Browse files
bump version
1 parent 926d12c commit 96e3f83

File tree

3 files changed

+28
-9
lines changed

3 files changed

+28
-9
lines changed

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,15 @@ legal & caveats
6363
known bugs
6464
----------
6565

66-
* because i am not smart enough to write a fully streaming parser, the current parser "cheats" a bit when it encounters a `expr` node! it actually waits until it has all the tokens it needs to build a tree for a given expression, then builds it and emits it as a single node. the `expr` parsing is heavily influenced by [crockford's tdop article](http://javascript.crockford.com/tdop/tdop.html). the rest of the parser is heavily influenced by fever dreams.
66+
* because i am not smart enough to write a fully streaming parser, the current parser "cheats" a bit when it encounters a `expr` node! it actually waits until it has all the tokens it needs to build a tree for a given expression, then builds it and emits the constituent child nodes in the expected order. the `expr` parsing is heavily influenced by [crockford's tdop article](http://javascript.crockford.com/tdop/tdop.html). the rest of the parser is heavily influenced by fever dreams.
6767

6868
* the parser might hit a state where it's looking at what *could be* an expression, or it could be a declaration --
6969
that is, the statement starts with a previously declared `struct`. it'll opt to pretend it's a declaration, but that
70-
might not be the case (it might just a user error!)
70+
might not be the case -- it might be a user-defined constructor starting a statement!
71+
72+
* "unhygenic" `#if` / `#endif` macros are completely unhandled at the moment, since they're a bit of a pain.
73+
if you've got unhygenic macros in your code, move the #if / #endifs to statement level, and have them surround
74+
wholly parseable code. this sucks, and i am sorry.
7175

7276
license
7377
-------

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "glsl-parser",
3-
"version": "0.0.0",
3+
"version": "0.0.1",
44
"description": "transform streamed glsl tokens into an ast",
55
"main": "index.js",
66
"dependencies": {

test/test.glsl

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,38 +13,52 @@ precision highp vec4;
1313
struct xxx {
1414
int y;
1515
float b;
16-
}
16+
} a = 2, b;
1717

18+
struct {
19+
xxx z;
20+
} www;
21+
struct gary {
22+
vec4 busey;
23+
};
1824
varying vec2 vTexcoord;
1925
varying vec3 vPosition;
2026
uniform mat4 proj, view;
2127

2228
    attribute vec3 position;
2329
    attribute vec2 texcoord;
2430

25-
int x(void) {
31+
int forwarddecl(vec2 c);
32+
33+
int forwarddecl(vec2 c) {
2634

2735
}
2836

29-
int y() {
37+
int empty() {
3038

3139
}
3240

33-
int z(int a, int b) {
41+
int two(int a, int b) {
3442

3543
}
3644

37-
int w(int a) {
45+
int one(int a[2]) {
3846
do x; while(1);
3947
}
4048

49+
int emptyname(vec2[4]);
50+
int emptynameemptyname(vec2, vec2);
51+
52+
4153
int first, second, third, fourth, fifth, sixth, seventh, eigth;
4254

4355
    void main(){
4456
        vTexcoord = texcoord;
4557
        vPosition = position;
4658
vec3 thing = vec2(1., 2.);
4759
int v_thing, garybusey;
60+
thing.rgba = 2e10 + .2e2 + 1.e3 * 0xFaBc09 + (3 * v_thing);
61+
4862
for(xxx i = 0; i < 10; ++i) {
4963
discard;
5064
}
@@ -54,7 +68,7 @@ int first, second, third, fourth, fifth, sixth, seventh, eigth;
5468
        gl_Position = proj * view * // nope
5569
vec4(position, 1.0);
5670

57-
if(first < /*hello*/ y) { z; }
71+
if(first < y) { z; }
5872
if(second < y) z;
5973
if(third == y) z; else if(z == w) y;
6074
if(fourth == y) z; else if(z == w) { y; };
@@ -70,3 +84,4 @@ int first, second, third, fourth, fifth, sixth, seventh, eigth;
7084
break;
7185
continue;
7286
    }
87+

0 commit comments

Comments
 (0)