Re: LL(1) and common-heads...

d.sand@ix.netcom.com (Duane Sand)
14 Jan 1996 18:51:30 -0500

          From comp.compilers

Related articles
LL(1) and common-heads... p8uu@jupiter.sun.csd.unb.ca (1995-12-28)
LL(1) and common-heads... deakjahn@ludens.elte.hu (Gabor DEAK JAHN) (1995-12-30)
Re: LL(1) and common-heads... mparks@oz.net (1996-01-12)
Re: LL(1) and common-heads... d.sand@ix.netcom.com (1996-01-14)
Re: LL(1) and common-heads... Osman.Buyukisik@ae.ge.com (U-E59264-Osman Buyukisik) (1996-01-15)
| List of all articles for this month |
From: d.sand@ix.netcom.com (Duane Sand)
Newsgroups: comp.compilers
Date: 14 Jan 1996 18:51:30 -0500
Organization: Netcom
References: 95-12-143 96-01-014
Keywords: parse, assembler

p8uu@jupiter.sun.csd.unb.ca says...
>Hi all, I've written an actual assembler for this new OS that
>a bunch of us are trying to get off the ground (originally from
>r.g.p.). Anyhow, the assembler works fine, but I'm not using any
>parsing algorithms like LL(1) or SLR. I was wondering if it would be
>of any use writing it using LL(1). Or would anyone suggest a better
>algorithm?


mparks@oz.net (Michael Parkes) writes:
>It looks to me like you are using the wrong tool for the job. If I
>understand you correctly this is a semantic problem and should be dealt
>with as such. Try using an attribute grammar that supports 'sparse'
>tables. This will allow you to define the valid semantic mappings and
>will vastly simplify the syntax processing. The basic job should only
>require about 2,000 lines.


If you've got your assembler working, why mess with it further at all?
Is it too slow? Too fast? Too big? Too small? Too simple? Too
inelegant? Completed too soon?


Most assemblers have so little syntax that BNF-based methods are
overkill and will double the complexity of the "parse". You should
pick some compact tabular way to relate opcode names and operand
patterns and instruction bit patterns, and not worry about fancy
algorithms at all.


The 2000 source line suggestion is very inflated. By comparison,
implementations of the Forth language typically have a built-in
assembler included, which is typically about 200 lines of source code
for current machines. Of course they cheat, by using a rational
nontraditional syntax for the instructions, and using a compact
language, and building on top of a simple but powerful
scanner/interpreter system.
[Good point. You should be able to write an entire assembler in 2000 lines.
-John]














--


Post a followup to this message

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