Initial revision

Fri, 28 Dec 2001 04:44:05 +0000

author
eric
date
Fri, 28 Dec 2001 04:44:05 +0000
changeset 5
9eb47d44dab9
parent 4
86a98659662f
child 6
72eb20f1a4ec

Initial revision

parser.y file | annotate | diff | revisions
scanner.l file | annotate | diff | revisions
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/parser.y	Fri Dec 28 04:44:05 2001 +0000
     1.3 @@ -0,0 +1,97 @@
     1.4 +%{
     1.5 +#include <stdio.h>
     1.6 +%}
     1.7 +
     1.8 +%union {
     1.9 +  int integer;
    1.10 +  double fp;
    1.11 +  char *string;
    1.12 +}
    1.13 +
    1.14 +%token <integer> INTEGER
    1.15 +%token <fp> FLOAT
    1.16 +%token <string> STRING
    1.17 +
    1.18 +%token EVEN
    1.19 +%token ODD
    1.20 +%token ALL
    1.21 +
    1.22 +%token FILE
    1.23 +%token IMAGE
    1.24 +%token ROTATE
    1.25 +%token CROP
    1.26 +%token SIZE
    1.27 +%token INPUT
    1.28 +
    1.29 +%token PAGE
    1.30 +%token BOOKMARK
    1.31 +%token OUTPUT
    1.32 +
    1.33 +%type <integer> range
    1.34 +%type <integer> ranges
    1.35 +
    1.36 +%%
    1.37 +
    1.38 +statements: statement | statements statement;
    1.39 +
    1.40 +statement: input_statement | output_statement;
    1.41 +
    1.42 +
    1.43 +range:	INTEGER ".." INTEGER
    1.44 +	| INTEGER;
    1.45 +
    1.46 +ranges:	range
    1.47 +	| ranges ',' range;
    1.48 +
    1.49 +
    1.50 +file_clause:
    1.51 +	FILE STRING  ';' ;
    1.52 +
    1.53 +image_clause:
    1.54 +	IMAGE ranges ';' ;
    1.55 +
    1.56 +rotate_clause:
    1.57 +	ROTATE INTEGER ';' ;
    1.58 +
    1.59 +crop_clause:
    1.60 +	CROP FLOAT ',' FLOAT ';' ;
    1.61 +
    1.62 +size_clause:
    1.63 +	SIZE FLOAT ',' FLOAT ';' ;
    1.64 +
    1.65 +part:
    1.66 +	EVEN | ODD | ALL;
    1.67 +
    1.68 +part_clause:
    1.69 +	part ';' ;
    1.70 +
    1.71 +input_clause:
    1.72 +	part_clause
    1.73 +	| file_clause | image_clause | rotate_clause
    1.74 +	| crop_clause | size_clause;
    1.75 +
    1.76 +input_clauses:
    1.77 +	input_clause
    1.78 +	| input_clauses input_clause;
    1.79 +
    1.80 +input_statement:
    1.81 +	INPUT '{' input_clauses '}' ;
    1.82 +
    1.83 +
    1.84 +page_clause:
    1.85 +	PAGE ranges ';'
    1.86 +	| PAGE ranges ',' STRING ';' ;
    1.87 +
    1.88 +bookmark_clause:
    1.89 +	BOOKMARK STRING ';' ;
    1.90 +
    1.91 +output_clause:
    1.92 +	page_clause | bookmark_clause;
    1.93 +
    1.94 +output_clauses:
    1.95 +	output_clause
    1.96 +	| output_clauses output_clause;
    1.97 +
    1.98 +output_statement:
    1.99 +	OUTPUT '{' output_clauses '}' ;
   1.100 +
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/scanner.l	Fri Dec 28 04:44:05 2001 +0000
     2.3 @@ -0,0 +1,29 @@
     2.4 +%option case-insensitive
     2.5 +
     2.6 +/*
     2.7 +%{
     2.8 +#include "parser.tab.h"
     2.9 +}%
    2.10 +*/
    2.11 +
    2.12 +digit [0-9]
    2.13 +alpha [a-zA-Z]
    2.14 +
    2.15 +%%
    2.16 +
    2.17 +{digit}+	{ yylval.integer = atoi (yytext); return (INTEGER); }
    2.18 +
    2.19 +all		{ return (ALL); }
    2.20 +bookmark	{ return (BOOKMARK); }
    2.21 +crop		{ return (CROP); }
    2.22 +even		{ return (EVEN); }
    2.23 +file		{ return (FILE); }
    2.24 +image		{ return (IMAGE); }
    2.25 +input		{ return (INPUT); }
    2.26 +odd		{ return (ODD); }
    2.27 +output		{ return (OUTPUT); }
    2.28 +page		{ return (PAGE); }
    2.29 +rotate		{ return (ROTATE); }
    2.30 +size		{ return (SIZE); }
    2.31 +
    2.32 +\".*\"		{ yylval.string = newstr (yytext); return (STRING); }