Leading or trailing white space characters in file names


Re: Leading or trailing white space characters in file names
#40
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?
Reply
« Next Oldest | Next Newest »



Messages In This Thread
Re: Leading or trailing white space characters in file names - by Roland Melkert - 2012-03-03, 19:23

Forum Jump:


Users browsing this thread: 1 Guest(s)