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

YueScript compile error with line comments wrong indent #127

Open
GokuHiki opened this issue Feb 28, 2023 · 3 comments
Open

YueScript compile error with line comments wrong indent #127

GokuHiki opened this issue Feb 28, 2023 · 3 comments

Comments

@GokuHiki
Copy link

I encounter this error when work with class. Nothing is serious but maybe you could take a look.

class Behavior
  Start: =>
    Debug.Log("START!")  
-- Observable.EveryUpdate()\Subscribe ->Debug.Log("UPDATE!")
    observable = Observable.EveryUpdate()
    -- observer = Observer.CreateSubscribeObserver((->Debug.Log("UPDATE!")), Stubs.Throw, Stubs.Nop)
    -- disposable = observable\Subscribe observer
    -- DisposableExtensions.AddTo disposable, @actor
  Update: =>

It show error:

5: unexpected indent
    observable = Observable.EveryUpdate()
    ^

Thanks and regards!

@vendethiel
Copy link

That’s not a bug, it’s an indent based language and you had a line with 0 indent so you closed the class.

@GokuHiki
Copy link
Author

GokuHiki commented Mar 1, 2023

No. In indent based language or whatever programming language, inline comments are ignored. So a full line comment would be treated as a blank line. And the blank line is total ignored. EX: python, moonscript, livescript, coffeescript, etc... are all indent based language. And they all ignore full inline comments.

@pigpigyyy
Copy link
Owner

It's intended behavior in Yuescript. I forced the comment to follow the code indent or an advanced indent. You can find the syntax rules here.

empty_line_break = (
check_indent >> (multi_line_comment >> space | comment) |
advance >> ensure(multi_line_comment >> space | comment, pop_indent) |
plain_space
) >> and_(line_break);

The mis-indented comments have inconsistent behaviors in Moonscript, they will either break or not break blocks in different syntax.

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

3 participants