1 /* This file is part of Shapes.
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
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.
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/>.
16 * Copyright 2008, 2010 Henrik Tidefelt
21 #include "pagescanner.h"
26 #include <cstdio> // This is a workaround for a bug in Flex.
32 Float [+-]?[0-9]*[.]?[0-9]*
37 IndirectRef {PlainInteger}{WhiteSpace}+{PlainInteger}{WhiteSpace}*"R"
38 IndirectDef {PlainInteger}{WhiteSpace}+{PlainInteger}{WhiteSpace}*"obj"
43 %option yyclass="PageScanner"
49 <Copy>(.|[\n]) { (*yyout) << *yytext ; }
51 ({Float}{WhiteSpace}+){5}{Float}{WhiteSpace}*"cm" {
54 dummy = strtod( yytext, & end );
57 throw( "Expected pure translation in the initial coordinate transform matrix" );
59 dummy = strtod( end, & end );
62 throw( "Expected pure translation in the initial coordinate transform matrix" );
64 dummy = strtod( end, & end );
67 throw( "Expected pure translation in the initial coordinate transform matrix" );
69 dummy = strtod( end, & end );
72 throw( "Expected pure translation in the initial coordinate transform matrix" );
74 x0 = strtod( end, & end );
75 y0 = strtod( end, & end );
76 (*yyout) << yytext << endl ;
82 {Float}{WhiteSpace}*"w" ;
92 {Float}{WhiteSpace}*{Float}{WhiteSpace}*"m" {
95 dummy = strtod( yytext, & end );
96 ytmp = strtod( end, & end );
99 {Float}{WhiteSpace}*{Float}{WhiteSpace}*"l" {
101 strtod( yytext, & end );
102 double tmp = strtod( end, & end ) - 3;
115 throw( "Surprising state in pagescanner" );
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.