change 'format' to 'label', add character type, track bookmark level.

Tue, 01 Jan 2002 03:46:08 +0000

author
eric
date
Tue, 01 Jan 2002 03:46:08 +0000
changeset 27
7a28031fe457
parent 26
4368c5fd9242
child 28
ba8313d18bd3

change 'format' to 'label', add character type, track bookmark level.

parser.y file | annotate | diff | revisions
scanner.l file | annotate | diff | revisions
     1.1 --- a/parser.y	Tue Jan 01 03:44:40 2002 +0000
     1.2 +++ b/parser.y	Tue Jan 01 03:46:08 2002 +0000
     1.3 @@ -6,15 +6,18 @@
     1.4  
     1.5  %union {
     1.6    int integer;
     1.7 +  char character;
     1.8    double fp;
     1.9    char *string;
    1.10    page_size_t size;
    1.11    range_t range;
    1.12 +  page_label_t page_label;
    1.13  }
    1.14  
    1.15  %token <integer> INTEGER
    1.16  %token <fp> FLOAT
    1.17  %token <string> STRING
    1.18 +%token <character> CHARACTER
    1.19  %token <size> PAGE_SIZE
    1.20  
    1.21  %token ELIPSIS
    1.22 @@ -38,7 +41,7 @@
    1.23  %token RESOLUTION
    1.24  %token INPUT
    1.25  
    1.26 -%token FORMAT
    1.27 +%token LABEL
    1.28  %token PAGE
    1.29  %token PAGES
    1.30  %token BOOKMARK
    1.31 @@ -151,8 +154,11 @@
    1.32  output_file_clause:
    1.33  	FILE_KEYWORD STRING  ';' { output_set_file ($2) } ;
    1.34  
    1.35 -format_clause:
    1.36 -	FORMAT STRING ';' { output_set_page_number_format ($2) } ;
    1.37 +label_clause:
    1.38 +	LABEL ';' { page_label_t label = { NULL, '\0' }; output_set_page_label (label); }
    1.39 +	| LABEL STRING ';' { page_label_t label = { $2, '\0' }; output_set_page_label (label); }
    1.40 +	| LABEL CHARACTER ';' { page_label_t label = { NULL, $2 }; output_set_page_label (label); }
    1.41 +	| LABEL STRING ',' CHARACTER ';' { page_label_t label = { $2, $4 }; output_set_page_label (label); } ;
    1.42  
    1.43  page_ranges:
    1.44  	range { output_pages ($1); }
    1.45 @@ -172,13 +178,13 @@
    1.46  	| bookmark_name_list ',' bookmark_name ;
    1.47  
    1.48  bookmark_clause:
    1.49 -	BOOKMARK { output_push_context (); }
    1.50 +	BOOKMARK { output_push_context (); bookmark_level++; }
    1.51  	bookmark_name_list
    1.52 -	output_clause_list ';' { output_pop_context (); } ;
    1.53 +	output_clause_list ';' { bookmark_level--; output_pop_context (); } ;
    1.54  
    1.55  output_clause:
    1.56  	output_file_clause
    1.57 -	| format_clause
    1.58 +	| label_clause
    1.59  	| page_clause | pages_clause
    1.60  	| bookmark_clause
    1.61  	| output_clause_list ;
     2.1 --- a/scanner.l	Tue Jan 01 03:44:40 2002 +0000
     2.2 +++ b/scanner.l	Tue Jan 01 03:46:08 2002 +0000
     2.3 @@ -1,5 +1,5 @@
     2.4  /*
     2.5 -$Id: scanner.l,v 1.11 2001/12/30 23:25:08 eric Exp $
     2.6 +$Id: scanner.l,v 1.12 2001/12/31 19:46:08 eric Exp $
     2.7  */
     2.8  
     2.9  %option case-insensitive
    2.10 @@ -54,11 +54,11 @@
    2.11  crop		{ return (CROP); }
    2.12  even		{ return (EVEN); }
    2.13  file		{ return (FILE_KEYWORD); }
    2.14 -format		{ return (FORMAT); }
    2.15  image		{ return (IMAGE); }
    2.16  images		{ return (IMAGES); }
    2.17  inch		{ return (INCH); }
    2.18  input		{ return (INPUT); }
    2.19 +label		{ return (LABEL); }
    2.20  landscape	{ return (LANDSCAPE); }
    2.21  odd		{ return (ODD); }
    2.22  output		{ return (OUTPUT); }
    2.23 @@ -69,7 +69,12 @@
    2.24  rotate		{ return (ROTATE); }
    2.25  size		{ return (SIZE); }
    2.26  
    2.27 -\"[^\n"]*\"		{ 
    2.28 +'[^\n']'	{
    2.29 +		  yylval.character = yytext [1];
    2.30 +		  return (CHARACTER);
    2.31 +		}
    2.32 +
    2.33 +\"[^\n"]*\"	{
    2.34                    int len = strlen (yytext) - 2;
    2.35                    yylval.string = malloc (len + 1);
    2.36                    memcpy (yylval.string, yytext + 1, len);