icerpc / slicec

The Slice compiler library
Apache License 2.0
13 stars 5 forks source link

Disallow Identifiers that Start with an Underscore #633

Closed InsertCreativityHere closed 1 year ago

InsertCreativityHere commented 1 year ago

This PR implements part of #632: Identifiers (both in Slice and preprocessor directives) can no longer start with an underscore.

This does not implement the banning of multiple consecutive underscores (See https://github.com/icerpc/slicec/issues/632#issuecomment-1627855130)

If you think that even this is too restrictive, feel free to say so and I'll close it. But, at the very least we need to reject just _ as an identifier, since this is a reserved identifier in some languages.

InsertCreativityHere commented 1 year ago

I added some tests! Wasn't sure about adding them originally since now it's just a plain 'ol syntax error like %foo.

Note that we don't have a test for identifiers starting with a number in Slice because that's already handled by the integer literal tests.