Re:ASCII and Unicode quotation marks
by hk__2 on Wednesday September 13, 2017 @05:47PM
(#15243027)
You don’t need escaping in «This is a string containing an «embedded» quoted string».
[ Parent
| on HN ]
Re:ASCII and Unicode quotation marks
by cassowary on Wednesday September 13, 2017 @11:15PM
(#15244743)
«Hi. How do I open a quote?»
«Oh, you just use the « character.»
Parse error. Unexpected EOF.
That wouldn’t be a good idea but you could adapt your parser to support that case. You can write `/* /* */` in C, for instance.
To clarify: we’d still need escaping but in fewer cases.
Re:ASCII and Unicode quotation marks
by tedunangst on Wednesday September 13, 2017 @06:05PM
(#15243166)
Debatable whether that would actually work in practice.
/* nested /* comments */ don't work */
Re:ASCII and Unicode quotation marks
by int_19h on Wednesday September 13, 2017 @09:58PM
(#15244453)
They don't work in C, but that's an arbitrary decision made by its designers. There are many languages that have balanced comments that can be nested. In OCaml, for example, this is legal:
(* nested (* comments *) work *)This is possible in D using /+ comments +/.
https://wiki.dlang.org/Commenting_out_code#Nested_comments
This allows commenting out code containing comments, which can be useful when debugging or giving usage examples in the code.
I think it would make the parsing a tiny bit more inconvenient though
Yup, suddenly your parser needs to keep a count of how many nested strings deep it is.
Re:ASCII and Unicode quotation marks
by munificent on Thursday September 14, 2017 @12:02AM
(#15244914)
It's not hard. Obviously the parser has to do that things that aren't a single token like parenthesized expressions.
Even for things where the nesting does happen during lexical analysis, it's pretty trivial to keep a count in your lexer. Lots of languages support nesting comment syntax or string interpolation, which both have equivalent difficulty.
Re:ASCII and Unicode quotation marks
by userbinator on Wednesday September 13, 2017 @10:17PM
(#15244537)
Don't forget that "parser" also includes human brains, which tend to not be that great at parsing nested things.
To use formal language theory, strings containing escape characters are regular, i.e. parseable with a finite-state machine. Allowing nesting means you need a stack to find the matching pair.
It’s trivial to do; parsers handle nested things quite easily.
Re:ASCII and Unicode quotation marks
by jrochkind1 on Wednesday September 13, 2017 @09:52PM
(#15244429)
ruby does that. computers are pretty fast now.