Hubro / tree-sitter-robot

Tree-sitter parser for Robot Framework files
ISC License
14 stars 3 forks source link

Emacs tree-sitter #7

Open slalomsk8er opened 9 months ago

slalomsk8er commented 9 months ago

I'm missing the robot-ts-mode major mode and for now stay with robot-mode. While playing with the treesit-explore-mode minor mode, I found some strange behavior:

*** Settings ***
Documentation       A simple web scraper robot.
...                 Opens a website.
...                 Stores the web page text in a file in the output directory.
...                 Saves a screenshot of an element in the output directory.

Library             RPA.Browser.Selenium
Library             RPA.FileSystem

*** Tasks ***
Store Web Page Content
    Open Available Browser    https://robotframework.org/
    ${text}=    Get Text    css:body
    Create File    ${OUTPUT_DIR}${/}text.txt    ${text}    overwrite=True
    Screenshot    css:h1    ${OUTPUT_DIR}${/}screenshot.png
    [Teardown]    Close Browser
---
emacs modeline: task.robot
---
(source_file
 (section
  (settings_section (section_header)
   (setting_statement
    (arguments
     (argument (text_chunk))
     (continuation (ellipses)
      (argument (text_chunk)))
     (continuation (ellipses)
      (argument (text_chunk)))
     (continuation (ellipses)
      (argument (text_chunk)))))
   (setting_statement
    (arguments
     (argument (text_chunk))))))
 (ERROR
  (argument (text_chunk))
  (ERROR (ERROR) SPC (ERROR) (ERROR) SPC (ERROR) SPC (ERROR) SPC (ERROR) (ERROR) SPC (ERROR) SPC (ERROR) (ERROR)
   (ERROR ${ (ERROR) } = (ERROR) SPC (ERROR))
   (ERROR)
   (ERROR (ERROR) SPC (ERROR) ${ (ERROR) } ${ (ERROR) } (ERROR) ${ (ERROR) })
   (ERROR) = (ERROR) (ERROR) (ERROR) ${ (ERROR) } ${ (ERROR) } (ERROR))
  (ERROR) SPC (ERROR)))
---
emacs modeline: *tree-sitter explorer for task.robot*

Why the ERRORS? The first one would be the Library on line 8 but I have no idea it isn't resulting in a setting_statement like the Library on line 7.

Is it me and my limited Emacs and Tree-Sitter skills or did I find a bug?

Hubro commented 9 months ago

Thanks for the report!

I think I've forgotten to add *** Tasks *** as a valid section header. Could you try replacing it with *** Test Cases *** to make sure?

Strange that it would invalidate the second "Library" setting though :thinking:

slalomsk8er commented 9 months ago

Nice catch. I forgot that *** Test Case *** is the normal and *** Tasks *** was added later by https://github.com/robocorp, if I got it right, for RPA. Screenshot_20240104_170916