SmaCC question

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

SmaCC question

Brian M
I'm trying to write a simple parser to copy input, but replacing some
text with html links. My problem is that I get this error even on
reduced scanner code:
    'A block compiles more than 1K bytes of code'

By removing 'Deuteronomy' from the scanner code below, things work
fine. Any suggestions would be much appreciated.

Brian.

-------------------- Parser Code

Text :
        Text Term
        | Term ;

Term :
        Reference
        | String
        | <integer> { Transcript show: '1' value asString } ;

Reference :
        BibleReference { Transcript show: '[', '1' first value asString, ']' } ;

       
String :
        ( <word> | <spaces>  | <comma> | <period> | <dash> ) { Transcript
show: '1' value asString. };
       
BibleReference :
        <biblebook> ;


--------------------  Scanner Code

<integer>       :     \d+ ;
<period>        :      \.;
<dash>          :      -;
<comma>       :      ,;

<biblebook> : (Genesis | Gn | Gen | Exodus | Ex | Leviticus | Lv | Lev
| Nm | Num | Numbers | Dt | Deuteronomy) \.? \s+ \d+ (\: \d+ (-
\d+)?)? ;

<word>         :      [^\s\.,]+;
<spaces>        :      \s+;


-------------------- Test Code

Mttt 334 asdf Genesis hello Gn 3:2
Cf Gen 3 42 hm 1 Cor. 3 bloop

Reply | Threaded
Open this post in threaded view
|

Re: SmaCC question

Lukas Renggli
> <biblebook> : (Genesis | Gn | Gen | Exodus | Ex | Leviticus | Lv | Lev
> | Nm | Num | Numbers | Dt | Deuteronomy) \.? \s+ \d+ (\: \d+ (-
> \d+)?)? ;

You should split that huge expression up. Preferably you just keep \.?
\s+ \d+ (\: \d+ (-\d+)?)? as part of the scanner and move the rest
into the parser as literal strings.

This is a problem in Squeak because methods can only have a certain size.

Lukas

--
Lukas Renggli
http://www.lukas-renggli.ch

Reply | Threaded
Open this post in threaded view
|

Re: SmaCC question

Ben Goetter
> This is a problem in Squeak because methods can only have a certain size.

 From where in Squeak does this limit arise?

Ben


Reply | Threaded
Open this post in threaded view
|

Re: SmaCC question

Brian M
In reply to this post by Lukas Renggli
I'm not sure how to do conditional code in the parser. I set your
recommend string to <chapverse> in the scanner and then tried this in
the parser.

BibleReference :
        ( "Genesis" | "Gn" | "Gen" ) [<chapverse>] { Transcript show: '[',
'1' asString, ']' } ;

But this results in a Shift/Reduce Conflict. What I'm trying to
accomplish is 'Gen 3' to be recognized as a bible reference and 'Gen
hello' as a string (not an error).

Brian.


On Feb 18, 2008 4:26 PM, Lukas Renggli <[hidden email]> wrote:

> > <biblebook> : (Genesis | Gn | Gen | Exodus | Ex | Leviticus | Lv | Lev
> > | Nm | Num | Numbers | Dt | Deuteronomy) \.? \s+ \d+ (\: \d+ (-
> > \d+)?)? ;
>
> You should split that huge expression up. Preferably you just keep \.?
> \s+ \d+ (\: \d+ (-\d+)?)? as part of the scanner and move the rest
> into the parser as literal strings.
>
> This is a problem in Squeak because methods can only have a certain size.
>
> Lukas
>
> --
> Lukas Renggli
> http://www.lukas-renggli.ch
>
>