4

I'm building a programmable piece of software. Idea was to let the end users controll the host system through some scripting. Hence the software comes with a script editor for which I'm using RSyntaxTextArea. All is well till here.

As a final touch, I thought of adding some sort of IntelliSense to the script(The script language is Rhino) editor and I'm not sure how exactly to best implement this(at least to some extent).

To get started, I have started with this amateur approach :

  1. .(dot) character invokes the whole suggestion process.
  2. The script content (excluding the current statement) is *eval*uated and from which I identify variables/functions defined so far and their type. The suggestions are computed based on this.

Alternatively instead of evaluating the script(which is premature), I'm thinking about building AST. Is this a right way to approach this? Do you have any suggestions/links/algorithms etc.. ? How to handle the case when the current state of the script is not compilable? Please advice.

chedine
  • 2,384
  • 3
  • 19
  • 24

1 Answers1

0

Supposing that you are implementing this in Java (due to the java tag) you should take a look at JavaCC it incorporates the lexer, AST handling capabilities and even code generation (although this last part maybe irrelevante to you).

prmottajr
  • 1,816
  • 1
  • 13
  • 22
  • 1
    Well, you need to know what variables have been defined and whatnot, so unless there is an already-available solution, you will have to implement an interpreter for your scripting language. I would prefer doing this by writing the grammar myself ( depends on how complex the language is), and once that's done, you can implement some functions to get variables of an object, and all that jazz. –  Dec 19 '13 at 11:47