Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/RenderSystems/GL/src/nvparse/ps1.0_tokens.l @ 3

Last change on this file since 3 was 3, checked in by anonymous, 17 years ago

=update

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