基本的には、コンパイラ コース用の単純なインタープリターを作成しています。もちろん、これは宿題タイプの質問ではありません。
アスタリスクが後に続くものは、文字列の一部でない限り、コメントと見なされます。インタープリターにブラケットであるエスケープ文字があります。
これらは私のインタープリターのサンプル構文です
* hello world
OUTPUT: "This is asterisk [*]" * outputs string
OUTPUT: "This is asterisk *"  * outputs string produces syntax error
x = "[*]" & "hello" & "[*]*]" this is already comment which produces syntax error
これを実行しようとするとRegex
[^\[]\*.*
次のものと一致します。
* hello world
 * outputs string
 *"  * outputs string produces syntax error
]*]" this is already comment which produces syntax error
私の質問は、なぜregex「食べる」前に1文字だったのですか? 私はすでに必要です
* hello world
* outputs string
*"  * outputs string produces syntax error
*]" this is already comment which produces syntax error