New answers tagged

0

Many languages support unicode. For example, ①②③⑳ would be a valid Swift identifier. But being able to have the same character sequence being both an identifier and a number is at best confusing and useless.


2

It's worth noting that there are some programming languages, even common ones, that support what you want. For example: In Common Lisp, 1+ is a valid symbol name. C# supports verbatim identifiers, to interoperate with languages that have a different notion of "identifier" than C# does.


1

In many languages, 1e3 is a literal that represents 1000, 0x10 is a literal that represents 16. If we used your proposed regexp for variable names, it would be ambiguous whether those expressions should be represented as a literal or as a variable name.


4

Yes, normally a parser calls the lexical analyser every time it needs a token, and this results in many, many, many calls to the lexical analyser. It is well known by compiler writers that the lexical analysis can consume the larger proportion of the compilers execution time. However, the lexical analysis process would normally use a Chomsky type 3 grammar, ...


Top 50 recent answers are included