我有以下输入字符串:
(
(
(App = smtp AND "Server Port" != 25)
OR
(App = pop3 AND "Server Port" == 20)
)
AND
(App = smtp AND "Server Port" != 35)
)
OR
(App = pop3 AND "Server Port" != 110)
AND
(
(App = imap AND "Server Port" != 143)
OR
(App = pop3 AND "Server Port" == 20)
)
AND (App = imap OR "Server Port" != 143)
想变成:
[
[
[
'App = smtp AND "Server Port" != 25',
'OR',
'App = pop3 AND "Server Port" == 20'
],
'AND',
'App = smtp AND "Server Port" != 35'
],
'OR',
'App = pop3 AND "Server Port" != 110',
'AND',
[
[
'App = imap AND "Server Port" != 143',
'OR',
'App = pop3 AND "Server Port" == 20'
]
],
'AND',
'App = imap OR "Server Port" != 143'
]
我如何在 pegjs 语法中做到这一点?
我当然可以编写一个 javascript 代码,但我正在寻找 PEGjs 的一些帮助。