[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Is SableCC 2.13 Thread-safe?
SableCC is generally thread safe in a sense that you have to:
a) create a seperate parser/lexer pair fo each single parsing of the input
b) synchronized yourself a) so two parser/lexer constructors are not
The constrain b) is due to the read-only file access implementations on
some JVMs, which is throwing an exception if two objects are trying
simultanously access single file in read-only mode. You can easily fix
that by embeding the section of the parser/lexer which opens and reads
parser.dat/lexer.dat into a synchronized block synchronized on some static
object. It works just fine then.
The constrain a) is due dependency of SableCC 2.13 on some static data
structures. I have a patch which removes all static dependencies from
SableCC and makes your parser/lexer pair reusable, so you can perform
multiple parser generations using the same objects. Then there is no need
to reinitialize new objects all over again for each generation phase.
You can find the patch in the mailing list archive, or you can download
the patched compiled version from:
(have a look at the source code for the reference)
I will prepare another patch which will generate the synchronized
block in parser/lexer constructor for the user automatically in the
generated parser/lexer source, and anable user to pass more than single
grammar file in the command line mode, like:
java SableCC -d dir grammar1.txt grammar2.txt ...
Tell me if you would be interested.
> I'm looking at using a parser inside a servlet, and I was wondering
> if anyone knew whether SableCC is thread-safe. JavaCC is currently
> not thread-safe due to some static data members.
> Thanks in advance,