Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incremental parsing #76

Closed
JessicaLopezEspejel opened this issue Nov 12, 2021 · 1 comment
Closed

Incremental parsing #76

JessicaLopezEspejel opened this issue Nov 12, 2021 · 1 comment

Comments

@JessicaLopezEspejel
Copy link

JessicaLopezEspejel commented Nov 12, 2021

Hello, how can I use your parser to work as I explain in the following lines?

code = 'System'
code = 'System.'
code = 'System.out'
code = 'System.out.' 
code = 'System.out.println' 
code = 'System.println('
code = 'System.println("hello")

It means, the parser should be able to detect that the java syntax is doing well at each time I add one or more tokens. I tried using tree-sitter, but it did work and I do not know if there is a trick.

The code I tested is:

from tree_sitter import Language, Parser
JAVA_LANGUAGE = Language('parser/my-languages.so', 'java') 
parser = Parser() 
parser.set_language(JAVA_LANGUAGE)
code = 'System.' #.out.println("hello");  
tree = parser.parse(bytes(code,'utf8')).root_node 
subtree= [x[0] for x in get_all_sub_trees(tree)]

When code = 'System.out.println("hello"); works, but when code = 'System' fails

Thank you in advance

@JessicaLopezEspejel
Copy link
Author

Answer by @maxbrunsfeld
""
With Tree-sitter, you need to have the entire text available before you can start parsing. It doesn't all need to be stored in a single string/buffer, but you do need to have it available via a callback.
""

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant