Implement Identifier Checking (for reserved characters) #16

Closed
djspiewak opened this Issue May 12, 2011 · 2 comments

Comments

Projects
None yet
2 participants
Owner

djspiewak commented May 12, 2011

Currently, it is possible to do something like this following:

Elem(None, "<", Attributes(), Group())

Clearly, this Elem name doesn't make any sense. We should run all identifiers through a regexp to ensure this case is rejected at runtime.

Contributor

jespersm commented May 13, 2011

An exception should be thrown in Elem#apply, right?
Normally, I'd go for IlleglArgumentException or similar, is this bad Scala style?

Owner

djspiewak commented May 13, 2011

Actually, it should be thrown in the constructor for Elem. It's easier (and more efficient at runtime) if we stick with the compiler auto-generated apply method on the Elem companion object.

IllegalArgumentException is actually just right for the situation. I'm usually a bit lazy with my exceptions in Scala and I just use RuntimeException everywhere (which is definitely bad Scala style). :-) That reminds me: I really should go through and replace those instances in Anti-XML…

djspiewak added a commit that referenced this issue May 17, 2011

@djspiewak djspiewak closed this May 17, 2011

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment