• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JavaCC

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is there a way to know which tokens are possible to follow a partial
string according to a grammar, whose JavaCC parser was generated?

For example:

Lets say you have:

x ::= yz
y ::= "y"
z ::= "a" | "b"

Is it possible that through a JavaCC parser for the above grammar, I
have some kind of framework where if I will provide "y", I will get an
array of the next possible tokens "a" and "b".

For a better understanding of what I need, I want to generate a sort
of small wizard application for a small grammar. This wizard would help the
user in constructing the syntactically correct statements by popping
up the possibilities and the user chooses from them. For example, it
is very similar to how JBuilder pops up a window with the
possibilities in the editor window.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!

I'm very interested in this problem too. The only solution
I thought of is to feed the current input to a different TokenManager object and try to continue with all tokens. The tokens that pass
without an error are the possible extensions at this point.

Haven't implemented it yet because I have no idea how to do this
so far, and it sounds a bit time consuming to try all possible tokens
all the time.

Would be nice if you post your solution.

best regards
Daniel
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic