2 Surgical Strike (Free Software Version).
3 Copyright (C) 2008, 2014 Rob Myers
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
25 #include "surgical_strike.h"
29 void yyerror(const char *);
33 extern "C" int yywrap (void)
38 #define YY_INPUT(buf,result,max_size) {\
39 result = GetNextChar(buf, max_size); \
44 #define YYERROR_VERBOSE (1)
70 %token <floatnum> NUMBER
71 %token <string> STRING
72 %token <string> IDENTIFIER
76 program: incoming statements;
78 incoming: INCOMING { parse_incoming (); };
82 | statements statement;
88 codeword_start: CODEWORD IDENTIFIER { parse_codeword ($2); };
90 codeword_end: SET { parse_set (); };
92 codeword_definition: codeword_start commands codeword_end;
99 MARK { parse_mark (); }
100 | CLEAR { parse_clear (); }
101 | MANOUVER NUMBER NUMBER NUMBER { parse_manouver ($2, $3, $4); }
102 | ROLL NUMBER NUMBER NUMBER { parse_roll ($2, $3, $4); }
103 | SCALE NUMBER NUMBER NUMBER { parse_scale ($2, $3, $4); }
104 | LOAD STRING { parse_payload ($2); }
105 | CAMOUFLAGE STRING { parse_camouflage ($2); }
106 | IDENTIFIER { parse_codeword_execution ($1, 1); }
107 | IDENTIFIER NUMBER { parse_codeword_execution ($1, $2); }
108 | DELIVER { parse_deliver (); }
114 extern char * yytext;
118 void yyerror (const char *msg)
120 std::fprintf (stderr, "%d: %s at '%s'\n", yylineno, msg, yytext);
124 int main(int argc, char ** argv)
126 std::string output_file = "out.obj";
128 (std::strcmp (argv[1], "--help") == 0)) ||
131 std::printf ("Surgical Strike Free Software version 0.4\n"
133 "surgical_strike - Read from stdin, write to out.obj|.mtl\n"
134 "surgical_strike [input file] [output file] - "
135 "Read input file, write output file\n");
138 if (debug) std::fprintf (stderr, "Starting up.\n");
141 std::fprintf (stderr, "Opening input file %s.\n", argv[1]);
142 FILE * new_stdin = freopen (argv[1], "r", stdin);
143 if (new_stdin == NULL)
145 std::fprintf (stderr, "Couldn't open input file %s.\n", argv[1]);
151 output_file = argv[2];
153 if (debug) std::fprintf (stderr, "Parsing input file.\n");
155 if (debug) std::fprintf (stderr, "Executing commands.\n");
156 run_main (output_file);