Hi Basil,
I've created a library in the past that provides this capability. It
has APIs to create a JFlex and a Cup files, uses JFlex and Cup to
generate a parser class with a different name each time, and loads it
as the new parser. If you are interested, I'll look for it and send
it in private. The problem is that it's old, not been recently
compiled, and still had lots of bugs in it
Hadrien
Le 1 sept. 08 à 20:06, costa basil a écrit :
>
> Hi:
>
> Is it possible with JFlex to have a programming interface and do the
> scanning dynamically? So, instead of having JFlex generating the lexer
> (that is generating source code), JFlex would provide an interface
> that a programmer would use to set values, add actions and patterns,
> then JFlex does the magic and then I can run it all in one go without
> the need to generate any source code at all.
>
> Example of interface:
>
> Lets say you have an interface IAction that emulates an action that
> you'd normally specify in the lex file (such as: { return
> symbol(sym.ABSTRACT); })
>
> interface IAction {
> public <actionReturnType> execute(<some parameters - could provide a
> reference to the lexer itelf>);
> }
>
>
> Then in the main lexer class (provided by JFlex) you have functions
> such as:
>
> addPattern(String pattern, IAction action);
> addPattern(int state, String patter, IAction action);
>
> addDefinition (...) for lines such as: CommentContent = ( [^*] | \*
> + [^/*] )*
>
> buildInternalTables()... - this does all the work to build tables or
> whatever that would be used in the scanning.
>
> The you are ready to do the parsing.
>
> One use for this would be to scan text files where the delimiters are
> configurable.
>
> If jflex can't do this, is there any other java tool that could have
> these features?
>
>
> Thanks
>
> ----------------------------------------------------------------------
> ---
> This SF.Net email is sponsored by the Moblin Your Move Developer's
> challenge
> Build the coolest Linux based applications with Moblin SDK & win
> great prizes
> Grand prize is a trip for two to an Open Source event anywhere in
> the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> --
> jflex-users mailing list
> https://lists.sourceforge.net/lists/listinfo/jflex-users
>
|