Skip to content

Commit 53aa4b0

Browse files
authored
Merge pull request #19 from stackgl/builtin-decl
Builtin declaration
2 parents 68e8d64 + aad0398 commit 53aa4b0

File tree

6 files changed

+609
-5222
lines changed

6 files changed

+609
-5222
lines changed

lib/expr.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ prefix('(', function() {
8585
this.type = 'group'
8686
this.children = [expression(0)]
8787
advance(')')
88-
return this
88+
return this
8989
})
9090
prefix('++')
9191
prefix('--')
@@ -142,7 +142,7 @@ function symbol(id, binding_power) {
142142
}
143143
} else {
144144
sym = Object.create(original_symbol)
145-
sym.id = id
145+
sym.id = id
146146
sym.lbp = binding_power
147147
symbol_table[id] = sym
148148
}

lib/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ function parser() {
504504
function parse_decllist() {
505505
// grab ident
506506

507-
if(token.type === 'ident') {
507+
if(token.type === 'ident' || token.type === 'builtin') {
508508
var name = token.data
509509
state.unshift(ident())
510510
state.scope.define(name)
@@ -560,7 +560,7 @@ function parser() {
560560
}
561561

562562
function parse_ident() {
563-
if(token.type !== 'ident') {
563+
if(token.type !== 'ident' && token.type !== 'builtin') {
564564
return unexpected('expected user-defined name, got '+token.data)
565565
}
566566

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"description": "transform streamed glsl tokens into an ast",
55
"main": "stream.js",
66
"dependencies": {
7-
"glsl-tokenizer": "^2.0.0",
7+
"glsl-tokenizer": "^2.1.4",
88
"through": "2.3.4",
99
"through2": "^0.6.3"
1010
},

test/fixture.glsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ int emptyname(vec2[4]);
5050
int emptynameemptyname(vec2, vec2);
5151

5252

53-
int first, second, third, fourth, fifth, sixth, seventh, eigth;
53+
uint first, second, third, fourth, fifth, sixth, seventh, eigth;
5454

5555
    void main(){
5656
        vTexcoord = texcoord;

test/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ test('stream().program === array()', function(t) {
5353

5454
var actual = Object.keys(ast.scope).sort()
5555
var expect = [
56-
'a', 'b', 'c', 'eigth', 'empty', 'emptyname'
56+
'a', 'b', 'c', 'distance', 'eigth', 'empty', 'emptyname'
5757
, 'emptynameemptyname', 'fifth', 'first', 'forwarddecl'
5858
, 'fourth', 'gary', 'main', 'one', 'position', 'proj'
5959
, 'second', 'seventh', 'sixth', 'texcoord', 'third', 'two'

0 commit comments

Comments
 (0)