Trouble with PreCCX

Philip Willoughby <pgw99@doc.ic.ac.uk>
8 Jun 2003 22:07:08 -0400

          From comp.compilers

Related articles
Trouble with PreCCX pgw99@doc.ic.ac.uk (Philip Willoughby) (2003-06-08)
Re: Trouble with PreCCX mklooster@baan.nl (2003-07-13)
| List of all articles for this month |
From: Philip Willoughby <pgw99@doc.ic.ac.uk>
Newsgroups: comp.compilers
Date: 8 Jun 2003 22:07:08 -0400
Organization: Imperial College, London
Keywords: tools, question
Posted-Date: 08 Jun 2003 22:07:07 EDT

Hi all,


I'm trying to write a parser for a new language using preccx 2.45f which
is the latest version I can find.


I'm having a lot of trouble - I'm more used to yacc, but I can't build
this one with single-symbol lookahead without things getting very messy.


I'll start with my smallest problem (I think the others will follow the
same pattern), so if anyone out there is a PreCCX-pert please help...


The line I'm trying to parse is:


int $foo ;


Which declares an integer named $foo.


Here are the relevant bits of my grammar:


========================


@ posh_statement = posh_variable_declaration
@ { posh_whitespace }*
@ <';'>


/* There is more to this rule, but none of the others can be matching */


@ posh_variable_declaration = posh_type
@ { posh_whitespace }+
@ posh_variable
@ [
@ { posh_whitespace }*
@ posh_equal
@ { posh_whitespace }*
@ posh_expression
@ ]


@ posh_type = posh_bool
@ | posh_int
@ | posh_string


/* again, there is more but it's not relevant */


@ posh_int = <'i'>
@ <'n'>
@ <'t'>


@ posh_variable = <'$'>
@ posh_name


@ posh_name = posh_alphabetic
@ { posh_alphanumeric }*


/* I assume you can all guess what posh_alphabetic etc are ;-) */


@ posh_whitespace = <' '>
@ | <'\t'>
@ | <'\n'>
@ | <'\v'>
@ | <'\f'>
@ | <'\r'>
@ | <'#'>
@ >'\n'<*
@ <'\n'>


@ posh_equal = <'='>


/* Hopefully posh_expression is irrelevant since posh_equal can't match */


========================


The full grammar is at http://www.doc.ic.ac.uk/~pgw99/poshparser.y
The lexer to use with it is at http://www.doc.ic.ac.uk/~pgw99/deadsimple.l


I suspect that if I rewrote these clauses for yacc, it would parse
things correctly.


I appreciate any help you can give...


Regards,


Philip Willoughby


Systems Programmer, Department of Computing, Imperial College, London, UK


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.