1999-12-16 22:56:45 +00:00
|
|
|
|
/* rtfGrammer.y
|
|
|
|
|
|
|
|
|
|
Copyright (C) 1999 Free Software Foundation, Inc.
|
|
|
|
|
|
2007-10-29 21:16:17 +00:00
|
|
|
|
Author: Stefan B<>hringer (stefan.boehringer@uni-bochum.de)
|
1999-12-16 22:56:45 +00:00
|
|
|
|
Date: Dec 1999
|
|
|
|
|
|
|
|
|
|
This file is part of the GNUstep GUI Library.
|
|
|
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or
|
2007-10-29 21:16:17 +00:00
|
|
|
|
modify it under the terms of the GNU Lesser General Public
|
1999-12-16 22:56:45 +00:00
|
|
|
|
License as published by the Free Software Foundation; either
|
2008-06-10 04:01:49 +00:00
|
|
|
|
version 2 of the License, or (at your option) any later version.
|
1999-12-16 22:56:45 +00:00
|
|
|
|
|
|
|
|
|
This library is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
2007-10-29 21:16:17 +00:00
|
|
|
|
Lesser General Public License for more details.
|
1999-12-16 22:56:45 +00:00
|
|
|
|
|
2007-10-29 21:16:17 +00:00
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
1999-12-16 22:56:45 +00:00
|
|
|
|
License along with this library; see the file COPYING.LIB.
|
2007-10-29 21:16:17 +00:00
|
|
|
|
If not, see <http://www.gnu.org/licenses/> or write to the
|
|
|
|
|
Free Software Foundation, 51 Franklin Street, Fifth Floor,
|
|
|
|
|
Boston, MA 02110-1301, USA.
|
1999-12-16 22:56:45 +00:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
if processed using -p GSRTFP (as recommended) it will introduce the following global symbols:
|
|
|
|
|
'GSRTFPparse', `GSRTFPlex', `GSRTFPerror', `GSRTFPnerrs', `GSRTFPlval',
|
|
|
|
|
`GSRTFPchar', `GSRTFPdebug
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/* we request for a reentrant parser */
|
2020-01-22 15:54:25 +00:00
|
|
|
|
%define api.pure
|
1999-12-16 22:56:45 +00:00
|
|
|
|
|
|
|
|
|
%{
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
The overall plan is to make this grammer universal in usage.
|
|
|
|
|
Intrested buddies can implement plain C functions to consume what
|
|
|
|
|
the grammer is producing. this way the rtf-grammer-tree can be
|
|
|
|
|
converted to what is needed: GNUstep attributed strings, tex files,
|
|
|
|
|
...
|
|
|
|
|
|
|
|
|
|
The plan is laid out by defining a set of C functions which cover
|
|
|
|
|
all what is needed to mangle rtf information (it is NeXT centric
|
|
|
|
|
however and may even lack some features). Be aware that some
|
|
|
|
|
functions are called at specific times when some information may or
|
|
|
|
|
may not be available. The first argument of all functions is a
|
|
|
|
|
context, which is asked to be maintained by the consumer at
|
|
|
|
|
whichever purpose seems appropriate. This context must be passed to
|
|
|
|
|
the parser by issuing 'value = GSRTFparse(ctxt, lctxt);' in the
|
|
|
|
|
first place.
|
|
|
|
|
*/
|
|
|
|
|
|
2011-02-22 20:59:10 +00:00
|
|
|
|
#import <AppKit/AppKit.h>
|
1999-12-16 22:56:45 +00:00
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <string.h>
|
2001-08-21 14:52:00 +00:00
|
|
|
|
#include "rtfScanner.h"
|
1999-12-16 22:56:45 +00:00
|
|
|
|
|
|
|
|
|
/* this context is passed to the interface functions */
|
2002-11-24 01:06:26 +00:00
|
|
|
|
typedef void *GSRTFctxt;
|
2011-01-03 08:25:42 +00:00
|
|
|
|
/*#undef YYLSP_NEEDED*/
|
2001-08-21 14:52:00 +00:00
|
|
|
|
#define CTXT ctxt
|
1999-12-16 22:56:45 +00:00
|
|
|
|
|
|
|
|
|
#define YYERROR_VERBOSE
|
2014-06-15 21:38:40 +00:00
|
|
|
|
#define YYDEBUG 1
|
1999-12-16 22:56:45 +00:00
|
|
|
|
|
2001-08-21 14:52:00 +00:00
|
|
|
|
#include "RTFConsumerFunctions.h"
|
2002-11-24 01:06:26 +00:00
|
|
|
|
/*int GSRTFlex (YYSTYPE *lvalp, RTFscannerCtxt *lctxt); */
|
|
|
|
|
int GSRTFlex(void *lvalp, void *lctxt);
|
1999-12-16 22:56:45 +00:00
|
|
|
|
|
2014-06-17 21:06:11 +00:00
|
|
|
|
/* */
|
|
|
|
|
int fieldStart = 0;
|
|
|
|
|
|
1999-12-16 22:56:45 +00:00
|
|
|
|
%}
|
|
|
|
|
|
2011-01-03 08:25:42 +00:00
|
|
|
|
%parse-param {void *ctxt}
|
|
|
|
|
%parse-param {void *lctxt}
|
2020-01-22 15:54:25 +00:00
|
|
|
|
%lex-param {void *lctxt}
|
2011-01-03 08:25:42 +00:00
|
|
|
|
|
1999-12-16 22:56:45 +00:00
|
|
|
|
%union {
|
2000-06-24 22:10:09 +00:00
|
|
|
|
int number;
|
1999-12-16 22:56:45 +00:00
|
|
|
|
const char *text;
|
|
|
|
|
RTFcmd cmd;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* <!><p> RTFtext values have to be freed */
|
|
|
|
|
%token <text> RTFtext
|
|
|
|
|
%token RTFstart
|
2000-04-23 22:28:46 +00:00
|
|
|
|
%token RTFansi
|
|
|
|
|
%token RTFmac
|
|
|
|
|
%token RTFpc
|
|
|
|
|
%token RTFpca
|
|
|
|
|
%token RTFignore
|
2000-06-16 17:03:56 +00:00
|
|
|
|
%token RTFinfo
|
|
|
|
|
%token RTFstylesheet
|
|
|
|
|
%token RTFfootnote
|
|
|
|
|
%token RTFheader
|
|
|
|
|
%token RTFfooter
|
|
|
|
|
%token RTFpict
|
2000-06-24 22:10:09 +00:00
|
|
|
|
%token RTFplain
|
|
|
|
|
%token RTFparagraph
|
|
|
|
|
%token RTFdefaultParagraph
|
|
|
|
|
%token RTFrow
|
|
|
|
|
%token RTFcell
|
|
|
|
|
%token RTFtabulator
|
|
|
|
|
%token RTFemdash
|
|
|
|
|
%token RTFendash
|
|
|
|
|
%token RTFemspace
|
|
|
|
|
%token RTFenspace
|
|
|
|
|
%token RTFbullet
|
2014-06-15 21:38:40 +00:00
|
|
|
|
%token RTFfield
|
|
|
|
|
%token RTFfldinst
|
|
|
|
|
%token RTFfldalt
|
|
|
|
|
%token RTFfldrslt
|
|
|
|
|
%token RTFflddirty
|
|
|
|
|
%token RTFfldedit
|
|
|
|
|
%token RTFfldlock
|
|
|
|
|
%token RTFfldpriv
|
|
|
|
|
%token RTFfttruetype
|
2000-06-24 22:10:09 +00:00
|
|
|
|
%token RTFlquote
|
|
|
|
|
%token RTFrquote
|
|
|
|
|
%token RTFldblquote
|
|
|
|
|
%token RTFrdblquote
|
2000-04-23 22:28:46 +00:00
|
|
|
|
%token <cmd> RTFred
|
|
|
|
|
%token <cmd> RTFgreen
|
|
|
|
|
%token <cmd> RTFblue
|
|
|
|
|
%token <cmd> RTFcolorbg
|
|
|
|
|
%token <cmd> RTFcolorfg
|
2011-02-22 20:59:10 +00:00
|
|
|
|
%token <cmd> RTFunderlinecolor
|
2000-04-23 22:28:46 +00:00
|
|
|
|
%token <cmd> RTFcolortable
|
1999-12-16 22:56:45 +00:00
|
|
|
|
%token <cmd> RTFfont
|
|
|
|
|
%token <cmd> RTFfontSize
|
2006-05-11 21:03:21 +00:00
|
|
|
|
%token <cmd> RTFNeXTGraphic
|
|
|
|
|
%token <cmd> RTFNeXTGraphicWidth
|
|
|
|
|
%token <cmd> RTFNeXTGraphicHeight
|
2011-01-03 08:50:17 +00:00
|
|
|
|
%token <cmd> RTFNeXTHelpLink
|
|
|
|
|
%token <cmd> RTFNeXTHelpMarker
|
|
|
|
|
%token <cmd> RTFNeXTfilename
|
|
|
|
|
%token <cmd> RTFNeXTmarkername
|
|
|
|
|
%token <cmd> RTFNeXTlinkFilename
|
|
|
|
|
%token <cmd> RTFNeXTlinkMarkername
|
1999-12-16 22:56:45 +00:00
|
|
|
|
%token <cmd> RTFpaperWidth
|
|
|
|
|
%token <cmd> RTFpaperHeight
|
|
|
|
|
%token <cmd> RTFmarginLeft
|
|
|
|
|
%token <cmd> RTFmarginRight
|
2000-06-16 17:03:56 +00:00
|
|
|
|
%token <cmd> RTFmarginTop
|
|
|
|
|
%token <cmd> RTFmarginButtom
|
2000-04-23 22:28:46 +00:00
|
|
|
|
%token <cmd> RTFfirstLineIndent
|
|
|
|
|
%token <cmd> RTFleftIndent
|
2000-06-17 17:53:14 +00:00
|
|
|
|
%token <cmd> RTFrightIndent
|
2000-04-23 22:28:46 +00:00
|
|
|
|
%token <cmd> RTFalignCenter
|
2000-06-24 22:10:09 +00:00
|
|
|
|
%token <cmd> RTFalignJustified
|
2000-04-23 22:28:46 +00:00
|
|
|
|
%token <cmd> RTFalignLeft
|
|
|
|
|
%token <cmd> RTFalignRight
|
2000-06-24 22:10:09 +00:00
|
|
|
|
%token <cmd> RTFlineSpace
|
|
|
|
|
%token <cmd> RTFspaceAbove
|
2000-04-23 22:28:46 +00:00
|
|
|
|
%token <cmd> RTFstyle
|
1999-12-16 22:56:45 +00:00
|
|
|
|
%token <cmd> RTFbold
|
|
|
|
|
%token <cmd> RTFitalic
|
|
|
|
|
%token <cmd> RTFunderline
|
2011-02-22 20:59:10 +00:00
|
|
|
|
%token <cmd> RTFunderlineDot
|
|
|
|
|
%token <cmd> RTFunderlineDash
|
|
|
|
|
%token <cmd> RTFunderlineDashDot
|
|
|
|
|
%token <cmd> RTFunderlineDashDotDot
|
|
|
|
|
%token <cmd> RTFunderlineDouble
|
1999-12-16 22:56:45 +00:00
|
|
|
|
%token <cmd> RTFunderlineStop
|
2011-02-22 20:59:10 +00:00
|
|
|
|
%token <cmd> RTFunderlineThick
|
|
|
|
|
%token <cmd> RTFunderlineThickDot
|
|
|
|
|
%token <cmd> RTFunderlineThickDash
|
|
|
|
|
%token <cmd> RTFunderlineThickDashDot
|
|
|
|
|
%token <cmd> RTFunderlineThickDashDotDot
|
|
|
|
|
%token <cmd> RTFunderlineWord
|
|
|
|
|
%token <cmd> RTFstrikethrough
|
|
|
|
|
%token <cmd> RTFstrikethroughDouble
|
2003-07-15 22:18:49 +00:00
|
|
|
|
%token <cmd> RTFunichar
|
2000-04-23 22:28:46 +00:00
|
|
|
|
%token <cmd> RTFsubscript
|
|
|
|
|
%token <cmd> RTFsuperscript
|
2000-06-17 17:53:14 +00:00
|
|
|
|
%token <cmd> RTFtabstop
|
2000-06-16 17:03:56 +00:00
|
|
|
|
%token <cmd> RTFfcharset
|
|
|
|
|
%token <cmd> RTFfprq
|
|
|
|
|
%token <cmd> RTFcpg
|
2020-01-22 15:54:25 +00:00
|
|
|
|
%token <cmd> RTFansicpg
|
1999-12-16 22:56:45 +00:00
|
|
|
|
%token <cmd> RTFOtherStatement
|
|
|
|
|
%token RTFfontListStart
|
|
|
|
|
|
|
|
|
|
// <!> we assume token numbers to be sequential
|
|
|
|
|
// \fnil | \froman | \fswiss | \fmodern | \fscript | \fdecor | \ftech
|
|
|
|
|
// look at rtfScanner.h for enum definition
|
|
|
|
|
%token RTFfamilyNil
|
|
|
|
|
%token RTFfamilyRoman
|
|
|
|
|
%token RTFfamilySwiss
|
|
|
|
|
%token RTFfamilyModern
|
|
|
|
|
%token RTFfamilyScript
|
|
|
|
|
%token RTFfamilyDecor
|
|
|
|
|
%token RTFfamilyTech
|
2014-10-05 20:49:40 +00:00
|
|
|
|
%token RTFfamilyBiDi
|
1999-12-16 22:56:45 +00:00
|
|
|
|
|
2000-04-23 22:28:46 +00:00
|
|
|
|
%type <number> rtfFontFamily rtfCharset rtfFontStatement
|
2014-06-17 21:06:11 +00:00
|
|
|
|
%type <text> rtfFieldinst
|
1999-12-16 22:56:45 +00:00
|
|
|
|
|
|
|
|
|
/* let's go */
|
|
|
|
|
|
|
|
|
|
%%
|
|
|
|
|
|
2014-10-05 20:49:40 +00:00
|
|
|
|
rtfFile: '{' { GSRTFstart(CTXT); } RTFstart rtfIngredients { GSRTFstop(CTXT); } '}'
|
1999-12-16 22:56:45 +00:00
|
|
|
|
;
|
|
|
|
|
|
2020-01-22 15:54:25 +00:00
|
|
|
|
rtfCharset: RTFansi { GSRTFencoding(CTXT, 1); }
|
|
|
|
|
| RTFmac { GSRTFencoding(CTXT, 2); }
|
2020-05-29 13:18:37 +00:00
|
|
|
|
| RTFpc { GSRTFencoding(CTXT, 3); }
|
2020-01-22 15:54:25 +00:00
|
|
|
|
| RTFpca { GSRTFencoding(CTXT, 4); }
|
|
|
|
|
| rtfCharset RTFansicpg { GSRTFencoding(CTXT, $2.parameter); }
|
1999-12-16 22:56:45 +00:00
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
rtfIngredients: /* empty */
|
2014-10-05 20:49:40 +00:00
|
|
|
|
| rtfIngredients rtfCharset
|
2000-04-23 22:28:46 +00:00
|
|
|
|
| rtfIngredients rtfFontList
|
|
|
|
|
| rtfIngredients rtfColorDef
|
1999-12-16 22:56:45 +00:00
|
|
|
|
| rtfIngredients rtfStatement
|
2001-08-21 14:52:00 +00:00
|
|
|
|
| rtfIngredients RTFtext { GSRTFmangleText(CTXT, $2); free((void *)$2); }
|
1999-12-16 22:56:45 +00:00
|
|
|
|
| rtfIngredients rtfBlock
|
2003-04-07 10:02:47 +00:00
|
|
|
|
| rtfIngredients error
|
1999-12-16 22:56:45 +00:00
|
|
|
|
;
|
|
|
|
|
|
2011-01-03 08:50:17 +00:00
|
|
|
|
rtfBlock: '{' { GSRTFopenBlock(CTXT, NO); } rtfIngredients rtfNeXTstuff '}' { GSRTFcloseBlock(CTXT, NO); } /* may be empty */
|
2001-08-21 14:52:00 +00:00
|
|
|
|
| '{' { GSRTFopenBlock(CTXT, YES); } RTFignore rtfIngredients '}' { GSRTFcloseBlock(CTXT, YES); }
|
|
|
|
|
| '{' { GSRTFopenBlock(CTXT, YES); } RTFinfo rtfIngredients '}' { GSRTFcloseBlock(CTXT, YES); }
|
|
|
|
|
| '{' { GSRTFopenBlock(CTXT, YES); } RTFstylesheet rtfIngredients '}' { GSRTFcloseBlock(CTXT, YES); }
|
|
|
|
|
| '{' { GSRTFopenBlock(CTXT, YES); } RTFfootnote rtfIngredients '}' { GSRTFcloseBlock(CTXT, YES); }
|
|
|
|
|
| '{' { GSRTFopenBlock(CTXT, YES); } RTFheader rtfIngredients '}' { GSRTFcloseBlock(CTXT, YES); }
|
|
|
|
|
| '{' { GSRTFopenBlock(CTXT, YES); } RTFfooter rtfIngredients '}' { GSRTFcloseBlock(CTXT, YES); }
|
|
|
|
|
| '{' { GSRTFopenBlock(CTXT, YES); } RTFpict rtfIngredients '}' { GSRTFcloseBlock(CTXT, YES); }
|
2014-06-15 21:38:40 +00:00
|
|
|
|
| '{' { GSRTFopenBlock(CTXT, NO); } RTFfield rtfField '}' { GSRTFcloseBlock(CTXT, NO); }
|
2003-04-07 10:02:47 +00:00
|
|
|
|
| '{' error '}'
|
2000-04-23 22:28:46 +00:00
|
|
|
|
;
|
|
|
|
|
|
1999-12-16 22:56:45 +00:00
|
|
|
|
|
2014-06-17 21:06:11 +00:00
|
|
|
|
rtfField: { fieldStart = GSRTFgetPosition(CTXT);} rtfFieldMod rtfFieldinst rtfFieldrslt { GSRTFaddField(CTXT, fieldStart, $3); free((void *)$3); }
|
2014-06-15 21:38:40 +00:00
|
|
|
|
| error
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
rtfFieldMod: /* empty */
|
|
|
|
|
| rtfFieldMod RTFflddirty
|
|
|
|
|
| rtfFieldMod RTFfldedit
|
|
|
|
|
| rtfFieldMod RTFfldlock
|
|
|
|
|
| rtfFieldMod RTFfldpriv
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
rtfIgnore: /* empty */
|
|
|
|
|
| RTFignore
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
rtfFieldinst: '{' rtfIgnore RTFfldinst RTFtext rtfFieldalt '}' { $$ = $4;}
|
|
|
|
|
| '{' rtfIgnore RTFfldinst '{' { GSRTFopenBlock(CTXT, YES); } rtfStatementList RTFtext rtfFieldalt '}' { GSRTFcloseBlock(CTXT, YES); } '}' { $$ = $7;}
|
|
|
|
|
| '{' error '}' { $$ = NULL;}
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
rtfFieldalt: /* empty */
|
|
|
|
|
| RTFfldalt
|
|
|
|
|
;
|
|
|
|
|
|
2014-06-17 21:06:11 +00:00
|
|
|
|
rtfFieldrslt: '{' rtfIgnore RTFfldrslt rtfIngredients '}'
|
|
|
|
|
| '{' error '}'
|
2014-06-15 21:38:40 +00:00
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
rtfStatementList: /* empty */
|
|
|
|
|
| rtfStatementList rtfStatement
|
|
|
|
|
| rtfStatementList rtfBlock
|
|
|
|
|
;
|
|
|
|
|
|
1999-12-16 22:56:45 +00:00
|
|
|
|
/*
|
|
|
|
|
RTF statements start with a '\', have a alpha name and a number argument
|
|
|
|
|
*/
|
|
|
|
|
|
2000-04-23 22:28:46 +00:00
|
|
|
|
rtfStatement: RTFfont { int font;
|
|
|
|
|
|
|
|
|
|
if ($1.isEmpty)
|
|
|
|
|
font = 0;
|
|
|
|
|
else
|
|
|
|
|
font = $1.parameter;
|
2001-08-21 14:52:00 +00:00
|
|
|
|
GSRTFfontNumber(CTXT, font); }
|
2000-04-23 22:28:46 +00:00
|
|
|
|
| RTFfontSize { int size;
|
|
|
|
|
|
|
|
|
|
if ($1.isEmpty)
|
|
|
|
|
size = 24;
|
|
|
|
|
else
|
|
|
|
|
size = $1.parameter;
|
2001-08-21 14:52:00 +00:00
|
|
|
|
GSRTFfontSize(CTXT, size); }
|
2000-04-23 22:28:46 +00:00
|
|
|
|
| RTFpaperWidth { int width;
|
|
|
|
|
|
|
|
|
|
if ($1.isEmpty)
|
|
|
|
|
width = 12240;
|
|
|
|
|
else
|
|
|
|
|
width = $1.parameter;
|
2001-08-21 14:52:00 +00:00
|
|
|
|
GSRTFpaperWidth(CTXT, width);}
|
2000-04-23 22:28:46 +00:00
|
|
|
|
| RTFpaperHeight { int height;
|
|
|
|
|
|
|
|
|
|
if ($1.isEmpty)
|
|
|
|
|
height = 15840;
|
|
|
|
|
else
|
|
|
|
|
height = $1.parameter;
|
2001-08-21 14:52:00 +00:00
|
|
|
|
GSRTFpaperHeight(CTXT, height);}
|
2000-04-23 22:28:46 +00:00
|
|
|
|
| RTFmarginLeft { int margin;
|
|
|
|
|
|
|
|
|
|
if ($1.isEmpty)
|
|
|
|
|
margin = 1800;
|
|
|
|
|
else
|
|
|
|
|
margin = $1.parameter;
|
2001-08-21 14:52:00 +00:00
|
|
|
|
GSRTFmarginLeft(CTXT, margin);}
|
2000-04-23 22:28:46 +00:00
|
|
|
|
| RTFmarginRight { int margin;
|
|
|
|
|
|
|
|
|
|
if ($1.isEmpty)
|
|
|
|
|
margin = 1800;
|
|
|
|
|
else
|
|
|
|
|
margin = $1.parameter;
|
2001-08-21 14:52:00 +00:00
|
|
|
|
GSRTFmarginRight(CTXT, margin); }
|
2000-06-16 17:03:56 +00:00
|
|
|
|
| RTFmarginTop { int margin;
|
|
|
|
|
|
|
|
|
|
if ($1.isEmpty)
|
|
|
|
|
margin = 1440;
|
|
|
|
|
else
|
|
|
|
|
margin = $1.parameter;
|
2001-08-21 14:52:00 +00:00
|
|
|
|
GSRTFmarginTop(CTXT, margin); }
|
2000-06-16 17:03:56 +00:00
|
|
|
|
| RTFmarginButtom { int margin;
|
|
|
|
|
|
|
|
|
|
if ($1.isEmpty)
|
|
|
|
|
margin = 1440;
|
|
|
|
|
else
|
|
|
|
|
margin = $1.parameter;
|
2001-08-21 14:52:00 +00:00
|
|
|
|
GSRTFmarginButtom(CTXT, margin); }
|
2000-04-23 22:28:46 +00:00
|
|
|
|
| RTFfirstLineIndent { int indent;
|
|
|
|
|
|
|
|
|
|
if ($1.isEmpty)
|
|
|
|
|
indent = 0;
|
|
|
|
|
else
|
|
|
|
|
indent = $1.parameter;
|
2001-08-21 14:52:00 +00:00
|
|
|
|
GSRTFfirstLineIndent(CTXT, indent); }
|
2000-04-23 22:28:46 +00:00
|
|
|
|
| RTFleftIndent { int indent;
|
|
|
|
|
|
|
|
|
|
if ($1.isEmpty)
|
|
|
|
|
indent = 0;
|
|
|
|
|
else
|
|
|
|
|
indent = $1.parameter;
|
2001-08-21 14:52:00 +00:00
|
|
|
|
GSRTFleftIndent(CTXT, indent);}
|
2000-06-17 17:53:14 +00:00
|
|
|
|
| RTFrightIndent { int indent;
|
|
|
|
|
|
|
|
|
|
if ($1.isEmpty)
|
|
|
|
|
indent = 0;
|
|
|
|
|
else
|
|
|
|
|
indent = $1.parameter;
|
2001-08-21 14:52:00 +00:00
|
|
|
|
GSRTFrightIndent(CTXT, indent);}
|
2000-06-17 17:53:14 +00:00
|
|
|
|
| RTFtabstop { int location;
|
|
|
|
|
|
|
|
|
|
if ($1.isEmpty)
|
|
|
|
|
location = 0;
|
|
|
|
|
else
|
|
|
|
|
location = $1.parameter;
|
2001-08-21 14:52:00 +00:00
|
|
|
|
GSRTFtabstop(CTXT, location);}
|
|
|
|
|
| RTFalignCenter { GSRTFalignCenter(CTXT); }
|
|
|
|
|
| RTFalignJustified { GSRTFalignJustified(CTXT); }
|
|
|
|
|
| RTFalignLeft { GSRTFalignLeft(CTXT); }
|
|
|
|
|
| RTFalignRight { GSRTFalignRight(CTXT); }
|
2000-06-24 22:10:09 +00:00
|
|
|
|
| RTFspaceAbove { int space;
|
|
|
|
|
|
|
|
|
|
if ($1.isEmpty)
|
|
|
|
|
space = 0;
|
|
|
|
|
else
|
|
|
|
|
space = $1.parameter;
|
2001-08-21 14:52:00 +00:00
|
|
|
|
GSRTFspaceAbove(CTXT, space); }
|
|
|
|
|
| RTFlineSpace { GSRTFlineSpace(CTXT, $1.parameter); }
|
|
|
|
|
| RTFdefaultParagraph { GSRTFdefaultParagraph(CTXT); }
|
|
|
|
|
| RTFstyle { GSRTFstyle(CTXT, $1.parameter); }
|
2000-04-23 22:28:46 +00:00
|
|
|
|
| RTFcolorbg { int color;
|
|
|
|
|
|
|
|
|
|
if ($1.isEmpty)
|
|
|
|
|
color = 0;
|
|
|
|
|
else
|
|
|
|
|
color = $1.parameter;
|
2001-08-21 14:52:00 +00:00
|
|
|
|
GSRTFcolorbg(CTXT, color); }
|
2000-04-23 22:28:46 +00:00
|
|
|
|
| RTFcolorfg { int color;
|
|
|
|
|
|
|
|
|
|
if ($1.isEmpty)
|
|
|
|
|
color = 0;
|
|
|
|
|
else
|
|
|
|
|
color = $1.parameter;
|
2001-08-21 14:52:00 +00:00
|
|
|
|
GSRTFcolorfg(CTXT, color); }
|
2011-02-22 20:59:10 +00:00
|
|
|
|
| RTFunderlinecolor { int color;
|
|
|
|
|
|
|
|
|
|
if ($1.isEmpty)
|
|
|
|
|
color = 0;
|
|
|
|
|
else
|
|
|
|
|
color = $1.parameter;
|
|
|
|
|
GSRTFunderlinecolor(CTXT, color); }
|
2000-04-23 22:28:46 +00:00
|
|
|
|
| RTFsubscript { int script;
|
|
|
|
|
|
|
|
|
|
if ($1.isEmpty)
|
|
|
|
|
script = 6;
|
|
|
|
|
else
|
|
|
|
|
script = $1.parameter;
|
2001-08-21 14:52:00 +00:00
|
|
|
|
GSRTFsubscript(CTXT, script); }
|
2000-04-23 22:28:46 +00:00
|
|
|
|
| RTFsuperscript { int script;
|
|
|
|
|
|
|
|
|
|
if ($1.isEmpty)
|
|
|
|
|
script = 6;
|
|
|
|
|
else
|
|
|
|
|
script = $1.parameter;
|
2001-08-21 14:52:00 +00:00
|
|
|
|
GSRTFsuperscript(CTXT, script); }
|
2000-04-23 22:28:46 +00:00
|
|
|
|
| RTFbold { BOOL on;
|
|
|
|
|
|
|
|
|
|
if ($1.isEmpty || $1.parameter)
|
|
|
|
|
on = YES;
|
|
|
|
|
else
|
|
|
|
|
on = NO;
|
2001-08-21 14:52:00 +00:00
|
|
|
|
GSRTFbold(CTXT, on); }
|
2000-04-23 22:28:46 +00:00
|
|
|
|
| RTFitalic { BOOL on;
|
|
|
|
|
|
|
|
|
|
if ($1.isEmpty || $1.parameter)
|
|
|
|
|
on = YES;
|
|
|
|
|
else
|
|
|
|
|
on = NO;
|
2001-08-21 14:52:00 +00:00
|
|
|
|
GSRTFitalic(CTXT, on); }
|
2000-04-23 22:28:46 +00:00
|
|
|
|
| RTFunderline { BOOL on;
|
|
|
|
|
|
|
|
|
|
if ($1.isEmpty || $1.parameter)
|
|
|
|
|
on = YES;
|
|
|
|
|
else
|
|
|
|
|
on = NO;
|
2011-02-22 20:59:10 +00:00
|
|
|
|
GSRTFunderline(CTXT, on, NSUnderlineStyleSingle | NSUnderlinePatternSolid); }
|
|
|
|
|
| RTFunderlineDot { BOOL on;
|
|
|
|
|
|
|
|
|
|
if ($1.isEmpty || $1.parameter)
|
|
|
|
|
on = YES;
|
|
|
|
|
else
|
|
|
|
|
on = NO;
|
|
|
|
|
GSRTFunderline(CTXT, on, NSUnderlineStyleSingle | NSUnderlinePatternDot); }
|
|
|
|
|
| RTFunderlineDash { BOOL on;
|
|
|
|
|
|
|
|
|
|
if ($1.isEmpty || $1.parameter)
|
|
|
|
|
on = YES;
|
|
|
|
|
else
|
|
|
|
|
on = NO;
|
|
|
|
|
GSRTFunderline(CTXT, on, NSUnderlineStyleSingle | NSUnderlinePatternDash); }
|
|
|
|
|
| RTFunderlineDashDot { BOOL on;
|
|
|
|
|
|
|
|
|
|
if ($1.isEmpty || $1.parameter)
|
|
|
|
|
on = YES;
|
|
|
|
|
else
|
|
|
|
|
on = NO;
|
|
|
|
|
GSRTFunderline(CTXT, on, NSUnderlineStyleSingle | NSUnderlinePatternDashDot); }
|
|
|
|
|
| RTFunderlineDashDotDot { BOOL on;
|
|
|
|
|
|
|
|
|
|
if ($1.isEmpty || $1.parameter)
|
|
|
|
|
on = YES;
|
|
|
|
|
else
|
|
|
|
|
on = NO;
|
|
|
|
|
GSRTFunderline(CTXT, on, NSUnderlineStyleSingle | NSUnderlinePatternDashDotDot); }
|
|
|
|
|
| RTFunderlineDouble { BOOL on;
|
|
|
|
|
|
|
|
|
|
if ($1.isEmpty || $1.parameter)
|
|
|
|
|
on = YES;
|
|
|
|
|
else
|
|
|
|
|
on = NO;
|
|
|
|
|
GSRTFunderline(CTXT, on, NSUnderlineStyleDouble | NSUnderlinePatternSolid); }
|
|
|
|
|
| RTFunderlineStop { GSRTFunderline(CTXT, NO, NSUnderlineStyleNone); }
|
|
|
|
|
| RTFunderlineThick { BOOL on;
|
|
|
|
|
|
|
|
|
|
if ($1.isEmpty || $1.parameter)
|
|
|
|
|
on = YES;
|
|
|
|
|
else
|
|
|
|
|
on = NO;
|
|
|
|
|
GSRTFunderline(CTXT, on, NSUnderlineStyleThick | NSUnderlinePatternSolid); }
|
|
|
|
|
| RTFunderlineThickDot { BOOL on;
|
|
|
|
|
|
|
|
|
|
if ($1.isEmpty || $1.parameter)
|
|
|
|
|
on = YES;
|
|
|
|
|
else
|
|
|
|
|
on = NO;
|
|
|
|
|
GSRTFunderline(CTXT, on, NSUnderlineStyleThick | NSUnderlinePatternDot); }
|
|
|
|
|
| RTFunderlineThickDash { BOOL on;
|
|
|
|
|
|
|
|
|
|
if ($1.isEmpty || $1.parameter)
|
|
|
|
|
on = YES;
|
|
|
|
|
else
|
|
|
|
|
on = NO;
|
|
|
|
|
GSRTFunderline(CTXT, on, NSUnderlineStyleThick | NSUnderlinePatternDash); }
|
|
|
|
|
| RTFunderlineThickDashDot { BOOL on;
|
|
|
|
|
|
|
|
|
|
if ($1.isEmpty || $1.parameter)
|
|
|
|
|
on = YES;
|
|
|
|
|
else
|
|
|
|
|
on = NO;
|
|
|
|
|
GSRTFunderline(CTXT, on, NSUnderlineStyleThick | NSUnderlinePatternDashDot); }
|
|
|
|
|
| RTFunderlineThickDashDotDot { BOOL on;
|
|
|
|
|
|
|
|
|
|
if ($1.isEmpty || $1.parameter)
|
|
|
|
|
on = YES;
|
|
|
|
|
else
|
|
|
|
|
on = NO;
|
|
|
|
|
GSRTFunderline(CTXT, on, NSUnderlineStyleThick | NSUnderlinePatternDashDotDot); }
|
|
|
|
|
| RTFunderlineWord { BOOL on;
|
|
|
|
|
|
|
|
|
|
if ($1.isEmpty || $1.parameter)
|
|
|
|
|
on = YES;
|
|
|
|
|
else
|
|
|
|
|
on = NO;
|
|
|
|
|
GSRTFunderline(CTXT, on, NSUnderlineStyleSingle | NSUnderlinePatternSolid | NSUnderlineByWordMask); }
|
|
|
|
|
| RTFstrikethrough { NSInteger style;
|
|
|
|
|
if ($1.isEmpty || $1.parameter)
|
|
|
|
|
style = NSUnderlineStyleSingle | NSUnderlinePatternSolid;
|
|
|
|
|
else
|
|
|
|
|
style = NSUnderlineStyleNone;
|
|
|
|
|
GSRTFstrikethrough(CTXT, style); }
|
|
|
|
|
| RTFstrikethroughDouble { GSRTFstrikethrough(CTXT, NSUnderlineStyleDouble | NSUnderlinePatternSolid); }
|
2003-07-15 22:18:49 +00:00
|
|
|
|
| RTFunichar { GSRTFunicode(CTXT, $1.parameter); }
|
2001-08-21 14:52:00 +00:00
|
|
|
|
| RTFplain { GSRTFdefaultCharacterStyle(CTXT); }
|
|
|
|
|
| RTFparagraph { GSRTFparagraph(CTXT); }
|
|
|
|
|
| RTFrow { GSRTFparagraph(CTXT); }
|
2003-07-16 10:52:24 +00:00
|
|
|
|
| RTFOtherStatement { GSRTFgenericRTFcommand(CTXT, $1);
|
|
|
|
|
free((void*)$1.name); }
|
1999-12-16 22:56:45 +00:00
|
|
|
|
;
|
|
|
|
|
|
2011-01-03 08:50:17 +00:00
|
|
|
|
rtfNeXTstuff: /* empty */
|
|
|
|
|
| rtfNeXTGraphic
|
|
|
|
|
| rtfNeXTHelpLink
|
|
|
|
|
| rtfNeXTHelpMarker
|
|
|
|
|
;
|
|
|
|
|
|
2006-05-11 21:03:21 +00:00
|
|
|
|
/*
|
|
|
|
|
NeXTGraphic (images)
|
2010-05-01 08:26:01 +00:00
|
|
|
|
This is a Apple/NeXT extension. The format of the command is
|
|
|
|
|
{{\NeXTGraphic attachment \widthN \heightN} string}
|
|
|
|
|
and the string is ignored (on OS X it is always 0xAC).
|
|
|
|
|
See the Section "RTF Files and Attributed Strings" in Apple's
|
|
|
|
|
Attributed Strings Programming Guide.
|
2006-05-11 21:03:21 +00:00
|
|
|
|
*/
|
|
|
|
|
|
2011-01-03 08:50:17 +00:00
|
|
|
|
rtfNeXTGraphic: '{' RTFNeXTGraphic RTFtext RTFNeXTGraphicWidth RTFNeXTGraphicHeight '}' { GSRTFopenBlock(CTXT, YES); } rtfIngredients { GSRTFcloseBlock(CTXT, YES); }
|
2006-05-11 21:03:21 +00:00
|
|
|
|
{
|
2011-01-03 08:50:17 +00:00
|
|
|
|
GSRTFNeXTGraphic (CTXT, $3, $4.parameter, $5.parameter);
|
2006-05-11 21:03:21 +00:00
|
|
|
|
};
|
|
|
|
|
|
2011-01-03 08:50:17 +00:00
|
|
|
|
/*
|
|
|
|
|
NeXTHelpLink
|
|
|
|
|
This is a NeXT extension. The format of the command is
|
|
|
|
|
{{\NeXTHelpLinkN \markername markername; \linkFilename filename;
|
|
|
|
|
\linkMarkername markername;} string}
|
|
|
|
|
and the string is ignored (it is always 0xAC on NeXT).
|
|
|
|
|
Note that the {\NeXTHelpLink } group may itself be preceded by
|
|
|
|
|
other commands.
|
|
|
|
|
*/
|
|
|
|
|
|
2011-01-03 11:48:57 +00:00
|
|
|
|
rtfNeXTHelpLink: '{' RTFNeXTHelpLink RTFNeXTmarkername RTFtext RTFNeXTlinkFilename RTFtext RTFNeXTlinkMarkername RTFtext '}' { GSRTFopenBlock(CTXT, YES); } rtfIngredients { GSRTFcloseBlock(CTXT, YES); }
|
|
|
|
|
{
|
|
|
|
|
GSRTFNeXTHelpLink (CTXT, $2.parameter, $4, $6, $8);
|
|
|
|
|
};
|
2011-01-03 08:50:17 +00:00
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
NeXTHelpMarker
|
|
|
|
|
This is a NeXT extension. The format of the command is
|
|
|
|
|
{{\NeXTHelpMarkerN \markername markername;} string}
|
|
|
|
|
and the string is ignored (it is always 0xAC on NeXT).
|
|
|
|
|
Note that the {\NeXTHelpLink } group may itself be preceded by
|
|
|
|
|
other commands.
|
|
|
|
|
*/
|
|
|
|
|
|
2011-01-03 11:48:57 +00:00
|
|
|
|
rtfNeXTHelpMarker: '{' RTFNeXTHelpMarker RTFNeXTmarkername RTFtext '}' { GSRTFopenBlock(CTXT, YES); } rtfIngredients { GSRTFcloseBlock(CTXT, YES); }
|
|
|
|
|
{
|
|
|
|
|
GSRTFNeXTHelpMarker (CTXT, $2.parameter, $4);
|
|
|
|
|
};
|
2011-01-03 08:50:17 +00:00
|
|
|
|
|
1999-12-16 22:56:45 +00:00
|
|
|
|
/*
|
|
|
|
|
Font description
|
|
|
|
|
*/
|
|
|
|
|
|
2000-04-23 22:28:46 +00:00
|
|
|
|
rtfFontList: '{' RTFfontListStart rtfFonts '}'
|
1999-12-16 22:56:45 +00:00
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
rtfFonts:
|
|
|
|
|
| rtfFonts rtfFontStatement
|
|
|
|
|
| rtfFonts '{' rtfFontStatement '}'
|
2002-11-24 01:06:26 +00:00
|
|
|
|
| rtfFonts '{' rtfFontStatement rtfBlock RTFtext '}'
|
|
|
|
|
{ free((void *)$5);}
|
1999-12-16 22:56:45 +00:00
|
|
|
|
;
|
|
|
|
|
|
2000-04-23 22:28:46 +00:00
|
|
|
|
/* the first RTFfont tags the font with a number */
|
|
|
|
|
/* RTFtext introduces the fontName */
|
2001-08-21 14:52:00 +00:00
|
|
|
|
rtfFontStatement: RTFfont rtfFontFamily rtfFontAttrs RTFtext { GSRTFregisterFont(CTXT, $4, $2, $1.parameter);
|
2000-06-16 17:03:56 +00:00
|
|
|
|
free((void *)$4); }
|
2014-10-05 20:49:40 +00:00
|
|
|
|
/* fbidi should be a font family, but it seems to be used differently */
|
|
|
|
|
| RTFfont RTFfamilyBiDi rtfFontFamily rtfFontAttrs RTFtext { GSRTFregisterFont(CTXT, $5, $3, $1.parameter);
|
|
|
|
|
free((void *)$5); }
|
|
|
|
|
/* Theme fonts */
|
|
|
|
|
| RTFOtherStatement RTFfont RTFfamilyBiDi rtfFontFamily rtfFontAttrs RTFtext { GSRTFregisterFont(CTXT, $6, $4, $2.parameter);
|
|
|
|
|
free((void *)$6); }
|
1999-12-16 22:56:45 +00:00
|
|
|
|
;
|
|
|
|
|
|
2000-06-16 17:03:56 +00:00
|
|
|
|
rtfFontAttrs: /* empty */
|
|
|
|
|
| rtfFontAttrs RTFfcharset
|
|
|
|
|
| rtfFontAttrs RTFfprq
|
|
|
|
|
| rtfFontAttrs RTFcpg
|
2014-06-15 21:38:40 +00:00
|
|
|
|
| rtfFontAttrs RTFfttruetype
|
2000-06-16 17:03:56 +00:00
|
|
|
|
| rtfFontAttrs rtfBlock
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
|
1999-12-16 22:56:45 +00:00
|
|
|
|
rtfFontFamily:
|
|
|
|
|
RTFfamilyNil { $$ = RTFfamilyNil - RTFfamilyNil; }
|
|
|
|
|
| RTFfamilyRoman { $$ = RTFfamilyRoman - RTFfamilyNil; }
|
|
|
|
|
| RTFfamilySwiss { $$ = RTFfamilySwiss - RTFfamilyNil; }
|
|
|
|
|
| RTFfamilyModern { $$ = RTFfamilyModern - RTFfamilyNil; }
|
|
|
|
|
| RTFfamilyScript { $$ = RTFfamilyScript - RTFfamilyNil; }
|
|
|
|
|
| RTFfamilyDecor { $$ = RTFfamilyDecor - RTFfamilyNil; }
|
|
|
|
|
| RTFfamilyTech { $$ = RTFfamilyTech - RTFfamilyNil; }
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2000-06-24 22:10:09 +00:00
|
|
|
|
Colour definition
|
1999-12-16 22:56:45 +00:00
|
|
|
|
*/
|
|
|
|
|
|
2000-04-23 22:28:46 +00:00
|
|
|
|
rtfColorDef: '{' RTFcolortable rtfColors '}'
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
rtfColors: /* empty */
|
|
|
|
|
| rtfColors rtfColorStatement
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
/* We get the ';' as RTFText */
|
2000-06-16 17:03:56 +00:00
|
|
|
|
rtfColorStatement: RTFred RTFgreen RTFblue RTFtext
|
|
|
|
|
{
|
2001-08-21 14:52:00 +00:00
|
|
|
|
GSRTFaddColor(CTXT, $1.parameter, $2.parameter, $3.parameter);
|
2000-06-16 17:03:56 +00:00
|
|
|
|
free((void *)$4);
|
|
|
|
|
}
|
|
|
|
|
| RTFtext
|
|
|
|
|
{
|
2001-08-21 14:52:00 +00:00
|
|
|
|
GSRTFaddDefaultColor(CTXT);
|
2000-06-16 17:03:56 +00:00
|
|
|
|
free((void *)$1);
|
|
|
|
|
}
|
2000-04-23 22:28:46 +00:00
|
|
|
|
;
|
|
|
|
|
|
1999-12-16 22:56:45 +00:00
|
|
|
|
/*
|
|
|
|
|
some cludgy trailer
|
2002-11-24 01:06:26 +00:00
|
|
|
|
dummyNonTerminal: '\\' { @1.first_line; } / * we introduce a @n to fix the lex attributes * /
|
1999-12-16 22:56:45 +00:00
|
|
|
|
;
|
2002-11-24 01:06:26 +00:00
|
|
|
|
*/
|
1999-12-16 22:56:45 +00:00
|
|
|
|
|
|
|
|
|
%%
|
|
|
|
|
|
|
|
|
|
/* some C code here */
|
|
|
|
|
|