source: OGRE/trunk/ogrenew/RenderSystems/GL/src/nvparse/ps1.0_tokens.l @ 657

Revision 657, 2.9 KB checked in by mattausch, 19 years ago (diff)

added ogre dependencies and patched ogre sources

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#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
41static 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
73def                     {
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
92add(_x2|_x4|_d2)?(_sat)? |
93cnd(_x2|_x4|_d2)?(_sat)? |
94dp3(_x2|_x4|_d2)?(_sat)? |
95lrp(_x2|_x4|_d2)?(_sat)? |
96mad(_x2|_x4|_d2)?(_sat)? |
97mov(_x2|_x4|_d2)?(_sat)? |
98mul(_x2|_x4|_d2)?(_sat)? |
99sub(_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
107tex          |
108texbem       |
109texbeml      |
110texcoord     |
111texkill      |
112texm3x2pad   |
113texm3x2tex   |
114texreg2ar    |
115texreg2gb    |
116texm3x3pad   |
117texm3x3spec  |
118texm3x3tex   |
119texm3x3vspec    {
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%%
152bool ps10_init(char* inputString)
153{
154    myin = inputString;
155        return init_extensions();
156}
157
158#ifndef ps10_wrap
159int ps10_wrap(void)
160{
161  return(1);
162}
163#endif
Note: See TracBrowser for help on using the repository browser.