Yes, that would be nice, and right now the parser skips over all line ending characters in any combination. I'd like to keep it that way. At work here are two forces: the flexibility required to support the varied lengths of object "headers", and my desire not to force compilers to pass around specifics about their keywords.
The first problem can be shown with two examples
Code: Select all
Test/ParticleSystem1{}
fragment_program Test/FP cg{}
The length of headers varies greatly. Add in the optional behavior to have either of those inherit from another object and it stars getting very ambiguous. The problem is, once inside an object (like a material) how do you discern between a technique definition and a property definition, without knowing ahead of time keywords like "technique" and "diffuse" and without taking into account newlines? Ambiguity is just bad for a language, and this one has way too much dependence on context for the parser to do this much work.
So, why do I want specific compilers to not have to pass around keywords? These compilers that are specific to one resource type know what keywords they are looking for. Forcing them to store those keywords in a structure, and pass it around for a reusable parser to know will be slow, memory intensive, and inflexible. What happens if a plugin wants to add something? Yes, it can be done. It just isn't the correct way to do it.
I think I can make it work in a newline-independent way. The only landmarks for the parser to organize the AST by during parsing are the '{' '}' characters. Other than that the input will be tagged with a few ID codes and fed as a largely unsorted blob. Since the final compiler knows how many values need to be read for a "diffuse" property, it can easily sort out the input stream of tokens. Same with headers. Based on the context, the material compiler will know that given certain conditions "fragment_program" will validly define a fragment program, and be able to extract the correct information from the header leading up the '{'. Errors can also be more contextual and hopefully, more helpful.
So to summarize. Some back-tracking, yes. But not too far, and I think I can sort it out quickly. It was totally my fault. I made far too many assumptions based on my pretty extensive knowledge of material scripts, and my less-than-adequate knowledge of the other script forms. Won't make that mistake again.