LDraw.org Discussion Forums

Full Version: Leading or trailing white space characters in file names
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5 6
Here's a summary:

Replace in http://www.ldraw.org/Article218.html#files:

Quote:Every line of the file contains one command. With few exceptions, every command is independent of other lines. The exceptions are the BFC meta-commands which modify the behaviour of one or more following command lines. There is no line length restriction. The whitespace characters allowed for keyword and parameter separation include spaces and tabs. Every command starts with a number, called a line type. The function and format of the line is determined by the line type.

with

Quote:Every line of the file contains one command. With few exceptions, every command is independent of other lines. The exceptions are the BFC meta-commands which modify the behaviour of one or more following command lines. There is no line length restriction. Every command starts with a number, called a line type. The function and format of the line is determined by the line type.

Add a section below it:

Quote:White space

Command parameters for every line type must be separated by white space. The white space characters used to separate these parameters may be either space or tab. Both should be treated the same, and any number of contiguous white space characters (1 or more) are allowed.

And as a result of the above we can adjust the line:

Quote:<file> is the filename of the sub-file referenced and must be a valid LDraw filename.

to

Quote:<file> is the filename of the sub-file referenced and must be a valid LDraw filename. Any leading and/or trailing whitespaces must be ignored.

Add to http://www.ldraw.org/Article398.html

PartDescription is the descriptive name of the part ...

Quote:Leading white space in front of this very first linetype 0 is not allowed.

If we all agree I'm going to call for a vote.

w.
I think the new white space section should be modified to add one more sentence on the end, like so:

Quote:White space

Command parameters for every line type must be separated by white space. The white space characters used to separate these parameters may be either space or tab. Both should be treated the same, and any number of contiguous white space characters (1 or more) are allowed. Any number of white space characters may also precede the line type.

The reason for my suggestion is that without it, the legality of preceding white space characters is somewhat ambiguous. Everything else you had looks good to me.
Fine with it.

w.
Maybe it's me not being a native English reader, but to me it could be interpreted like you have to pick ether space or tab for white space. Maybe use 'any combination of white space characters' somewhere?

As a result of the recent discussions concerning the linetype 0 in respect to the first line I would also like to change

Quote:Leading white space in front of this very first linetype 0 is not allowed"

into

Quote:Leading white space in front of this very first linetype 0 is discouraged"

Otherwise you will break inlinineing of mpd's. Actually it's more a recommendation to the very first line of the file whatever it's linetype might be.
Roland Melkert Wrote:Maybe it's me not being a native English reader, but to me it could be interpreted like you have to pick ether space or tab for white space. Maybe use 'any combination of white space characters' somewhere?

Agree.

Roland Melkert Wrote:"Leading white space in front of this very first linetype 0 is discouraged"

I view discouragements as a means of highlighting cross-platform or serious legacy software pitfalls. In this case, I don't see any great advantage in a discouragement. The practice has already escaped into the wild, and I think clarity and decisiveness would be best here.

More knowledgable people, please correct me.

Allen
Willy Tschager Wrote:Here's a summary:

Replace in http://www.ldraw.org/Article218.html#files:

Quote:Every line of the file contains one command. With few exceptions, every command is independent of other lines. The exceptions are the BFC meta-commands which modify the behaviour of one or more following command lines. There is no line length restriction. Every command starts with a number, called a line type. The function and format of the line is determined by the line type.

I think the phrase "Every command starts with a number" is misleading, as a cursory reading would indicate that leading whitespace is forbidden. I also think the whole logical flow of the paragraph was/is jumbled. I would prefer the following:

Quote:Every line of the file contains one command. A command consists of optional leading whitespace, a number indicating the line type, and whitespace-delimited fields. The function and format of the line is determined by the line type number, while the fields contain the line's data. There is no line length restriction. Most commands are independent of other lines, although there are a few rare exceptions in which a line modifies the behaviour of one or more following command lines. For example, the BFC meta-commands change the interpretation of subsequent geometry.

A serious problem with both this text, and the original, is that it appears to disallow empty or whitespace-only lines. I think that should also be addressed.

Allen
In regards to the latest posts it seems we all agree on the spec changes. However formatting the text seems to be the current problem.

I think the best way of doing this is rewriting the introduction (specifying the entire documents (basic) parse rules.) Followed by noting the exceptions in the affected line-type texts (e.g. comments and filename).

I'm willing to give this a try somewhere this week, unless one of you is already working on it.

On a side note: It seems we forgot to increase the spec doc's version after the changes of last year.
Roland Melkert Wrote:I'm willing to give this a try somewhere this week, unless one of you is already working on it.

Roland, are you working on this?

w.
Yes, although I had less time for it than planned due to work etc.

Hoping to post it this weekend.
Ok it took me somewhat longer than planned, but here goes:

Replace Wrote:Every line of the file contains one command. With few exceptions, every command is independent of other lines. The exceptions are the BFC meta-commands which modify the behaviour of one or more following command lines. There is no line length restriction. The whitespace characters allowed for keyword and parameter separation include spaces and tabs. Every command starts with a number, called a line type. The function and format of the line is determined by the line type.

With Wrote:Basic parsing / file content

A LDraw file consists of single lines separated by DOS format line breaks (#13#10). Each line consists out of a number of tokens separated by whitespace. Whitespace is a string of one or more characters made out of any combination of spaces (#32) and/or tabs (#9). Lines with zero tokens are allowed and should be ignored.

If a line is non empty the first token must be a single digit numeric value. This number identifies the linetype and dictates further parsing of tokens for that line. The parsing rules per linetype follow below.

Although not mandatory, it is recommended to not use leading whitespace before the linetype token on the fist line of a file. This to assist software in determining the character encoding of the file.

"Basic parsing / file content" being a bullet just like "Text bases" etc.

Next adjust the comments part....

Add before start of meta part Wrote:Please note for any commentline normal token parsing is disabled, the value of a comment must be threaded as a single string value starting with the first non whitespace character after the '0' token up to the end of the fileline excluding trailing whitespace

And..

Replace Wrote:A META command is a statement used to tell an LDraw compatible program to do something. There are currently many official META commands and even more unofficial META commands. In a META command, a keyword follows the line type in the line. The keyword must be in all caps. The generic META line format is:

0 !<META command> <additional parameters>

Where:

With Wrote:A META command is a statement used to tell an LDraw compatible program to do something. There are currently many official META commands and even more unofficial META commands.

A meta command line, in essence, is a special comment. So to detect them any parser must take a second look at a comment line after it has been read like described above. The first token in the raw comment string is used to identify the command and dictates how (if at all) to parse the remaining of the line. The general format of a command line is (Please note the 'missing' '0' token, this was stripped while parsing the comment):

!<META command> <additional parameters>

Where:

Finally adjust the file reference part...

Replace Wrote:<file> is the filename of the sub-file referenced and must be a valid LDraw filename.

With Wrote:<file> is the filename of the sub-file referenced and must be a valid LDraw filename. Please note normal token separation is disabled for the filename value. The filename consist of all the characters read from the start (first non whitespace character after last token) up to the end of the fileline excluding trailing whitespace.

Hope this is (more) clear, although a native English speaking person might want to tweak this somewhat. Only part I'm not too sure about is the meta command part, i think it could be difficult to understand for people new to the format. It might need a deeper rewrite?
Pages: 1 2 3 4 5 6