123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- %{
- /*#include <QtGui>*/
- #include <QVariant>
- #include <QDebug>
- #include "utils/wavefrontobj.h"
- #include "lexer-wavefront-obj.h"
-
-
-
- // yylex is a function generated by Flex and we must tell to Bison that it is
- // defined in other place.
- extern int wavefront_objlex(void);
-
- // Bison uses the yyerror function for informing us when a parsing error has
- // occurred.
- void wavefront_objerror(const char *s);
- %}
-
- %define api.prefix {wavefront_obj}
- %define api.token.prefix {TOK_}
-
- // Here we define our custom variable types.
- // Custom types must be of fixed size.
- %union {
- float number;
- char* string;
- void* wavefront;
- }
-
- // Define the terminal expression types.
- %token <float_number> NUMBER
- %token <string> STRING
- %token SLASH
- %token MTLLIB
- %token USEMTL
- %token O
- %token V
- %token VT
- %token VN
- %token VP
- %token F
- %token S
-
- // Define the non-terminal expression types.
- %type <wavefront> wavefront_obj
-
- %%
-
- start: wavefront_obj {
- /* qDebug() << $1;*/
- };
-
- wavefront_obj: stmt_list {
- }
- ;
-
-
- stmt_list: {}
- | stmt_list stmt {};
-
- stmt: mtllib {}
- | usemtl {}
- | named_object {}
- | vertex {}
- | texture_coordinate {}
- | vertex_normal {}
- | vertex_space {}
- | face {}
- | smooth {};
-
- mtllib: MTLLIB STRING {};
-
- usemtl: USEMTL STRING {};
-
- named_object: O STRING {};
-
- vertex: V NUMBER NUMBER NUMBER {}
- | V NUMBER NUMBER NUMBER NUMBER {};
-
- texture_coordinate: VT NUMBER NUMBER {}
- | VT NUMBER NUMBER NUMBER {};
-
- vertex_normal: VN NUMBER NUMBER NUMBER {};
-
- vertex_space: VP NUMBER NUMBER NUMBER {};
-
- face: F face_vertex_list {};
-
- face_vertex_list: {}
- | face_vertex_list face_vertex {};
-
- face_vertex: NUMBER {}
- | NUMBER SLASH NUMBER {}
- | NUMBER SLASH NUMBER SLASH NUMBER {}
- | NUMBER SLASH SLASH NUMBER {};
-
- smooth: S NUMBER {}
- | S STRING {};
-
- %%
-
- void wavefront_objerror(const char *s)
- {
- qDebug() << "parse error:" << s << "at line" << wavefront_objlineno << "at" << wavefront_objtext;
- }
|