From 3cbb4891100a864e17af5a77dec23942caea3577 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Wed, 22 Apr 2020 15:00:59 +0800 Subject: fix #156 --- script/glob/gitignore.lua | 4 +++- script/glob/glob.lua | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/script/glob/gitignore.lua b/script/glob/gitignore.lua index f96aa627..315efa37 100644 --- a/script/glob/gitignore.lua +++ b/script/glob/gitignore.lua @@ -35,7 +35,9 @@ local parser = m.P { + object('?', m.P'?') + object('[]', m.V'Range') , - ['Char'] = object('char', (1 - m.S',{}[]*?/\\')^1), + ['SimpleChar'] = m.P(1) - m.S',{}[]*?/', + ['EscChar'] = m.P'\\' / '' * m.P(1), + ['Char'] = object('char', m.Cs((m.V'EscChar' + m.V'SimpleChar')^1)), ['FSymbol'] = object('**', m.P'**'), ['Range'] = m.P'[' * m.Ct(m.V'RangeUnit'^0) * m.P']'^-1, ['RangeUnit'] = m.Ct(- m.P']' * m.C(m.P(1)) * (m.P'-' * - m.P']' * m.C(m.P(1)))^-1), diff --git a/script/glob/glob.lua b/script/glob/glob.lua index aa8923f3..9cfbdc7e 100644 --- a/script/glob/glob.lua +++ b/script/glob/glob.lua @@ -19,7 +19,7 @@ end local parser = m.P { 'Main', ['Sp'] = m.S(' \t')^0, - ['Slash'] = m.S('/\\')^1, + ['Slash'] = m.P('/')^1, ['Main'] = m.Ct(m.V'Sp' * m.P'{' * m.V'Pattern' * (',' * expect(m.V'Pattern', 'Miss exp after ","'))^0 * m.P'}') + m.Ct(m.V'Pattern') + m.T'Main Failed' @@ -35,7 +35,9 @@ local parser = m.P { + object('?', m.P'?') + object('[]', m.V'Range') , - ['Char'] = object('char', (1 - m.S',{}[]*?/\\')^1), + ['SimpleChar'] = m.P(1) - m.S',{}[]*?/', + ['EscChar'] = m.P'\\' / '' * m.P(1), + ['Char'] = object('char', m.Cs((m.V'EscChar' + m.V'SimpleChar')^1)), ['FSymbol'] = object('**', m.P'**'), ['RangeWord'] = 1 - m.P']', ['Range'] = m.P'[' * m.Ct(m.V'RangeUnit'^0) * m.P']'^-1, -- cgit v1.2.3