*** empty log message ***

Sat, 29 Dec 2001 10:19:49 +0000

author
eric
date
Sat, 29 Dec 2001 10:19:49 +0000
changeset 9
de78038d990f
parent 8
7288d2753c18
child 10
3184d26a9596

*** empty log message ***

parser.y file | annotate | diff | revisions
scanner.l file | annotate | diff | revisions
     1.1 --- a/parser.y	Fri Dec 28 16:04:15 2001 +0000
     1.2 +++ b/parser.y	Sat Dec 29 10:19:49 2001 +0000
     1.3 @@ -6,20 +6,29 @@
     1.4    int integer;
     1.5    double fp;
     1.6    char *string;
     1.7 +  struct { double width, double height } size;
     1.8  }
     1.9  
    1.10  %token <integer> INTEGER
    1.11  %token <fp> FLOAT
    1.12  %token <string> STRING
    1.13 +%token <size> PAGE_SIZE
    1.14  
    1.15  %token ELIPSIS
    1.16  
    1.17 +%token CM
    1.18 +%token INCH
    1.19 +
    1.20  %token EVEN
    1.21  %token ODD
    1.22  %token ALL
    1.23  
    1.24 +%token PORTRAIT
    1.25 +%token LANDSCAPE
    1.26 +
    1.27  %token FILE
    1.28  %token IMAGE
    1.29 +%token IMAGES
    1.30  %token ROTATE
    1.31  %token CROP
    1.32  %token SIZE
    1.33 @@ -30,48 +39,96 @@
    1.34  %token BOOKMARK
    1.35  %token OUTPUT
    1.36  
    1.37 -%type <integer> range
    1.38 -%type <integer> ranges
    1.39 +%type <integer> image_range
    1.40 +%type <integer> image_ranges
    1.41 +%type <integer> page_range
    1.42 +%type <integer> page_ranges
    1.43 +
    1.44 +%type <fp> length
    1.45  
    1.46  %%
    1.47  
    1.48 -statements: statement | statements statement ;
    1.49 +statements: 
    1.50 +	statement
    1.51 +	| statements statement ;
    1.52  
    1.53 -statement: input_statement | output_statement ;
    1.54 +statement:
    1.55 +	input_statement
    1.56 +	| output_statement ;
    1.57  
    1.58  
    1.59 -range:	INTEGER ELIPSIS INTEGER
    1.60 +image_range:
    1.61 +	INTEGER ELIPSIS INTEGER
    1.62  	| INTEGER ;
    1.63  
    1.64 -ranges:	range
    1.65 -	| ranges ',' range ;
    1.66 +image_ranges:
    1.67 +	image_range
    1.68 +	| image_ranges ',' image_range ;
    1.69  
    1.70  
    1.71  file_clause:
    1.72  	FILE STRING  ';' ;
    1.73  
    1.74  image_clause:
    1.75 -	IMAGE ranges ';' ;
    1.76 +	IMAGE INTEGER ';'
    1.77 +	| IMAGE INTEGER modifier_clause_list ';' ;
    1.78 +
    1.79 +images_clause:
    1.80 +	IMAGES image_ranges ';'
    1.81 +	| IMAGES image_ranges modifier_clause_list ';'
    1.82 +	| IMAGES image_ranges part_clauses ';' ;
    1.83  
    1.84  rotate_clause:
    1.85  	ROTATE INTEGER ';' ;
    1.86  
    1.87 +unit:
    1.88 +	CM
    1.89 +	| INCH ;
    1.90 +
    1.91 +length:
    1.92 +	FLOAT
    1.93 +	| FLOAT unit ;
    1.94 +
    1.95  crop_clause:
    1.96 -	CROP FLOAT ',' FLOAT ';' ;
    1.97 +	CROP PAGE_SIZE ';'
    1.98 +	| CROP PAGE_SIZE orientation ';'
    1.99 +	| CROP length ',' length ';'
   1.100 +	| CROP length ',' length ',' length ',' length ';' ;
   1.101 +
   1.102 +orientation:
   1.103 +	PORTRAIT
   1.104 +	| LANDSCAPE ;
   1.105  
   1.106  size_clause:
   1.107 -	SIZE FLOAT ',' FLOAT ';' ;
   1.108 +	SIZE PAGE_SIZE ';'
   1.109 +	| SIZE PAGE_SIZE orientation ';'
   1.110 +	| SIZE length ',' length ';' ;
   1.111 +
   1.112 +modifier_clause:
   1.113 +	rotate_clause | crop_clause | size_clause;
   1.114 +
   1.115 +modifier_clauses:
   1.116 +	modifier_clause
   1.117 +	| modifier_clauses modifier_clause;
   1.118 +
   1.119 +modifier_clause_list:
   1.120 +	'{' modifier_clauses '}' ;
   1.121  
   1.122  part:
   1.123  	EVEN | ODD | ALL ;
   1.124  
   1.125  part_clause:
   1.126 -	part input_clause ;
   1.127 +	part modifier_clause_list;
   1.128 +
   1.129 +part_clauses:
   1.130 +	part_clause
   1.131 +	| part_clauses part_clause;
   1.132  
   1.133  input_clause:
   1.134 -	part_clause
   1.135 -	| file_clause | image_clause | rotate_clause
   1.136 -	| crop_clause | size_clause
   1.137 +	file_clause
   1.138 +	| image_clause
   1.139 +	| images_clause
   1.140 +	| modifier_clause
   1.141  	| input_clause_list ;
   1.142  
   1.143  input_clauses:
   1.144 @@ -84,13 +141,21 @@
   1.145  input_statement:
   1.146  	INPUT input_clauses ;
   1.147  
   1.148 +page_range:
   1.149 +	INTEGER ELIPSIS INTEGER
   1.150 +	| INTEGER ;
   1.151 +
   1.152 +page_ranges:
   1.153 +	page_range
   1.154 +	| page_ranges ',' page_range ;
   1.155 +
   1.156  page_clause:
   1.157  	PAGE INTEGER ';'
   1.158 -	| PAGE INTEGER ',' STRING ';' ;
   1.159 +	| PAGE STRING ',' INTEGER ';' ;
   1.160  
   1.161  pages_clause:
   1.162 -	PAGES ranges ';'
   1.163 -	| PAGES ranges ',' STRING ';' ;
   1.164 +	PAGES page_ranges ';'
   1.165 +	| PAGES STRING ',' page_ranges ';' ;
   1.166  
   1.167  bookmark_clause:
   1.168  	BOOKMARK INTEGER ',' STRING ';'
     2.1 --- a/scanner.l	Fri Dec 28 16:04:15 2001 +0000
     2.2 +++ b/scanner.l	Sat Dec 29 10:19:49 2001 +0000
     2.3 @@ -14,19 +14,48 @@
     2.4  \.\.		{ return (ELIPSIS); }
     2.5  
     2.6  {digit}+	{ yylval.integer = atoi (yytext); return (INTEGER); }
     2.7 +{digit}+.{digit}* { yylval.float = atof (yytext); return (FLOAT); }
     2.8 +
     2.9 +a		{ yylval.size.width = 8.5 * 25.4;
    2.10 +		  yylval.size.height = 11.0 * 25.4;
    2.11 +                  return (PAGE_SIZE); }
    2.12 +b		{ yylval.size.width = 11.0 * 25.4;
    2.13 +                  yylval.size.height = 17.0 * 25.4;
    2.14 +                  return (PAGE_SIZE); }
    2.15 +c		{ yylval.size.width = 17.0 * 25.4;
    2.16 +                  yylval.size.height = 22.0 * 25.4;
    2.17 +                  return (PAGE_SIZE); }
    2.18 +d		{ yylval.size.width = 22.0 * 25.4;
    2.19 +                  yylval.size.height = 34.0 * 25.4;
    2.20 +                  return (PAGE_SIZE); }
    2.21 +e		{ yylval.size.width = 34.0 * 25.4;
    2.22 +                   yylval.size.height = 44.0 * 25.4;
    2.23 +                  return (PAGE_SIZE); }
    2.24  
    2.25  all		{ return (ALL); }
    2.26  bookmark	{ return (BOOKMARK); }
    2.27 +cm		{ return (CM); }
    2.28  crop		{ return (CROP); }
    2.29  even		{ return (EVEN); }
    2.30  file		{ return (FILE); }
    2.31  image		{ return (IMAGE); }
    2.32 +images		{ return (IMAGES); }
    2.33 +inch		{ return (INCH); }
    2.34  input		{ return (INPUT); }
    2.35 +landscape	{ return (LANDSCAPE); }
    2.36  odd		{ return (ODD); }
    2.37  output		{ return (OUTPUT); }
    2.38  page		{ return (PAGE); }
    2.39  pages		{ return (PAGES); }
    2.40 +portrait	{ return (PORTRAIT) ; }
    2.41  rotate		{ return (ROTATE); }
    2.42  size		{ return (SIZE); }
    2.43  
    2.44  \".*\"		{ yylval.string = newstr (yytext); return (STRING); }
    2.45 +
    2.46 +[ \t\n]+	/* whitespace */
    2.47 +
    2.48 +--.*		/* Ada/VHDL style one-line comment */
    2.49 +
    2.50 +.		{ printf( "Unrecognized character: %s\n", yytext ); }
    2.51 +