Mr Flibble <
flibbleREM...@i42.co.uk> writes:
> It took me just five minutes to add support for escape sequences in an
> example programming language's string literal concept:
>
> string_literal: {
> is: string.utf8
> tokens: {
> '\"': {
> '\"': done
> escape: continue
> '\\': error
> character: continue
> }
> }
> escape: {
> tokens: {
> '\\': {
> 'n': character.LF
> character.LF: done
> 'r': character.CR
> character.CR: done
> 't': character.tab
> character.tab: done
> '\\': character.backslash
> character.backslash: done
> }
> }
> }
> }
>
> Designing new programming languages will be quick and easy with neos
> the universal compiler that can compile any programming language! :D
Do you have any real-world examples? For example, what do C11's strings
look like in neos? And in languages that can use either ' or " does the
work need to be duplicated? What about languages with arbitrary (and
sometimes non-identical) delimiters like Perl's q(x)? What about
Fortran's counted Hollerith string constants? Python has "..." as well
as """...""" complicated by the fact that adjacent strings are
syntactically possible. How would neos handle "" " """ being three
strings and """ """ being one? (This might be simple in that there
could be a higher-level of tokens that is not shown in your example.)
--
Ben.