Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!uunet!mcsun!ukc!icdoc!zmact61 From: zmact61@doc.ic.ac.uk (D Spinellis) Newsgroups: comp.graphics Subject: Re: YACC grammar for HPGL wanted (please) Summary: Yacc is an overkill Keywords: YACC, HPGL, grammar Message-ID: <1630@gould.doc.ic.ac.uk> Date: 26 Feb 90 14:37:17 GMT References: <1239@acadch.UUCP> Sender: news@doc.ic.ac.uk Reply-To: dds@cc.ic.ac.uk (Diomidis Spinellis) Organization: Imperial College Department of Computing Lines: 36 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"