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

RE : RE : problem with lexer.dat



I just though of something,
I use JBuilder from Borland as a development environment...
Can it affect sablecc and prevent it from correctly reading the
lexer.dat file ?

Thanx for the previous answer even though I haven't tried it yet :)
Pascal

-----Message d'origine-----
De?: Etienne Gagnon [mailto:etienne.gagnon@uqam.ca] 
Envoyé?: 7 septembre, 2003 23:25
À?: Pascal AUDANT
Cc?: 'Agbakpem Kevin Komivi'; sablecc-list@sable.mcgill.ca
Objet?: Re: RE : problem with lexer.dat

Pascal,

The Lexer and Parser classes expect the lexer.dat and parser.dat files
to be respectively in the same directory as the Lexer.class and
Parser.class files (be it on the file system, or in a .jar file).

So, assuming your grammar is in the directory c:\mygrammar, you
would do as follows:

...> C:
C:\...> cd \mygrammar
C:\mygrammar> java -jar ...[path-to-jar]...\sablecc.jar
littlegrammar.sablecc
...
[sablecc output]
...
C:\mygrammar> edit Main.java
...[create the Main class of your little compiler]...
C:\mygrammar> javac Main.java
...
C:\mygrammar> edit sampleinput.txt
...[create some input file to test your compiler]...
C:\mygrammar> java Main sampleinput.txt


This should work without complaining about missing or corrupted .dat
files.
(In my experience, I have not heard of corrupted .dat files other than
though bad usage of source-control systems like CVS [if you forget to
disable
keywords/end-of-line conversion]).

If this works, then look for the .dat files in the subdorectories.  If
you
package your compiler, you put leave these files in the same *relative*
pathes, otherwise the lexer & parser classes won't find them.

Have fun!

Etienne

Pascal AUDANT wrote:
> Re everybody,Kevin ... (thank you for the response! )
> I didn't really 'install' sablecc... I just use it by calling it with
> java -jar ...
> 
> I tried once to install it using Ant but it doesn't work. In fact I
> can't even install Ant:
> I am using Win XP and it doesn't recognise the command 'build' when I
> try it from console. (In the manual they say to install Ant for
Windows
> by using the build command :
> 
> build -Ddist.dir=<directory_to_contain_Ant_distribution> dist
> (Windows)
> 
> but when I try it windows says it doesn't know a command 'build'
> 
> Can somebody help me here pls ?
> Thank you !
> Pascal
> 
> 
> -----Message d'origine-----
> De : owner-sablecc-list@sable.mcgill.ca
> [mailto:owner-sablecc-list@sable.mcgill.ca] De la part de Agbakpem
Kevin
> Komivi
> Envoyé : 7 septembre, 2003 16:07
> À : Pascal AUDANT
> Cc : sablecc-list@sable.mcgill.ca
> Objet : Re: problem with lexer.dat
> 
> Pascal AUDANT wrote:
> 
> 
>>Greetings everyone,
>>
>>Btw, thanx alot for your help AND patience.
>>
>>I have now constructed my min grammar file which goes like :
>>
>>Package test;
>>
>>Tokens
>>
>>a = 'a';
>>
>>b = 'b';
>>
>>Productions
>>
>>s = a s [second]:a |
>>
>>{alternative_two} b;
>>
>>I generated all my classes and I implemented them in a main class ?
>>
>>However when I try to run the program I obtain the following error 
>>from the lexer.java class :
>>
>>"The file \"lexer.dat\" is either missing or corrupted."
>>
>>To make sure that the lexer.dat file is not missing I have put it in 
>>C: and change the code to :
>>
>>new BufferedInputStream(
>>
>>Lexer.class.getResourceAsStream("c:/lexer.dat")));
>>
>>However I still obtain the same error msg (The error occurs as soon as
> 
> 
>>lexer tries to read the lexer.dat file in int length = s.readInt();
>>
>>As always your help is really appreciated
>>
>>Pascal
>>
> 
> Hi Pascal, All,
> 
> As mentioned by the SableCC error message, i think that your problem
is 
> related to corruption of the file lexer.dat.
> You do not need to move this file.
> What you can do is :
> first, re-build SableCC(ant clean; ant jar).
> then, generate the classes for your grammar by running SableCC. Before

> that, make sure to remove old generated files if necessary.
> 
> I hope this can help you,
> 
> Cheers,
> 
> kevin
> 
> 
> 
> 
> 
> 


-- 
Etienne M. Gagnon, Ph.D.             http://www.info.uqam.ca/~egagnon/
SableVM:                                       http://www.sablevm.org/
SableCC:                                       http://www.sablecc.org/