Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Annlix
ShellCheck
提交
9dfcf54f
S
ShellCheck
项目概览
Annlix
/
ShellCheck
与 Fork 源项目一致
Fork自
镜像 / koalaman / ShellCheck
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
ShellCheck
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
9dfcf54f
编写于
3月 04, 2018
作者:
V
Vidar Holen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Functionality for emitting parse errors but still continue
上级
c8cd9dd0
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
39 addition
and
4 deletion
+39
-4
ShellCheck/Parser.hs
ShellCheck/Parser.hs
+39
-4
未找到文件。
ShellCheck/Parser.hs
浏览文件 @
9dfcf54f
...
...
@@ -301,12 +301,15 @@ pushContext c = do
parseProblemAtWithEnd
start
end
level
code
msg
=
do
irrelevant
<-
shouldIgnoreCode
code
unless
irrelevant
$
Ms
.
modify
(
\
state
->
state
{
parseProblems
=
note
:
parseProblems
state
})
addParseProblem
note
where
note
=
ParseNote
start
end
level
code
msg
addParseProblem
note
=
Ms
.
modify
(
\
state
->
state
{
parseProblems
=
note
:
parseProblems
state
})
parseProblemAt
pos
=
parseProblemAtWithEnd
pos
pos
parseProblemAtId
::
Monad
m
=>
Id
->
Severity
->
Integer
->
String
->
SCParser
m
()
...
...
@@ -1146,6 +1149,7 @@ readBackTicked quoted = called "backtick expansion" $ do
parseProblemAt
pos
ErrorC
1077
"For command expansion, the tick should slant left (` vs ´). Use $(..) instead."
-- Run a parser on a new input, such as for `..` or here documents.
subParse
pos
parser
input
=
do
lastPosition
<-
getPosition
lastInput
<-
getInput
...
...
@@ -2943,10 +2947,11 @@ parseShell env name contents = do
prTokenPositions
=
Map
.
empty
,
prRoot
=
Nothing
}
notesForContext
list
=
zipWith
(
$
)
[
first
,
second
]
$
filter
isName
list
where
isName
(
ContextName
_
_
)
=
True
isName
_
=
False
notesForContext
list
=
zipWith
(
$
)
[
first
,
second
]
$
filter
isName
list
first
(
ContextName
pos
str
)
=
ParseNote
pos
pos
ErrorC
1073
$
"Couldn't parse this "
++
str
++
". Fix to allow more checks."
second
(
ContextName
pos
str
)
=
ParseNote
pos
pos
InfoC
1009
$
...
...
@@ -3020,6 +3025,36 @@ parseScript sys spec =
checkSourced
=
psCheckSourced
spec
}
-- Same as 'try' but emit syntax errors if the parse fails.
tryWithErrors
::
Monad
m
=>
SCParser
m
v
->
SCParser
m
v
tryWithErrors
parser
=
do
userstate
<-
getState
oldContext
<-
getCurrentContexts
input
<-
getInput
pos
<-
getPosition
result
<-
lift
$
runParserT
(
setPosition
pos
>>
getResult
parser
)
userstate
(
sourceName
pos
)
input
case
result
of
Right
(
result
,
endPos
,
endInput
,
endState
)
->
do
-- 'many' objects if we don't consume anything at all, so read a dummy value
void
anyChar
<|>
eof
putState
endState
setPosition
endPos
setInput
endInput
return
result
Left
err
->
do
newContext
<-
getCurrentContexts
addParseProblem
$
makeErrorFor
err
mapM_
addParseProblem
$
notesForContext
newContext
setCurrentContexts
oldContext
fail
""
where
getResult
p
=
do
result
<-
p
endPos
<-
getPosition
endInput
<-
getInput
endState
<-
getState
return
(
result
,
endPos
,
endInput
,
endState
)
return
[]
runTests
=
$
quickCheckAll
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录