Update procedures
[shapes.git] / source / pageyylex.ll
blob1ed1e78a310af742e9dd83017e81fc520cb7a65f
1 /* This file is part of Shapes.
2  *
3  * Shapes is free software: you can redistribute it and/or modify
4  * it under the terms of the GNU General Public License as published by
5  * the Free Software Foundation, either version 3 of the License, or
6  * any later version.
7  *
8  * Shapes is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with Shapes.  If not, see <http://www.gnu.org/licenses/>.
15  *
16  * Copyright 2008, 2010 Henrik Tidefelt
17  */
21 #include "pagescanner.h"
23 #include <string.h>
24 #include <iostream>
25 #include <iomanip>
26 #include <cstdio> // This is a workaround for a bug in Flex.
30 WhiteSpace [ \t\n\r]
32 Float [+-]?[0-9]*[.]?[0-9]*
34 Name [/]{Regular}*
37 IndirectRef {PlainInteger}{WhiteSpace}+{PlainInteger}{WhiteSpace}*"R"
38 IndirectDef {PlainInteger}{WhiteSpace}+{PlainInteger}{WhiteSpace}*"obj"
40 %option c++
41 %option noyywrap
43 %option yyclass="PageScanner"
45 %x Copy
49 <Copy>(.|[\n]) { (*yyout) << *yytext ; }
51 ({Float}{WhiteSpace}+){5}{Float}{WhiteSpace}*"cm" {
52         char * end;
53         double dummy;
54         dummy = strtod( yytext, & end );
55         if( dummy != 1 )
56                 {
57                         throw( "Expected pure translation in the initial coordinate transform matrix" );
58                 }
59         dummy = strtod( end, & end );
60         if( dummy != 0 )
61                 {
62                         throw( "Expected pure translation in the initial coordinate transform matrix" );
63                 }
64         dummy = strtod( end, & end );
65         if( dummy != 0 )
66                 {
67                         throw( "Expected pure translation in the initial coordinate transform matrix" );
68                 }
69         dummy = strtod( end, & end );
70         if( dummy != 1 )
71                 {
72                         throw( "Expected pure translation in the initial coordinate transform matrix" );
73                 }
74         x0 = strtod( end, & end );
75         y0 = strtod( end, & end );
76         (*yyout) << yytext << endl ;
79 "q" ;
80 "[]0 d" ;
81 "0 J" ;
82 {Float}{WhiteSpace}*"w" ;
83 "S" ;
85 "Q" {
86         if( state == 3 )
87                 {
88                         BEGIN( Copy );
89                 }
92 {Float}{WhiteSpace}*{Float}{WhiteSpace}*"m" {
93         char * end;
94         double dummy;
95         dummy = strtod( yytext, & end );
96         ytmp = strtod( end, & end );
99 {Float}{WhiteSpace}*{Float}{WhiteSpace}*"l" {
100         char * end;
101         strtod( yytext, & end );
102         double tmp = strtod( end, & end ) - 3;
103         switch( state )
104                 {
105                 case 0:
106                         height = tmp;
107                         break;
108                 case 1:
109                         depth = tmp;
110                         break;
111                 case 2:
112                         width = tmp;
113                         break;
114                 default:
115                         throw( "Surprising state in pagescanner" );
116                 }
117         ++state;
120 {WhiteSpace}+ ;
122 . { throw( string( "Page scanner found unrecognized token: " ) + yytext ); }
125 /* The closing %% above marks the end of the Rules section and the beginning
126  * of the User Subroutines section. All text from here to the end of the
127  * file is copied verbatim to the end of the generated lex.pdf.c file.
128  * This section is where you put definitions of helper functions.
129  */