[comp.graphics] YACC grammar for HPGL wanted

jeremy@acadch.UUCP (Jeremy Tammik) (02/23/90)

Hi everybody,

could somebody please send me a Yacc grammar for the HPGL
plotter language? Thank you! Hints on using it efficiently
to parse & convert & understand HPGL would also be appreciated.

Jeremy
# Jeremy Tammik   #   Autodesk AG   #   CH-4133 Pratteln, Switzerland   # :-) # 
# {sun|uunet}!acad!acadch!jeremy # jeremy@acadch.UUCP # cernvax!acadch!jeremy #

zmact61@doc.ic.ac.uk (D Spinellis) (02/26/90)

In article <1239@acadch.UUCP> jeremy@acadch.UUCP (Jeremy Tammik) writes:
>could somebody please send me a Yacc grammar for the HPGL
>plotter language? Thank you! 

/* Commands needing 0, 1, 2 and 4 arguments */
%token	tCOM0 tCOM1 tCOM2 tCOM4
%token	tTERMINATOR tARG
%start	command_file

%%
command_file	: /* Empty */
		| command_file command
		;

command		: tCOM0 tTERMINATOR
		| tCOM1 tARG tTERMINATOR
		| tCOM2 tARG tARG tTERMINATOR
		| tCOM4 tARG tARG tARG tARG tTERMINATOR
		;
%%

>Hints on using it efficiently
>to parse & convert & understand HPGL would also be appreciated.

DON'T USE IT.  HPGL can be parsed very easily by a finite state machine.
Using yacc to parse it is an overkill.  All commands are two characters
long and are terminated by a special character.  You can determine the
number of arguments a command uses by counting argument separators until
you encounter the command terminator.

Diomidis
--
Diomidis Spinellis                  Internet:                 dds@cc.ic.ac.uk
Department of Computing             UUCP:                    ...!ukc!iccc!dds
Imperial College                    JANET:                    dds@uk.ac.ic.cc
London SW7 2BZ                      #include "/dev/tty"

woody@rpp386.cactus.org (Woodrow Baker) (02/27/90)

In article <1239@acadch.UUCP>, jeremy@acadch.UUCP (Jeremy Tammik) writes:
> Hi everybody,
> 
> could somebody please send me a Yacc grammar for the HPGL
> plotter language? Thank you! Hints on using it efficiently
> to parse & convert & understand HPGL would also be appreciated.
> 
> Jeremy
> # Jeremy Tammik   #   Autodesk AG   #   CH-4133 Pratteln, Switzerland   # :-) # 
> # {sun|uunet}!acad!acadch!jeremy # jeremy@acadch.UUCP # cernvax!acadch!jeremy #

ME TOO.

Cheers
Woody