pr_gramm.y
上传用户:hzhsqp
上传日期:2007-01-06
资源大小:1600k
文件大小:26k
- %{
- /*
- * pr_gramm.y
- *
- * Resource compiler grammar
- *
- * Portable Windows Library
- *
- * Copyright (c) 1993-1998 Equivalence Pty. Ltd.
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.0 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- * the License for the specific language governing rights and limitations
- * under the License.
- *
- * The Original Code is Portable Windows Library.
- *
- * The Initial Developer of the Original Code is Equivalence Pty. Ltd.
- *
- * Portions are Copyright (C) 1993 Free Software Foundation, Inc.
- * All Rights Reserved.
- *
- * Contributor(s): ______________________________________.
- *
- * $Log: pr_gramm.y,v $
- * Revision 1.26 1998/11/27 11:30:26 craigs
- * Fixed problem with memory checking conflicting with bison defines
- *
- * Revision 1.26 1998/11/27 11:30:26 craigs
- * Fixed problem with memory checking conflicting with bison defines
- *
- * Revision 1.25 1998/09/26 01:24:13 robertj
- * Added open source license
- *
- * Revision 1.24 1998/09/26 00:39:37 robertj
- * Fixed name space conflict with type Cursor.
- *
- * Revision 1.23 1998/09/14 13:47:26 robertj
- * Allowed consecutive string literals to be used as single string in more syntactic places.
- *
- * Revision 1.22 1996/01/23 13:32:44 robertj
- * More changes for editor
- *
- * Revision 1.21 1995/12/23 03:54:26 robertj
- * Added extra structures for editor use.
- *
- * Revision 1.20 1995/12/10 12:12:03 robertj
- * Changes to support graphical resource file editor.
- *
- * Revision 1.19 1995/10/14 15:19:12 robertj
- * Fixed missing font size on font keyword.
- * Changes required by move of standard buttons to PDialog.
- *
- * Revision 1.18 1995/08/24 12:48:05 robertj
- * Added general control type for arbitrary dialog controls.
- *
- * Revision 1.17 1995/07/31 12:30:12 robertj
- * Changed all generated resource IDs to be in the same "number space". This
- * is to avoid problems with IDs being used for more than one type of resource
- * eg a menu item and an image for a toolbar.
- * Fixed the generated #line commands to include a relative path instead of an
- * absolute one.
- *
- * Revision 1.16 1995/04/02 09:28:15 robertj
- * Added "balloon" help.
- *
- * Revision 1.15 1995/02/19 04:19:27 robertj
- * Added dynamically linked command processing.
- *
- * Revision 1.14 1995/01/27 11:25:41 robertj
- * Added pattern resource.
- *
- * Revision 1.13 1994/12/12 13:14:02 robertj
- * Changed RealEdit to FloatEdit.
- *
- * Revision 1.12 1994/12/05 11:38:00 robertj
- * Added #line to generated code.
- *
- * Revision 1.11 1994/07/02 03:30:08 robertj
- * Restored header keyword accidentally deleted.
- *
- * Revision 1.9 1994/04/20 12:47:01 robertj
- * *** empty log message ***
- *
- * Revision 1.8 1994/04/01 14:29:16 robertj
- * New format PRC file
- *
- * Revision 1.7 1993/12/31 07:05:07 robertj
- * Changed pixmap images for one pixel one number in PRC file.
- *
- * Revision 1.6 1993/12/01 16:12:09 robertj
- * Windows NT port.
- *
- * Revision 1.5 1993/11/30 18:40:23 robertj
- * Some formatting changes
- *
- * Revision 1.4 1993/08/20 21:31:56 robertj
- * Fixed bug with freeing freed pointer.
- * Optimised some code regarding converting char * to PString.
- *
- * Revision 1.3 1993/07/16 12:48:13 robertj
- * Changed resource string dictionary to ResourceObject as consequence of
- * getting converted C literal strings.
- * Removed redundant parameter from AddResource function.
- *
- * Revision 1.2 1993/07/15 04:38:31 robertj
- * Rationalised lex.h, parse.h and main.h out of existance.
- *
- * Revision 1.1 1993/07/03 06:01:44 robertj
- * Initial revision
- *
- * Revision 1.1 1993/06/24 19:23:17 craigs
- * Initial revision
- *
- */
- #include <ptlib.h>
- #undef calloc
- #undef malloc
- #undef free
- #undef realloc
- #include "pwrc.h"
- // nasty globals used to store ptr to current control and layout
- ResourceFile * current_file;
- ostream * inline_src;
- ostream * inline_hdr;
- static MenuBar * current_menubar;
- static MenuItem * current_item;
- static Control * current_control;
- static Layout * current_layout;
- extern int yylex();
- /////////////////////////////////////////
- //
- // yyerror
- // required function for flex
- //
- void yyerror(char * str)
- {
- extern char * yytext;
- PError << StdError(Fatal) << str << " near token "" << yytext <<""n";
- }
- %}
- %token MENU
- %token ACCELERATORS
- %token BEGIN_token
- %token END
- %token ITEM
- %token SEPARATOR
- %token ICON
- %token CURSOR
- %token PATTERN_token
- %token IMAGE
- %token STRING
- %token MENUBAR
- %token DIALOG
- %token DIMENSIONS
- %token POSITION
- %token FONT
- %token DEFPUSHBUTTON
- %token PUSHBUTTON
- %token CHECK3WAY
- %token CHECKBOX
- %token RADIOBUTTON
- %token LEFTTEXT
- %token CENTRETEXT
- %token RIGHTTEXT
- %token STATICBOX
- %token EDITBOX
- %token INTEDIT
- %token FLOATEDIT
- %token TEXTEDITOR
- %token CHOICEBOX
- %token LISTBOX
- %token COMBOBOX
- %token HSCROLLBAR
- %token VSCROLLBAR
- %token STATICICON
- %token SORTED
- %token MULTISELECT
- %token MULTICOLUMN
- %token HOTSPOT
- %token ANDMASK
- %token XORMASK
- %token PIXELS
- %token COLOURS
- %token RESOURCE
- %token CLASS
- %token LAYOUT
- %token MODALDIALOG
- %token FIELD
- %token VALUE
- %token NOTIFY
- %token TITLE
- %token ID
- %token OPTIONS
- %token CANCEL
- %token HELP
- %token OK
- %token DEFAULT
- %token WINDOW
- %token PASSWORDBOX
- %token STRINGLIST
- %token LIMITS
- %token HEADER
- %token CONTROL
- %token HASH_DEFINE
- %token END_DEFINE
- %token <sval> LITERAL
- %token <sval> IDENTIFIER
- %token <ival> INTEGER
- %token '{'
- %token '}'
- %token ';'
- %token '+'
- %token '-'
- %token '*'
- %token '/'
- %token '('
- %token ')'
- %token ','
- %type <ival> expression option option_list
- %type <sval> opt_resname literal_list title_decl field_decl
- %type <sval> classsed_identifier
- %type <resid> string_id menu_id item_id layout_id control_id
- %type <resid> icon_id cursor_id pattern_id image_id data_id
- %type <menulist> menu_decls
- %type <menu> menu_decl
- %type <itemlist> menu_items
- %type <item> item_decl
- %type <separator> separator_decl
- %type <pixels> pix_block pixels
- %type <binary> data_block data_items
- %type <strlist> string_list string_list_block
- %type <pixcontent> icon_items cursor_items pattern_items image_items
- %type <defvalue> define_expression
- %type <point> pos_decl dim_decl
- %type <layout> layout_base_class
- %type <control> control_base_class
- %type <classes> class_decl
- %union {
- long ival;
- PString *sval;
- ResourceID *resid;
- MenuList *menulist;
- Menu *menu;
- MenuItemList *itemlist;
- MenuItem *item;
- Separator *separator;
- BinaryData *binary;
- PixData *pixels;
- PStringList *strlist;
- PixelContents *pixcontent;
- DefineValue *defvalue;
- Point *point;
- Control *control;
- Layout *layout;
- ClassedResource *classes;
- }
- %left '+' '-'
- %left '*' '/'
- %left UMINUS
- %%
- file: /* empty */
- | file resource
- | file define
- ;
- resource: menubar_resource
- | string_resource
- | icon_resource
- | cursor_resource
- | pattern_resource
- | image_resource
- | data_resource
- | layout_resource
- ;
- /***************************************************************************
- Pre-processor rules
- ***************************************************************************/
- define: HASH_DEFINE IDENTIFIER define_expression END_DEFINE
- { current_file->AddDefineIdentifier($2, $3); }
- ;
- define_expression: /* empty */
- { $$ = new DefineValue(1, FALSE); }
- | expression
- { $$ = new DefineValue($1, FALSE); }
- | literal_list
- {
- $$ = new DefineValue(*$1);
- delete $1;
- }
- ;
- expression: INTEGER
- /* */
- | IDENTIFIER
- { $$ = current_file->GetIdentifierValue($1); }
- | expression '+' expression
- { $$ = $1 + $3; }
- | expression '-' expression
- { $$ = $1 - $3; }
- | expression '/' expression
- { $$ = $1 / $3; }
- | expression '*' expression
- { $$ = $1 * $3; }
- | '(' expression ')'
- { $$ = $2; }
- | '-' expression %prec UMINUS
- { $$ = -($2); }
- ;
- /***************************************************************************
- String resources
- ***************************************************************************/
- string_resource: STRING opt_separator string_id opt_separator literal_list ';'
- { current_file->AddResource(ResourceList::StringRes,
- new StringResource($3, $5), "string"); }
- ;
- string_id: expression
- { $$ = new ResourceID($1); }
- | '@' IDENTIFIER
- { $$ = current_file->GetAutoIdentifier($2, current_file->stringDict); }
- ;
- /***************************************************************************
- Menu resources
- ***************************************************************************/
- menubar_resource: MENUBAR menu_id block_begin
- {
- current_menubar = new MenuBar($2);
- inline_src = ¤t_menubar->src_before;
- inline_hdr = ¤t_menubar->hdr_before;
- }
- menubar_decls menu_decls
- {
- inline_src = ¤t_menubar->src_after;
- inline_hdr = ¤t_menubar->hdr_after;
- current_menubar->SetMenuList($6);
- }
- block_end
- {
- current_file->AddResource(ResourceList::MenubarRes,
- current_menubar, "menubar");
- inline_src = ¤t_file->src_inline;
- inline_hdr = ¤t_file->hdr_inline;
- }
- ;
- menu_id: /* empty */
- { $$ = NULL; }
- | expression
- { $$ = new ResourceID($1); }
- | '@' IDENTIFIER
- { $$ = current_file->GetAutoIdentifier($2, current_file->menubarDict); }
- ;
- menubar_decls: /* nothing */
- | menubar_decls menubar_decl
- ;
- menubar_decl: class_decl
- {
- current_menubar->SetResClass($1->GetResClass());
- if ($1->GetAncestorClass().IsEmpty())
- current_menubar->SetAncestorClass("PRootMenu");
- else
- current_menubar->SetAncestorClass($1->GetAncestorClass());
- delete $1;
- }
- | WINDOW IDENTIFIER ';'
- { current_menubar->SetWindow($2); }
- | ID item_id ';'
- { current_menubar->SetID($2); }
- ;
- menu_decls: menu_decl
- {
- $$ = new MenuList();
- $$->Append($1);
- }
- | menu_decls menu_decl
- {
- $1->Append($2);
- $$ = $1;
- }
- ;
- menu_decl: MENU literal_list block_begin menu_items block_end
- { $$ = new Menu($2, $4); }
- ;
- menu_items: /* empty */
- { $$ = new MenuItemList (); }
- | menu_items item_decl
- { $1->Append($2); }
- | menu_items menu_decl
- { $1->Append($2); }
- | menu_items separator_decl
- { $1->Append($2); }
- ;
- item_decl: ITEM item_id block_begin
- {
- current_item = new MenuItem($2);
- inline_src = ¤t_item->src_before;
- inline_hdr = ¤t_item->hdr_before;
- }
- item_body block_end
- {
- inline_src = ¤t_item->src_after;
- inline_hdr = ¤t_item->hdr_after;
- if (current_item->GetID() != -1)
- current_menubar->itemDict.SetAt(current_item->GetID(), current_item);
- $$ = current_item;
- }
- ;
- item_id: /* empty */
- { $$ = NULL; }
- | expression
- { $$ = new ResourceID($1); }
- | '@' IDENTIFIER
- { $$ = current_file->GetAutoIdentifier($2, current_menubar->itemDict); }
- ;
- item_body: item_attr
- | item_body item_attr
- ;
- item_attr: title_decl
- { current_item->SetText($1); }
- | field_decl
- { current_item->SetFieldName($1); }
- | NOTIFY classsed_identifier ';'
- { current_item->SetNotify($2); }
- | NOTIFY LITERAL ';'
- { current_item->SetNotify($2); }
- | ID item_id ';'
- {
- if (current_menubar->itemDict.GetAt($2->GetNum()) != NULL)
- PError << StdError(Fatal)
- << "cannot use menu item identifier more than once.n";
- current_item->SetID($2);
- }
- | ACCELERATORS literal_list ';'
- {
- PStringList * list = new PStringList();
- list->Append($2);
- current_item->SetAccelerators(list);
- }
- | ACCELERATORS string_list_block
- { current_item->SetAccelerators($2); }
- ;
- separator_decl: SEPARATOR ';'
- { $$ = new Separator(); }
- ;
- /***************************************************************************
- layout/dialog/modaldialog resource
- ***************************************************************************/
- layout_resource: layout_base_class layout_id block_begin
- {
- current_layout = $1;
- current_layout->SetID($2);
- inline_src = ¤t_layout->src_before;
- inline_hdr = ¤t_layout->hdr_before;
- }
- layout_decls control_decls
- {
- inline_src = ¤t_layout->src_after;
- inline_hdr = ¤t_layout->hdr_after;
- current_layout->SetUniqueItemIDs();
- }
- block_end
- {
- current_file->AddResource(ResourceList::LayoutRes,
- current_layout, "dialog");
- inline_src = ¤t_file->src_inline;
- inline_hdr = ¤t_file->hdr_inline;
- }
- ;
- layout_id: /* empty */
- { $$ = NULL; }
- | expression
- { $$ = new ResourceID($1); }
- | '@' IDENTIFIER
- { $$ = current_file->GetAutoIdentifier($2, current_file->dialogDict); }
- ;
- layout_base_class:
- LAYOUT
- { $$ = new Layout("PInteractorLayout", 0); }
- | DIALOG
- { $$ = new Layout("PDialog", 1); }
- | MODALDIALOG
- { $$ = new Layout("PModalDialog", 2); }
- ;
- layout_decls: layout_decl
- | layout_decls layout_decl
- ;
- layout_decl: ID layout_id ';'
- { current_layout->SetID($2); }
- | pos_decl
- { current_layout->SetPos($1); }
- | dim_decl
- { current_layout->SetDim($1); }
- | title_decl
- { current_layout->SetText($1); }
- | class_decl
- {
- current_layout->SetResClass($1->GetResClass());
- if (!$1->GetAncestorClass().IsEmpty())
- current_layout->SetAncestorClass($1->GetAncestorClass());
- delete $1;
- }
- | FONT literal_list opt_separator expression ';'
- { current_layout->SetFontInfo($2, $4); }
- | HEADER literal_list ';'
- { current_layout->SetHeader($2); }
- ;
- control_decls: control_decl
- | control_decls control_decl
- ;
- control_decl: control_base_class control_id block_begin
- {
- current_control = $1;
- current_control->SetID($2);
- inline_src = ¤t_control->src_before;
- inline_hdr = ¤t_control->hdr_before;
- }
- opt_control_attr_decls block_end
- {
- current_layout->AddControl(current_control);
- inline_src = ¤t_control->src_after;
- inline_hdr = ¤t_control->hdr_after;
- }
- ;
- control_id: /* empty */
- { $$ = NULL; }
- | expression
- { $$ = new ResourceID($1); }
- | '@' IDENTIFIER
- { $$ = current_file->GetAutoIdentifier($2, current_layout->itemDict); }
- ;
- control_base_class: PUSHBUTTON
- { $$ = new PushButton(); }
- | CHECK3WAY
- { $$ = new Check3Way(); }
- | CHECKBOX
- { $$ = new CheckBox(); }
- | RADIOBUTTON
- { $$ = new RadioButton(); }
- | LEFTTEXT
- { $$ = new LeftText(); }
- | CENTRETEXT
- { $$ = new CentreText(); }
- | RIGHTTEXT
- { $$ = new RightText(); }
- | STATICBOX
- { $$ = new StaticBox(); }
- | EDITBOX
- { $$ = new EditBox(); }
- | INTEDIT
- { $$ = new IntEditBox(); }
- | FLOATEDIT
- { $$ = new FloatEditBox(); }
- | TEXTEDITOR
- { $$ = new TextEditor(); }
- | PASSWORDBOX
- { $$ = new Password(); }
- | CHOICEBOX
- { $$ = new ChoiceBox(); }
- | LISTBOX
- { $$ = new ListBox(); }
- | COMBOBOX
- { $$ = new ComboBox(); }
- | HSCROLLBAR
- { $$ = new HScrollBar(); }
- | VSCROLLBAR
- { $$ = new VScrollBar(); }
- | STATICICON
- { $$ = new StaticIcon(); }
- | CONTROL
- { $$ = new UserControl(); }
- ;
- opt_control_attr_decls: /* empty */
- | opt_control_attr_decls control_attr_decl
- ;
- control_attr_decl: ID control_id ';'
- { current_control->SetID($2); }
- | pos_decl
- { current_control->SetPos($1); }
- | dim_decl
- { current_control->SetDim($1); }
- | title_decl
- { current_control->SetText($1); }
- | class_decl
- {
- current_control->SetResClass($1->GetResClass());
- if (!$1->GetAncestorClass().IsEmpty())
- PError << StdError(Warning)
- << "cannot specify ancestor class on control.n";
- delete $1;
- }
- | field_decl
- { current_control->SetFieldName($1); }
- | NOTIFY classsed_identifier ';'
- { current_control->SetNotify($2); }
- | NOTIFY LITERAL
- { current_control->SetNotify($2); }
- | VALUE classsed_identifier ';'
- { current_control->SetValueName($2, new PString()); }
- | VALUE IDENTIFIER '=' literal_list ';'
- { current_control->SetValueName($2, $4); }
- | VALUE IDENTIFIER '=' expression ';'
- { current_control->SetValueName($2, new PString(psprintf("%li", $4))); }
- | ICON expression ';'
- { current_control->SetIcon($2); }
- | HELP literal_list ';'
- { current_control->SetHelp($2); }
- | OPTIONS option_list ';'
- { current_control->SetOptions($2); }
- | LIMITS expression ',' expression ',' expression ',' expression ';'
- { current_control->SetLimits($2, $4, $6, $8); }
- | STRINGLIST string_list_block
- { current_control->SetStringList($2); }
- ;
- option_list: option
- { $$ = $1 }
- | option_list option
- { $$ = $1 | $2; }
- | option_list ',' option
- { $$ = $1 | $3; }
- ;
- option: SORTED
- { $$ = SortedOption; }
- | MULTISELECT
- { $$ = MultiSelectOption; }
- | MULTICOLUMN
- { $$ = MultiColumnOption; }
- | DEFAULT
- { $$ = DefaultButtonOption; }
- | OK
- { $$ = OkButtonOption; }
- | CANCEL
- { $$ = CancelButtonOption; }
- | HELP
- { $$ = HelpButtonOption; }
- ;
- pos_decl: POSITION expression ',' expression ';'
- { $$ = new Point ($2, $4); }
- ;
- dim_decl: DIMENSIONS expression ',' expression ';'
- { $$ = new Point ($2, $4); }
- ;
- title_decl: TITLE literal_list ';'
- { $$ = $2; }
- ;
- class_decl: CLASS IDENTIFIER ';'
- { $$ = new ClassedResource($2); }
- | CLASS IDENTIFIER ':' IDENTIFIER ';'
- { $$ = new ClassedResource($2, $4); }
- ;
- field_decl: FIELD classsed_identifier ';'
- { $$ = $2; }
- ;
- classsed_identifier: IDENTIFIER
- { $$ = $1; }
- | ':' ':' IDENTIFIER
- { $$ = new PString("::" + *$3); delete $3; }
- | IDENTIFIER ':' ':' IDENTIFIER
- { $$ = new PString(*$1 + "::" + *$4); delete $1; delete $4; }
- ;
- /***************************************************************************
- Icon resources
- ***************************************************************************/
- icon_resource: ICON opt_separator icon_id block_begin icon_items block_end
- { current_file->AddResource(ResourceList::IconRes,
- new Icon ($3, $5), "icon"); }
- ;
- icon_id: expression
- { $$ = new ResourceID($1); }
- | '@' IDENTIFIER
- { $$ = current_file->GetAutoIdentifier($2, current_file->iconDict); }
- ;
- icon_items: /* empty */
- { $$ = new PixelContents(); }
- | icon_items DIMENSIONS
- opt_separator expression ',' expression ',' expression ';'
- { $$->SetDimensions($4, $6, $8); }
- | icon_items COLOURS data_block
- { $$->SetClut($3); }
- | icon_items ANDMASK pix_block
- { $$->SetAndMask($3); }
- | icon_items XORMASK pix_block
- { $$->SetXorMask($3); }
- | icon_items PIXELS pix_block
- { $$->SetPixels($3); }
- ;
- /***************************************************************************
- Cursor resources
- ***************************************************************************/
- cursor_resource: CURSOR
- opt_separator cursor_id block_begin cursor_items block_end
- { current_file->AddResource(ResourceList::CursorRes,
- new CursorResource($3, $5), "cursor"); }
- ;
- cursor_id: expression
- { $$ = new ResourceID($1); }
- | '@' IDENTIFIER
- { $$ = current_file->GetAutoIdentifier($2, current_file->cursorDict); }
- ;
- cursor_items: /* empty */
- { $$ = new PixelContents(); }
- | cursor_items DIMENSIONS
- opt_separator expression ',' expression ',' expression ';'
- { $$->SetDimensions($4, $6, $8); }
- | cursor_items HOTSPOT opt_separator expression ',' expression ';'
- { $$->SetHotSpot($4, $6); }
- | cursor_items COLOURS data_block
- { $$->SetClut($3); }
- | cursor_items ANDMASK pix_block
- { $$->SetAndMask($3); }
- | cursor_items XORMASK pix_block
- { $$->SetXorMask($3); }
- | cursor_items PIXELS pix_block
- { $$->SetPixels($3); }
- ;
- /***************************************************************************
- Pattern resources
- ***************************************************************************/
- pattern_resource: PATTERN_token
- opt_separator pattern_id block_begin pattern_items block_end
- { current_file->AddResource(ResourceList::PatternRes,
- new Pattern($3, $5), "pattern"); }
- ;
- pattern_id: expression
- { $$ = new ResourceID($1); }
- | '@' IDENTIFIER
- { $$ = current_file->GetAutoIdentifier($2, current_file->patternDict); }
- ;
- pattern_items: /* empty */
- { $$ = new PixelContents(); }
- | pattern_items DIMENSIONS
- opt_separator expression ',' expression ',' expression ';'
- { $$->SetDimensions($4, $6, $8); }
- | pattern_items COLOURS data_block
- { $$->SetClut($3); }
- | pattern_items PIXELS pix_block
- { $$->SetPixels($3); }
- ;
- /***************************************************************************
- Image resources
- ***************************************************************************/
- image_resource: IMAGE opt_separator image_id block_begin image_items block_end
- { current_file->AddResource(ResourceList::ImageRes,
- new Image($3, $5), "image"); }
- ;
- image_id: expression
- { $$ = new ResourceID($1); }
- | '@' IDENTIFIER
- { $$ = current_file->GetAutoIdentifier($2, current_file->imageDict); }
- ;
- image_items: /* empty */
- { $$ = new PixelContents(); }
- | image_items DIMENSIONS
- opt_separator expression ',' expression ',' expression ';'
- { $$->SetDimensions($4, $6, $8); }
- | image_items COLOURS data_block
- { $$->SetClut($3); }
- | image_items PIXELS pix_block
- { $$->SetPixels($3); }
- ;
- /***************************************************************************
- Data resources
- ***************************************************************************/
- data_resource: RESOURCE opt_separator data_id opt_resname data_block
- { current_file->AddResource(ResourceList::DataRes,
- new DataResource($3, $4, $5), "data resource"); }
- ;
- data_id: expression
- { $$ = new ResourceID($1); }
- | '@' IDENTIFIER
- { $$ = current_file->GetAutoIdentifier($2, current_file->dataDict); }
- ;
- opt_resname: /* empty */
- { $$ = NULL; }
- | literal_list
- { $$ = $1; }
- | ',' literal_list
- { $$ = $2; }
- ;
- /***************************************************************************
- Misc rules
- ***************************************************************************/
- block_begin: BEGIN_token
- | '{'
- ;
- block_end: END
- | '}'
- ;
- pix_block: block_begin pixels block_end
- { $$ = $2; }
- ;
- pixels: /* empty */
- { $$ = new PixData(); }
- | pixels INTEGER
- {
- if ($2 < 0)
- PError << StdError(Warning) << "negative value in pixel datan";
- if ($2 > 255)
- PError << StdError(Warning) << "pix data greater than 255n";
- $1->Append ((BYTE)$2);
- }
- | pixels ','
- ;
- data_block: block_begin data_items block_end
- { $$ = $2; }
- ;
- data_items: /* empty */
- { $$ = new BinaryData(); }
- | data_items INTEGER
- {
- if ($2 < 0)
- PError << StdError(Warning) << "negative value in binary datan";
- $1->Append ((BYTE)($2 & 0xff));
- if ($2 > 255)
- $1->Append ((BYTE)(($2 >> 8) & 0xff));
- }
- | data_items LITERAL
- {
- PString s(PString::Literal, *$2);
- delete $2;
- for (PINDEX i = 0; i < s.GetLength(); i++)
- $1->Append (s[i]);
- }
- | data_items ','
- ;
- string_list_block: block_begin string_list block_end
- { $$ = $2; }
- ;
- string_list: literal_list
- {
- $$ = new PStringList();
- $$->Append ($1);
- }
- | string_list ',' literal_list
- { $1->Append ($3); }
- ;
- literal_list: LITERAL
- { $$ = $1; }
- | literal_list LITERAL
- {
- *$1 = $1->Left($1->GetLength()-1) + $2->Right($2->GetLength()-1);
- delete $2;
- $$ = $1;
- }
- ;
- opt_separator: /* empty */
- | ','
- ;