Skip to content

Commit

Permalink
fix: Add error message for constant inside compound-expr.
Browse files Browse the repository at this point in the history
  • Loading branch information
iphydf committed Jan 22, 2024
1 parent 7102c95 commit c29231a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Language/Cimple/DescribeAst.hs
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ describeExpected options
| wants ["ID_FUNC_TYPE", "non_null", "static", "'#include'"] = "top-level declaration or definition"
| options == ["ID_STD_TYPE", "ID_SUE_TYPE", "struct", "void"] = "type specifier"
| options == ["ID_STD_TYPE", "ID_SUE_TYPE", "const", "struct", "void"] = "type specifier"
| options == ["ID_CONST", "ID_VAR", "LIT_CHAR", "LIT_FALSE", "LIT_INTEGER", "'{'"] = "constant or literal"
| ["ID_FUNC_TYPE", "ID_STD_TYPE", "ID_SUE_TYPE", "ID_VAR"] `isPrefixOf` options = "type specifier or variable name"
| ["ID_FUNC_TYPE", "ID_STD_TYPE", "ID_SUE_TYPE", "const"] `isPrefixOf` options = "type specifier"
| ["ID_CONST", "sizeof", "LIT_CHAR", "LIT_FALSE", "LIT_TRUE", "LIT_INTEGER"] `isPrefixOf` options = "constant expression"
Expand Down
3 changes: 3 additions & 0 deletions test/Language/Cimple/DescribeAstSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ spec = do
expected parseText "int a() { int }" `shouldBe`
"expected variable name"

expected parseStmt "(int){" `shouldBe`
"expected constant or literal"

it "has suggestions for any sequence of tokens in top level" $ do
property $ \tokens ->
expected parseText (Text.intercalate " " (map sampleToken tokens)) `shouldNotContain`
Expand Down

0 comments on commit c29231a

Please sign in to comment.