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

should this be valid #59

Open
SingingBush opened this issue Jun 6, 2018 · 2 comments
Open

should this be valid #59

SingingBush opened this issue Jun 6, 2018 · 2 comments
Labels

Comments

@SingingBush
Copy link

a matrix could be defined as any of the following:

matrix {
    581 984
    321 35
}
matrix {
    581 984;
    321 35;
}
matrix {
    581 984; 321 35
}

So should matrix { 581 984; 321 35 } also be valid? It's not too clear from the mirrored docs. I'm trying to iron out issues with the Java implementation sdlang-dev/SDL#5

@Abscissa
Copy link
Collaborator

Abscissa commented Jun 7, 2018

In short, no.

Here's the key thing to be aware of with SDLang:

Despite the curly braces and semicolons, SDLang is NOT a free-form semicolon-terminated language like the C-family. SDLang is a newline-based language, like INI files or shell scripts.

This is the basic grammar of a the simple matrix example:

matrix { <NEWLINE>
    581 984 <NEWLINE>
    321 35 <NEWLINE>
} <NEWLINE>

That right there IS the syntax for adding children to a tag, period.

Second key point: It just so happens that SDLang allows a semicolon to be used as a substitute for a newline. This is to allow combining things onto one line.

That means, your second example:

matrix {
    581 984;
    321 35;
}

REALLY means this:

matrix {
    581 984

    321 35

}

Note the two blank lines (which just happen to be inconsequential, because blank lines are ignored in SDLang).

Therefore, if you want to put the entire matrix on one line, you don't do it the C-style way. Instead, you replace the newlines with semicolons:

matrix {; 581 984; 321 35 }

And of course, technically, you can add more semicolons if you want:

// Ugly and pointless, but valid and still means
// the same thing (just with extra blank lines)
;;;;; matrix {;;;; 581 984;;; 321 35;;;;; };;;

And you're right: This should be more clear in the docs.

@Abscissa Abscissa added the docs label Jun 7, 2018
@SingingBush
Copy link
Author

thanks for clarifying

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

No branches or pull requests

2 participants