[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Questions



Answer to Q1:

Look at the "public static String name(String s)" method in class
"ca.mcgill.sable.sablecc.ResolveIds" (in SableCC's source code). It is
probably what you are looking for. (Do not forget the LGPL license on this
code!)

Answer to Q2:

Look through  the mailing list archive. There has been a pretty good
discussion about this problem, and possible solutions. My preferred solution
involves major changes to SableCC, but don't wait for it.

A simple trick is to have an "end of message" token. Then you use a
customized lexer to replace this token by an EOF token that you send to the
parser.

Etienne

-----Original Message-----
From: Philippe <plegay@atos-group.com>
To: sablecc-lis@sable.mcgill.ca <sablecc-lis@sable.mcgill.ca>;
sablecc-list@bluebeard.CS.McGill.CA <sablecc-list@bluebeard.CS.McGill.CA>;
gagnon@bluebeard.CS.McGill.CA <gagnon@bluebeard.CS.McGill.CA>
Date: November 26, 1998 10:13 AM
Subject: Questions


>Hello,
>
>Question 1
>********
>I will have to produce an extension of  a DepthFirstAdapter generated by
>
>SableCC itself.
>
>For instance for the rule:
>suite02_bmr70 = thdr one_entity suite02_bmr70
>              | {empty}
>              ;
>
>I have to produce the java code
> public void caseASuite01Bmr70(ASuite01Bmr70 node)
>   {  System.out.println("caseASuite01Bmr70") ;
>      bmrcou = new BMR70K() ;
>   // Get one_entity
>      (node.getOneEntity()).apply(this) ;
>   // Add vector
>      bmrcou.AddToVector_liste_entity(symcou) ;
>   // Next Apply
>      (node.getSuite02Bmr70()).apply(this) ;
>   }
>So do you know a SableCC method: Convert
>Convert(suite02_bmr70) gives Suite01Bmr70
>Convert(one_entity) gives OneEntity.
>
>Question 2
>********
>Normally, I use the Lexer and the Parser (generated by SableCC) I have a
>finished input : a File.
>
>In my case, my input is a TCP/IP Stream, where a End of Stream says
>"This is the end, or this is an error".
>
>The parser is able to say : " I have read a full coherent sequence,
>therefore I want to stop and do the AST walk to produce actions. Then I
>want to continu reading from the TCP/IP Stream."
>
>My question is : How can I say to the parser, stop when you have see a
>coherent block (I can write in the grammar, that I have a coherent
>block).
>
>
>Thanks.
>
>
>