wenyan icon indicating copy to clipboard operation
wenyan copied to clipboard

Escape quote (「」) in string

Open splitline opened this issue 4 years ago • 6 comments

In a lot of programming language, we can use backslash to prevent interpreter from interpreting a quote (", ') as the end of string. I think that wenyan-lang also need feature like this

For example, if I want to print 問「天地」好在。, maybe we can use syntax like this 吾有一言。曰「「問\「天地\」好在。」」。書之。 But put backslash straightly seems doesn't fit with the wenyan philosophy :/

splitline avatar Dec 18 '19 08:12 splitline

If quote notations 「」 inside the string necessarily match up, then they can be directly determined by AST. The problem comes when quote notations inside the string do not required to be matched up, e.g. print 問「「, then print 天地, then print 」」好在。

shyoshyo avatar Dec 18 '19 08:12 shyoshyo

how about using something like 萬國碼之一萬兩千三百零一 to represent \u300d, i.e.

shyoshyo avatar Dec 18 '19 08:12 shyoshyo

how about using something like 萬國碼之一萬兩千三百零一 to represent \u300d, i.e.

satouriko avatar Dec 18 '19 08:12 satouriko

@shyoshyo I like your solution! Or perhaps we can wrap String.fromCharCode to do the trick.

LingDong- avatar Dec 18 '19 08:12 LingDong-

how about using something like 萬國碼之一萬兩千三百零一 to represent \u300d, i.e.

Is 「二」not better than「兩」?

nikacan avatar Dec 18 '19 09:12 nikacan

Before there is a escape syntax, you can do like this:

夫「「「」」」之一。名之曰「左括弧」。
夫「「「」」」之二。名之曰「右括弧」。

夫「左括弧」書之。
夫「右括弧」書之。

cuixiping avatar Jan 13 '20 06:01 cuixiping