[3] | 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 | #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 | |
---|
| 35 | static 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 | |
---|
| 67 | def { |
---|
| 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 | |
---|
| 86 | add(_x2|_x4|_d2)?(_sat)? | |
---|
| 87 | cnd(_x2|_x4|_d2)?(_sat)? | |
---|
| 88 | dp3(_x2|_x4|_d2)?(_sat)? | |
---|
| 89 | lrp(_x2|_x4|_d2)?(_sat)? | |
---|
| 90 | mad(_x2|_x4|_d2)?(_sat)? | |
---|
| 91 | mov(_x2|_x4|_d2)?(_sat)? | |
---|
| 92 | mul(_x2|_x4|_d2)?(_sat)? | |
---|
| 93 | sub(_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 | |
---|
| 101 | tex | |
---|
| 102 | texbem | |
---|
| 103 | texbeml | |
---|
| 104 | texcoord | |
---|
| 105 | texkill | |
---|
| 106 | texm3x2pad | |
---|
| 107 | texm3x2tex | |
---|
| 108 | texreg2ar | |
---|
| 109 | texreg2gb | |
---|
| 110 | texm3x3pad | |
---|
| 111 | texm3x3spec | |
---|
| 112 | texm3x3tex | |
---|
| 113 | texm3x3vspec { |
---|
| 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 | %% |
---|
| 146 | bool ps10_init(char* inputString) |
---|
| 147 | { |
---|
| 148 | myin = inputString; |
---|
| 149 | return init_extensions(); |
---|
| 150 | } |
---|
| 151 | |
---|
| 152 | #ifndef ps10_wrap |
---|
| 153 | int ps10_wrap(void) |
---|
| 154 | { |
---|
| 155 | return(1); |
---|
| 156 | } |
---|
| 157 | #endif |
---|