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

Multi-line variable definitions are broken #1

Open
antonhansson opened this issue Apr 29, 2022 · 5 comments
Open

Multi-line variable definitions are broken #1

antonhansson opened this issue Apr 29, 2022 · 5 comments
Assignees
Labels
enhancement New feature or request

Comments

@antonhansson
Copy link

Blueprint supports multi-line variable definitions, e.g.

    variable =
        "string" +
        variable

The end capture for variables is currently too simple (only matching linebreaks), but the following seems to improve things by disallowing a variable to end with + or =.:
"end": "[^+=][ ]*\\n",

@flimberger flimberger added the enhancement New feature or request label May 6, 2022
@flimberger flimberger self-assigned this May 6, 2022
@flimberger
Copy link
Owner

Hi,
thanks for your report, I'll look into it.
Since I'm currently not working on Android.bp-based projects, this might take some time though.

@flimberger
Copy link
Owner

If I understand the docs correctly, variables need to be terminated by a comma anyway, so I could just match for a trailing comma, i.e. "end": ",\\n",.

Am I missing something?

@flimberger
Copy link
Owner

I have created a branch, maybe you could test it.

@antonhansson
Copy link
Author

Variables needn't end with a comma, see e.g. this file/lines:

https://cs.android.com/android/platform/superproject/+/master:frameworks/base/StubLibraries.bp;l=68-80;drc=ebddedfd9b4380607eed95decbe5178516bca976

The regex I had above seems to cope with this file pretty well.

The added support for += was a nice bonus in your branch though, there's a couple of those here: https://cs.android.com/android/platform/superproject/+/master:frameworks/base/api/Android.bp;l=92-95;drc=2a8c2c360136ea5fe08a23172af0facd6ee0baa0

@flimberger
Copy link
Owner

The simple solution of "end": "[^+=][ ]*\\n", does unfortunately not work, as it leads to ambiguity in this case:

my_var =
    "value"

Both "begin" and "end" match the =, which is disallowed by the textmate grammar spec.
I created a solution which works by splitting the rules for single- and multi-line variable declarations.
Map and list values for variables are still broken, I'll look at those, too.

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

When branches are created from issues, their pull requests are automatically linked.

2 participants