pswparser.y revision 824
824N/A/*
824N/A * pswparser.y
824N/A *
824N/A * (c) Copyright 1988-1994 Adobe Systems Incorporated.
824N/A * All rights reserved.
824N/A *
824N/A * Permission to use, copy, modify, distribute, and sublicense this software
824N/A * and its documentation for any purpose and without fee is hereby granted,
824N/A * provided that the above copyright notices appear in all copies and that
824N/A * both those copyright notices and this permission notice appear in
824N/A * supporting documentation and that the name of Adobe Systems Incorporated
824N/A * not be used in advertising or publicity pertaining to distribution of the
824N/A * software without specific, written prior permission. No trademark license
824N/A * to use the Adobe trademarks is hereby granted. If the Adobe trademark
824N/A * "Display PostScript"(tm) is used to describe this software, its
824N/A * functionality or for any other purpose, such use shall be limited to a
824N/A * statement that this software works in conjunction with the Display
824N/A * PostScript system. Proper trademark attribution to reflect Adobe's
824N/A * ownership of the trademark shall be given whenever any such reference to
824N/A * the Display PostScript system is made.
824N/A *
824N/A * ADOBE MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE SOFTWARE FOR
824N/A * ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
824N/A * ADOBE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
824N/A * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
824N/A * NON- INFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL ADOBE BE LIABLE
824N/A * TO YOU OR ANY OTHER PARTY FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL
824N/A * DAMAGES OR ANY DAMAGES WHATSOEVER WHETHER IN AN ACTION OF CONTRACT,
824N/A * NEGLIGENCE, STRICT LIABILITY OR ANY OTHER ACTION ARISING OUT OF OR IN
824N/A * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ADOBE WILL NOT
824N/A * PROVIDE ANY TRAINING OR OTHER SUPPORT FOR THE SOFTWARE.
824N/A *
824N/A * Adobe, PostScript, and Display PostScript are trademarks of Adobe Systems
824N/A * Incorporated which may be registered in certain jurisdictions
824N/A *
824N/A * Author: Adobe Systems Incorporated
824N/A */
824N/A/* $XFree86: xc/config/pswrap/pswparser.y,v 1.4 2000/05/18 23:46:08 dawes Exp $ */
824N/A
824N/A/*
824N/A * Not all yaccs understand this.
824N/A *
824N/A%expect 1
824N/A */
824N/A
824N/A%{
824N/A
824N/A#include "pswpriv.h"
824N/A#include "pswsemantics.h"
824N/A
824N/A%}
824N/A
824N/A/* yylval type (from lexer and on stack) */
824N/A
824N/A%union {
824N/A char *object;
824N/A long intobj;
824N/A Token token;
824N/A Item item;
824N/A Header header;
824N/A int flag;
824N/A Arg arg;
824N/A Subscript subscript;
824N/A}
824N/A
824N/A
824N/A%token <object> DEFINEPS ENDPS STATIC
824N/A%token <object> PSCONTEXT
824N/A%token <object> BOOLEAN FLOAT DOUBLE UNSIGNED SHORT LONG INT CHAR USEROBJECT
824N/A%token <object> NUMSTRING
824N/A%token <object> CNAME
824N/A%token <intobj> CINTEGER
824N/A
824N/A%token <object> PSNAME PSLITNAME PSREAL PSBOOLEAN PSSTRING PSHEXSTRING
824N/A%token <intobj> PSINTEGER
824N/A%token <object> PSSUBNAME PSINDEX
824N/A
824N/A%token <object> '(' ')' '|' ';' ',' '*' '[' ']' '{' '}' ':'
824N/A
824N/A%type <token> Token Tokens Body
824N/A%type <item> Items Item
824N/A%type <header> Header
824N/A%type <flag> Def Type
824N/A%type <arg> InArgs Args ContextArg SubArgs Arg
824N/A%type <subscript> Subscript
824N/A
824N/A%start Module
824N/A
824N/A%%
824N/A
824N/AModule:
824N/A /* empty */
824N/A | Module Definition
824N/A ;
824N/A
824N/ADefinition:
824N/A Header Body ENDPS
824N/A { FinalizePSWrapDef($1, $2); yyerrok; }
824N/A | error ENDPS
824N/A { yyerrok; }
824N/A ;
824N/A
824N/ABody:
824N/A /* nothing */
824N/A { $$ = 0; }
824N/A | Tokens
824N/A /* { $$ = $1; }*/
824N/A ;
824N/A
824N/ATokens:
824N/A Token
824N/A { $$ = AppendPSWToken($1, 0L); }
824N/A | Tokens Token
824N/A { $$ = AppendPSWToken($2, $1); yyerrok; }
824N/A /* | error
824N/A { $$ = 0; } */
824N/A ;
824N/A
824N/AHeader:
824N/A Def ')'
824N/A { $$ = PSWHeader($1, 0, 0); yyerrok; }
824N/A | Def InArgs ')'
824N/A { $$ = PSWHeader($1, $2, 0); yyerrok; }
824N/A | Def InArgs '|' Args ')'
824N/A { $$ = PSWHeader($1, $2, $4); yyerrok; }
824N/A | Def '|' Args ')'
824N/A { $$ = PSWHeader($1, 0, $3); yyerrok; }
824N/A ;
824N/A
824N/ADef:
824N/A DEFINEPS CNAME '('
824N/A { PSWName($2); $$ = 0; yyerrok; }
824N/A | DEFINEPS STATIC CNAME '('
824N/A { PSWName($3); $$ = 1; yyerrok; }
824N/A | DEFINEPS error '('
824N/A { PSWName("error"); $$ = 0; yyerrok; }
824N/A ;
824N/A
824N/ASemi:
824N/A /* nothing */
824N/A | ';' { yyerrok; }
824N/A ;
824N/A
824N/AInArgs:
824N/A ContextArg Semi
824N/A /* { $$ = $1; } */
824N/A | Args
824N/A /* { $$ = $1; } */
824N/A | ContextArg ';' Args
824N/A { $$ = ConsPSWArgs($1, $3); }
824N/A ;
824N/A
824N/AContextArg:
824N/A PSCONTEXT CNAME
824N/A { $$ = PSWArg(T_CONTEXT, PSWItem($2)); }
824N/A ;
824N/A
824N/AArgs:
824N/A SubArgs Semi
824N/A /* { $$ = $1; }*/
824N/A ;
824N/A
824N/ASubArgs:
824N/A Arg
824N/A /* { $$ = $1; }*/
824N/A | SubArgs ';' Arg
824N/A { yyerrok; $$ = AppendPSWArgs($3, $1); }
824N/A | SubArgs error
824N/A | SubArgs error Arg
824N/A { yyerrok; $$ = AppendPSWArgs($3, $1); }
824N/A | SubArgs ';' error
824N/A ;
824N/A
824N/AArg: Type Items
824N/A { $$ = PSWArg($1, $2); yyerrok; }
824N/A ;
824N/A
824N/AItems:
824N/A Item
824N/A /* { $$ = $1; } */
824N/A | Items ',' Item
824N/A { yyerrok; $$ = AppendPSWItems($3, $1); }
824N/A | error { $$ = 0; }
824N/A | Items error
824N/A | Items error Item
824N/A { yyerrok; $$ = AppendPSWItems($3, $1); }
824N/A | Items ',' error
824N/A ;
824N/A
824N/AItem:
824N/A '*' CNAME
824N/A { $$ = PSWStarItem($2); }
824N/A | CNAME '[' Subscript ']'
824N/A { $$ = PSWSubscriptItem($1, $3); }
824N/A | CNAME '[' Subscript ']' ':' CNAME
824N/A { $$ = PSWScaleItem($1, $3, $6, 0); }
824N/A | CNAME '[' Subscript ']' ':' CINTEGER
824N/A { $$ = PSWScaleItem($1, $3, NULL, $6); }
824N/A | CNAME
824N/A { $$ = PSWItem($1); }
824N/A ;
824N/A
824N/ASubscript:
824N/A CNAME
824N/A { $$ = PSWNameSubscript($1); }
824N/A | CINTEGER
824N/A { $$ = PSWIntegerSubscript($1); }
824N/A ;
824N/A
824N/AType:
824N/A BOOLEAN
824N/A { $$ = T_BOOLEAN; }
824N/A | FLOAT
824N/A { $$ = T_FLOAT; }
824N/A | DOUBLE
824N/A { $$ = T_DOUBLE; }
824N/A | CHAR
824N/A { $$ = T_CHAR; }
824N/A | UNSIGNED CHAR
824N/A { $$ = T_UCHAR; }
824N/A | INT
824N/A { $$ = T_INT; }
824N/A | LONG INT
824N/A { $$ = T_LONGINT; }
824N/A | LONG
824N/A { $$ = T_LONGINT; }
824N/A | SHORT INT
824N/A { $$ = T_SHORTINT; }
824N/A | SHORT
824N/A { $$ = T_SHORTINT; }
824N/A | UNSIGNED
824N/A { $$ = T_UINT; }
824N/A | UNSIGNED LONG
824N/A { $$ = T_ULONGINT; }
824N/A | UNSIGNED INT
824N/A { $$ = T_UINT; }
824N/A | UNSIGNED LONG INT
824N/A { $$ = T_ULONGINT; }
824N/A | UNSIGNED SHORT
824N/A { $$ = T_USHORTINT; }
824N/A | UNSIGNED SHORT INT
824N/A { $$ = T_USHORTINT; }
824N/A | USEROBJECT
824N/A { $$ = T_USEROBJECT; }
824N/A | NUMSTRING
824N/A { $$ = T_NUMSTR; }
824N/A | INT NUMSTRING
824N/A { $$ = T_NUMSTR; }
824N/A | FLOAT NUMSTRING
824N/A { $$ = T_FLOATNUMSTR; }
824N/A | LONG NUMSTRING
824N/A { $$ = T_LONGNUMSTR; }
824N/A | SHORT NUMSTRING
824N/A { $$ = T_SHORTNUMSTR; }
824N/A ;
824N/A
824N/AToken:
824N/A PSINTEGER
824N/A { $$ = PSWToken(T_INT, (char *)$1); }
824N/A | PSREAL
824N/A { $$ = PSWToken(T_FLOAT, $1); }
824N/A | PSBOOLEAN
824N/A { $$ = PSWToken(T_BOOLEAN, $1); }
824N/A | PSSTRING
824N/A { $$ = PSWToken(T_STRING, $1); }
824N/A | PSHEXSTRING
824N/A { $$ = PSWToken(T_HEXSTRING, $1); }
824N/A | PSNAME
824N/A { $$ = PSWToken(T_NAME, $1); }
824N/A | PSLITNAME
824N/A { $$ = PSWToken(T_LITNAME, $1); }
824N/A | PSSUBNAME PSINDEX
824N/A { $$ = PSWToken2(T_SUBSCRIPTED, $1, $2); }
824N/A | '[' Body ']'
824N/A { $$ = PSWToken(T_ARRAY, (char *)$2); }
824N/A | '{' Body '}'
824N/A { $$ = PSWToken(T_PROC, (char *)$2); }
824N/A ;