1 | /* definitions */ |
---|
2 | digit [0-9] |
---|
3 | char [a-zA-Z_.] |
---|
4 | alphanum [0-9a-zA-Z_] |
---|
5 | |
---|
6 | %option prefix="ps10_" |
---|
7 | %{ /* code to be included */ |
---|
8 | |
---|
9 | #include <stdlib.h> |
---|
10 | #include <list> |
---|
11 | #include <vector> |
---|
12 | |
---|
13 | #include "ps1.0_program.h" |
---|
14 | |
---|
15 | using namespace std; |
---|
16 | using namespace ps10; |
---|
17 | |
---|
18 | #include "_ps1.0_parser.h" |
---|
19 | |
---|
20 | #ifdef _WIN32 |
---|
21 | # include <windows.h> |
---|
22 | #endif |
---|
23 | |
---|
24 | #include <GL/gl.h> |
---|
25 | #include <GL/glext.h> |
---|
26 | #include "nvparse_errors.h" |
---|
27 | #include "nvparse_externs.h" |
---|
28 | |
---|
29 | |
---|
30 | #define YY_INPUT(buf,result,max_size) \ |
---|
31 | { \ |
---|
32 | int c = *myin++; \ |
---|
33 | result = (c == 0) ? YY_NULL : (buf[0] = c, 1); \ |
---|
34 | } |
---|
35 | |
---|
36 | #define YY_ALWAYS_INTERACTIVE 1 |
---|
37 | |
---|
38 | //#define DBG_MESG(msg, line) errors.set(msg, line) |
---|
39 | #define DBG_MESG(msg, line) |
---|
40 | |
---|
41 | static char buf[80]; |
---|
42 | |
---|
43 | |
---|
44 | %} |
---|
45 | |
---|
46 | %s DEFSTATE |
---|
47 | |
---|
48 | /* end of definitions */ |
---|
49 | %% |
---|
50 | |
---|
51 | ; | |
---|
52 | \/\/ { |
---|
53 | char ch; |
---|
54 | while ((ch = yyinput()) != '\n') |
---|
55 | ; |
---|
56 | line_number++; |
---|
57 | DBG_MESG("dbg: comment, NEWLINE", line_number-1); |
---|
58 | return NEWLINE; |
---|
59 | } |
---|
60 | |
---|
61 | <DEFSTATE>[+-]?[0-9]+\.[0-9]* | |
---|
62 | <DEFSTATE>[+-]?[0-9]*\.[0-9]+ | |
---|
63 | <DEFSTATE>[+-]?[0-9]+ { |
---|
64 | ps10_lval.fval = (float)atof(yytext); |
---|
65 | // debug |
---|
66 | DBG_MESG("dbg: NUMBER", line_number); |
---|
67 | return NUMBER; |
---|
68 | } |
---|
69 | |
---|
70 | |
---|
71 | |
---|
72 | |
---|
73 | def { |
---|
74 | // debug |
---|
75 | DBG_MESG("dbg: DEF", line_number); |
---|
76 | BEGIN DEFSTATE; |
---|
77 | return DEF; |
---|
78 | } |
---|
79 | |
---|
80 | |
---|
81 | ((1[ \t]*)?-[ \t]*)?r[01](\.a|\.b|\.w|\.rgb|\.xyz|_bias|_bx2)? | |
---|
82 | ((1[ \t]*)?-[ \t]*)?c[0-7](\.a|\.b|\.w|\.rgb|\.xyz|_bias|_bx2)? | |
---|
83 | ((1[ \t]*)?-[ \t]*)?t[0-3](\.a|\.b|\.w|\.rgb|\.xyz|_bias|_bx2)? | |
---|
84 | ((1[ \t]*)?-[ \t]*)?v[01](\.a|\.b|\.w|\.rgb|\.xyz|_bias|_bx2)? { |
---|
85 | sprintf(buf, "dbg: REG = %s", yytext); |
---|
86 | // debug |
---|
87 | DBG_MESG(buf, line_number); |
---|
88 | ps10_lval.sval = new string(yytext); |
---|
89 | return REG; |
---|
90 | } |
---|
91 | |
---|
92 | add(_x2|_x4|_d2)?(_sat)? | |
---|
93 | cnd(_x2|_x4|_d2)?(_sat)? | |
---|
94 | dp3(_x2|_x4|_d2)?(_sat)? | |
---|
95 | lrp(_x2|_x4|_d2)?(_sat)? | |
---|
96 | mad(_x2|_x4|_d2)?(_sat)? | |
---|
97 | mov(_x2|_x4|_d2)?(_sat)? | |
---|
98 | mul(_x2|_x4|_d2)?(_sat)? | |
---|
99 | sub(_x2|_x4|_d2)?(_sat)? { |
---|
100 | sprintf(buf, "dbg: BLENDOP = %s", yytext); |
---|
101 | // debug |
---|
102 | DBG_MESG(buf, line_number); |
---|
103 | ps10_lval.sval = new string(yytext); |
---|
104 | return BLENDOP; |
---|
105 | } |
---|
106 | |
---|
107 | tex | |
---|
108 | texbem | |
---|
109 | texbeml | |
---|
110 | texcoord | |
---|
111 | texkill | |
---|
112 | texm3x2pad | |
---|
113 | texm3x2tex | |
---|
114 | texreg2ar | |
---|
115 | texreg2gb | |
---|
116 | texm3x3pad | |
---|
117 | texm3x3spec | |
---|
118 | texm3x3tex | |
---|
119 | texm3x3vspec { |
---|
120 | sprintf(buf, "dbg: ADDROP = %s", yytext); |
---|
121 | // debug |
---|
122 | DBG_MESG(buf, line_number); |
---|
123 | ps10_lval.sval = new string(yytext); |
---|
124 | return ADDROP; |
---|
125 | } |
---|
126 | |
---|
127 | |
---|
128 | |
---|
129 | ([ \t]*\r?\n)+ { |
---|
130 | line_number++; |
---|
131 | BEGIN 0; |
---|
132 | // debug |
---|
133 | DBG_MESG("dbg: NEWLINE", line_number-1); |
---|
134 | return NEWLINE; |
---|
135 | } |
---|
136 | |
---|
137 | [ \t]+ { |
---|
138 | } |
---|
139 | |
---|
140 | [Pp]s\.1.[01] { |
---|
141 | return HEADER; |
---|
142 | } |
---|
143 | |
---|
144 | . { |
---|
145 | char buf[40]; |
---|
146 | sprintf(buf, "character token == '%c'", *yytext); |
---|
147 | DBG_MESG(buf, line_number); |
---|
148 | return *yytext; |
---|
149 | } |
---|
150 | |
---|
151 | %% |
---|
152 | bool ps10_init(char* inputString) |
---|
153 | { |
---|
154 | myin = inputString; |
---|
155 | return init_extensions(); |
---|
156 | } |
---|
157 | |
---|
158 | #ifndef ps10_wrap |
---|
159 | int ps10_wrap(void) |
---|
160 | { |
---|
161 | return(1); |
---|
162 | } |
---|
163 | #endif |
---|