assembler/lexer: add support for double hypen comments

This commit is contained in:
Zack Buhman 2025-10-21 15:39:08 -05:00
parent fe0684ca5e
commit ae3fa0f2e6
2 changed files with 12 additions and 8 deletions

View File

@ -1,4 +1,4 @@
# d = length(uv) -- d = length(uv)
src0.rgb = temp[0] : src0.rgb = temp[0] :
temp[0].r = DP3 src0.rg0 src0.rg0 ; temp[0].r = DP3 src0.rg0 src0.rg0 ;
src0.rgb = temp[0] : src0.rgb = temp[0] :
@ -7,15 +7,15 @@ NOP
src0.a = temp[0] : src0.a = temp[0] :
temp[0].a = RCP src0.a ; temp[0].a = RCP src0.a ;
# d = abs(d - 0.5) * 1 + -0.1 -- d = abs(d - 0.5) * 1 + -0.1
src0.a = float(48), # 0.5 src0.a = float(48), -- 0.5
src1.a = temp[0], # d src1.a = temp[0], -- d
src2.a = float(29), # 0.1015625 src2.a = float(29), -- 0.1015625
srcp.a = sub : # (src1.a - src0.a) srcp.a = sub : -- (src1.a - src0.a)
temp[0].a = MAD |srcp.a| src0.1 -src2.a ; temp[0].a = MAD |srcp.a| src0.1 -src2.a ;
# d = (d >= 0.0) ? 1.0 : 0.0 -- d = (d >= 0.0) ? 1.0 : 0.0
# out.rgba = vec4(d, 0, 0, 1) -- out.rgba = vec4(d, 0, 0, 1)
OUT TEX_SEM_WAIT OUT TEX_SEM_WAIT
src0.a = temp[0] : src0.a = temp[0] :
out[0].a = MAX src0.1 src0.1 , out[0].a = MAX src0.1 src0.1 ,

View File

@ -112,6 +112,10 @@ class Lexer:
return Token(*self.pos(), TT.semicolon, self.lexeme()) return Token(*self.pos(), TT.semicolon, self.lexeme())
elif c == ord(','): elif c == ord(','):
return Token(*self.pos(), TT.comma, self.lexeme()) return Token(*self.pos(), TT.comma, self.lexeme())
elif c == ord('-') and self.peek() == ord('-'):
self.advance()
while not self.at_end_p() and self.peek() != ord('\n'):
self.advance()
elif self.minus_is_token and c == ord('-'): elif self.minus_is_token and c == ord('-'):
return Token(*self.pos(), TT.minus, self.lexeme()) return Token(*self.pos(), TT.minus, self.lexeme())
elif c == ord('#'): elif c == ord('#'):