Updating the changelog in the VERSION file, and version_sync.
[shapes.git] / source / pageyylex.ll
blob8207c4e00baa2e2a1ffb106ee7ba701f3f8ec010
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 Henrik Tidefelt
17  */
21 #include "pagescanner.h"
22 #include <string.h>
23 #include <iostream>
24 #include <iomanip>
28 WhiteSpace [ \t\n\r]
30 Float [+-]?[0-9]*[.]?[0-9]*
32 Name [/]{Regular}*
35 IndirectRef {PlainInteger}{WhiteSpace}+{PlainInteger}{WhiteSpace}*"R"
36 IndirectDef {PlainInteger}{WhiteSpace}+{PlainInteger}{WhiteSpace}*"obj"
38 %option c++
39 %option noyywrap
41 %option yyclass="PageScanner"
43 %x Copy
47 <Copy>(.|[\n]) { (*yyout) << *yytext ; }
49 ({Float}{WhiteSpace}+){5}{Float}{WhiteSpace}*"cm" {
50         char * end;
51         double dummy;
52         dummy = strtod( yytext, & end );
53         if( dummy != 1 )
54                 {
55                         throw( "Expected pure translation in the initial coordinate transform matrix" );
56                 }
57         dummy = strtod( end, & end );
58         if( dummy != 0 )
59                 {
60                         throw( "Expected pure translation in the initial coordinate transform matrix" );
61                 }
62         dummy = strtod( end, & end );
63         if( dummy != 0 )
64                 {
65                         throw( "Expected pure translation in the initial coordinate transform matrix" );
66                 }
67         dummy = strtod( end, & end );
68         if( dummy != 1 )
69                 {
70                         throw( "Expected pure translation in the initial coordinate transform matrix" );
71                 }
72         x0 = strtod( end, & end );
73         y0 = strtod( end, & end );
74         (*yyout) << yytext << endl ;
77 "q" ;
78 "[]0 d" ;
79 "0 J" ;
80 {Float}{WhiteSpace}*"w" ;
81 "S" ;
83 "Q" {
84         if( state == 3 )
85                 {
86                         BEGIN( Copy );
87                 }
90 {Float}{WhiteSpace}*{Float}{WhiteSpace}*"m" {
91         char * end;
92         double dummy;
93         dummy = strtod( yytext, & end );
94         ytmp = strtod( end, & end );
97 {Float}{WhiteSpace}*{Float}{WhiteSpace}*"l" {
98         char * end;
99         strtod( yytext, & end );
100         double tmp = strtod( end, & end ) - 3;
101         switch( state )
102                 {
103                 case 0:
104                         height = tmp;
105                         break;
106                 case 1:
107                         depth = tmp;
108                         break;
109                 case 2:
110                         width = tmp;
111                         break;
112                 default:
113                         throw( "Surprising state in pagescanner" );
114                 }
115         ++state;
118 {WhiteSpace}+ ;
120 . { throw( string( "Page scanner found unrecognized token: " ) + yytext ); }
123 /* The closing %% above marks the end of the Rules section and the beginning
124  * of the User Subroutines section. All text from here to the end of the
125  * file is copied verbatim to the end of the generated lex.pdf.c file.
126  * This section is where you put definitions of helper functions.
127  */