on master help sign in
Remove a bunch of commented out error messages

These are no longer useful references, either because new messages have already been written or because the parser works differently enough that they are no longer relevant to how things will be.

commit13a0ae57f548936c4875978bf76997001af55017 authorEvan Czaplicki <evancz@users.noreply.github.com> dateMon 6 May 2019, 18:14 (7 years ago) parentf20c662
1 file changed−329
compiler/src/Reporting/Error/Syntax.hs−329
compiler/src/Reporting/Error/Syntax.hs−329
@@ -1478,24 +1478,6 @@ toFuncReport source name func frow fcol =
14781478 region = A.Region pos pos
14791479 in
14801480 case expectation of
1481− TODO ->
1482− error "TODO no parse error yet"
1483−
1484− XXX ->
1485− error "TODO no parse error yet"
1486−
1487− -- Parse.Utils
1488−
1489− HasTab ->
1490− Report.Report "NO TABS" region [] $
1491− Report.toCodeSnippet source region Nothing
1492− (
1493− D.reflow $
1494− "I ran into a tab, but tabs are not allowed in Elm files."
1495− ,
1496− D.reflow $
1497− "Replace the tab with spaces."
1498− )
14991481
15001482 DocComment ->
15011483 Report.Report "EXPECTING DOC COMMENT" region [] $
@@ -1535,9 +1517,6 @@ toFuncReport source name func frow fcol =
15351517 ]
15361518 )
15371519
1538− ReservedOperator op ->
1539− error "TODO ReservedOperator" op
1540−
15411520 Wildcard ->
15421521 Report.Report "EXPECTING A WILDCARD" region [] $
15431522 Report.toCodeSnippet source region Nothing
@@ -1630,158 +1609,6 @@ toFuncReport source name func frow fcol =
16301609 )
16311610
16321611
1633−-- PARSE ERROR TO DOCS
1634−
1635−
1636−problemToDocs :: Problem -> (D.Doc, D.Doc)
1637−problemToDocs problem =
1638− case problem of
1639− Tab ->
1640− (
1641− "I ran into a tab, but tabs are not allowed in Elm files."
1642− ,
1643− "Replace the tab with spaces."
1644− )
1645−
1646− EndOfFile_Comment ->
1647− (
1648− "I got to the end of the file while parsing a multi-line comment."
1649− ,
1650− [
1651− "Multi-line comments look like {- comment -}, and it looks like\
1652− \ you are missing the closing marker."
1653− ,
1654− D.toSimpleHint $
1655− "Nested multi-line comments like {- this {- and this -} -} are allowed.\
1656− \ The opening and closing markers must be balanced though, just\
1657− \ like parentheses in normal code. Maybe that is the problem?"
1658− ]
1659− )
1660−
1661− EndOfFile_String ->
1662− (
1663− "I got to the end of the file while parsing a string."
1664− ,
1665− "Strings look like \"this\" with double quotes on each end.\
1666− \ Is the closing double quote missing in your code?"
1667− )
1668−
1669− EndOfFile_MultiString ->
1670− (
1671− "I got to the end of the file while parsing a multi-line string."
1672− ,
1673− "Multi-line strings look like \"\"\"this\"\"\" with three double quotes\
1674− \ on each end. Is the closing triple quote missing in your code?"
1675− )
1676−
1677− EndOfFile_Char ->
1678− (
1679− "I got to the end of the file while parsing a character."
1680− ,
1681− "Characters look like 'c' with single quotes on each end.\
1682− \ Is the closing single quote missing in your code?"
1683− )
1684−
1685− NewLineInString ->
1686− (
1687− "This string is missing the closing quote."
1688− ,
1689− [
1690− "Elm strings like \"this\" cannot contain newlines."
1691− ,
1692− D.toSimpleHint $
1693− "For strings that CAN contain newlines, say \"\"\"this\"\"\" for Elm’s\
1694− \ multi-line string syntax. It allows unescaped newlines and double quotes."
1695− ]
1696− )
1697−
1698− NewLineInChar ->
1699− (
1700− "This character is missing the closing quote."
1701− ,
1702− "Elm characters must start and end with a single quote. Valid examples\n\
1703− \ include 'a', 'b', '\n', 'ø', and '\\u{00F8}' for unicode code points."
1704− )
1705−
1706− BadNumberDot numberBeforeDot ->
1707− (
1708− "Numbers cannot end with a decimal points."
1709− ,
1710− let
1711− number =
1712− D.fromString (show numberBeforeDot)
1713− in
1714− "Saying " <> D.green number <> " or " <> D.green (number <> ".0") <> " will work though!"
1715− )
1716−
1717− BadNumberEnd ->
1718− (
1719− "Numbers cannot have letters or underscores in them."
1720− ,
1721− "Maybe a space is missing between a number and a variable?"
1722− )
1723−
1724− BadNumberExp ->
1725− (
1726− "If you put the letter E in a number, it should followed by more digits."
1727− ,
1728− "If you want to say 1000, you can also say 1e3.\
1729− \ You cannot just end it with an E though!"
1730− )
1731−
1732− BadNumberHex ->
1733− (
1734− "I see the start of a hex number, but not the end."
1735− ,
1736− "A hex number looks like 0x123ABC, where the 0x is followed by hexidecimal\
1737− \ digits. Valid hexidecimal digits include: 0123456789abcdefABCDEF"
1738− )
1739−
1740− BadNumberZero ->
1741− (
1742− "Normal numbers cannot start with zeros. Take the zeros off the front."
1743− ,
1744− "Only numbers like 0x0040 or 0.25 can start with a zero."
1745− )
1746−
1747− BadUnderscore _ ->
1748− (
1749− "Variable names cannot start with an underscore like this:"
1750− ,
1751− "Delete the underscore and it shoulld be fine!"
1752− )
1753−
1754− Theories stack allTheories ->
1755− (
1756− D.reflow $
1757− "Something went wrong while parsing " <> contextToString "your code" "" stack <> "."
1758− ,
1759− case Set.toList (Set.fromList allTheories) of
1760− [] ->
1761− D.stack
1762− [ D.reflow $
1763− "I do not have any suggestions though!"
1764− , D.reflow $
1765− "Can you get it down to a <http://sscce.org> and share it at\
1766− \ <https://github.com/elm/error-message-catalog/issues>?\
1767− \ That way we can figure out how to give better advice!"
1768− ]
1769−
1770− [theory] ->
1771− D.reflow $
1772− "I was expecting to see "
1773− <> addPeriod (theoryToString stack theory)
1774−
1775− theories ->
1776− D.vcat $
1777− [ "I was expecting:"
1778− , ""
1779− ]
1780− ++ map (bullet . theoryToString stack) theories
1781− )
1782−
1783−
1784−
17851612-- CONTEXT
17861613
17871614
@@ -1834,160 +1661,4 @@ getAnchor stack =
18341661 _ ->
18351662 getAnchor rest
18361663
1837−
1838−
1839−-- THEORY HELPERS
1840−
1841−
1842−bullet :: String -> D.Doc
1843−bullet point =
1844− D.hang 4 (" - " <> D.fillSep (map D.fromString (words point)))
1845−
1846−
1847−addPeriod :: String -> String
1848−addPeriod msg =
1849− if last msg `elem` ['`', ')', '.', '!', '?'] then
1850− msg
1851− else
1852− msg <> "."
1853−
1854−
1855−theoryToString :: ContextStack -> Theory -> String
1856−theoryToString context theory =
1857− case theory of
1858− Keyword keyword ->
1859− "the `" <> keyword <> "` keyword"
1860−
1861− Symbol symbol ->
1862− case symbol of
1863− "=" -> equalsTheory context
1864− "->" -> "an arrow (->) followed by an expression"
1865− ":" -> "the \"has type\" symbol (:) followed by a type"
1866− "," -> "a comma"
1867− "|" -> barTheory context
1868− "::" -> "the cons operator (::) followed by more list elements"
1869− "." -> "a dot (.)"
1870− "-" -> "a minus sign (-)"
1871− "_" -> "an underscore"
1872− "(" -> "a left paren, for grouping or starting tuples"
1873− ")" -> "a closing paren"
1874− "[" -> "a left square bracket, for starting lists"
1875− "]" -> "a right square bracket, to end a list"
1876− "{" -> "a left curly brace, for starting records"
1877− "}" -> "a right curly brace, to end a record"
1878− "{-|" -> "a doc comment, like {-| this -}" --}
1879− _ -> "the (" <> symbol <> ") symbol"
1880−
1881− LowVar ->
1882− "a lower-case variable, like `x` or `user`"
1883−
1884− CapVar ->
1885− "an upper-case variable, like `Maybe` or `Just`"
1886−
1887− InfixOp ->
1888− "an infix operator, like (+) or (==)"
1889−
1890− Digit ->
1891− "a digit from 0 to 9"
1892−
1893− BadSpace ->
1894− badSpace context
1895−
1896− Expecting next ->
1897− case next of
1898− Decl -> "a declaration, like `x = 5` or `type alias Model = { ... }`"
1899− Expr -> "an expression, like x or 42"
1900− AfterOpExpr op -> "an expression after that (" <> Name.toChars op <> ") operator, like x or 42"
1901− ElseBranch -> "an `else` branch. An `if` must handle both possibilities."
1902− Arg -> "an argument, like `name` or `total`"
1903− Pattern -> "a pattern, like `name` or (Just x)"
1904− Type -> "a type, like Int or (List String)"
1905− Listing -> "a list of exposed values and types, like (..) or (x,y,z)"
1906− Exposing -> "something like `exposing (..)`"
1907−
1908−
1909−equalsTheory :: ContextStack -> String
1910−equalsTheory stack =
1911− case stack of
1912− [] ->
1913− "an equals sign (=)"
1914−
1915− (context, _) : rest ->
1916− case context of
1917− ExprRecord -> "an equals sign (=) followed by an expression"
1918− Definition name -> "an equals sign (=) followed by " <> Name.toChars name <> "'s definition"
1919− TypeUnion -> "an equals sign (=) followed by the first union type constructor"
1920− TypeAlias -> "an equals sign (=) followed by the aliased type"
1921− _ -> equalsTheory rest
1922−
1923−
1924−barTheory :: ContextStack -> String
1925−barTheory stack =
1926− case stack of
1927− [] ->
1928− "a vertical bar (|)"
1929−
1930− (context, _) : rest ->
1931− case context of
1932− ExprRecord -> "a vertical bar (|) followed by the record fields you want to update"
1933− TypeRecord -> "a vertical bar (|) followed by some record field types"
1934− TypeUnion -> "a vertical bar (|) followed by more union type constructors"
1935− _ -> barTheory rest
1936−
1937−
1938−badSpace :: ContextStack -> String
1939−badSpace stack =
1940− case stack of
1941− [] ->
1942− "more indentation? I was not done with that last thing yet."
1943−
1944− (context, _) : rest ->
1945− case context of
1946− ExprIf -> "the end of that `if`" <> badSpaceExprEnd rest
1947− ExprLet -> "the end of that `let`" <> badSpaceExprEnd rest
1948− ExprFunc -> badSpace rest
1949− ExprCase -> "more of that `case`" <> badSpaceExprEnd rest
1950− ExprList -> "the end of that list" <> badSpaceExprEnd rest
1951− ExprTuple -> "a closing paren" <> badSpaceExprEnd rest
1952− ExprRecord -> "the end of that record" <> badSpaceExprEnd rest
1953− Definition name -> "the rest of " <> Name.toChars name <> "'s definition" <> badSpaceExprEnd stack
1954− Annotation name -> "the rest of " <> Name.toChars name <> "'s type annotation" <> badSpaceEnd
1955− TypeTuple -> "a closing paren" <> badSpaceEnd
1956− TypeRecord -> "the end of that record" <> badSpaceEnd
1957− PatternList -> "the end of that list" <> badSpaceEnd
1958− PatternTuple -> "a closing paren" <> badSpaceEnd
1959− PatternRecord -> "the end of that record" <> badSpaceEnd
1960− Module -> "something like `module Main exposing (..)`"
1961− Import -> "something like `import Html exposing (..)`"
1962− TypeUnion -> "more of that union type" <> badSpaceEnd
1963− TypeAlias -> "more of that type alias" <> badSpaceEnd
1964− Infix -> "more of that infix declaration" <> badSpaceEnd
1965− Port -> "more of that port declaration" <> badSpaceEnd
1966−
1967−
1968−badSpaceEnd :: String
1969−badSpaceEnd =
1970− ". Maybe you forgot some code? Or you need more indentation?"
1971−
1972−
1973−badSpaceExprEnd :: ContextStack -> String
1974−badSpaceExprEnd stack =
1975− case stack of
1976− [] ->
1977− badSpaceEnd
1978−
1979− (Definition name, A.Position _ column) : _ ->
1980− let
1981− ending =
1982− if column <= 1 then
1983− "to be indented?"
1984− else
1985− "more indentation? (Try " <> show (column + 1) <> "+ spaces.)"
1986− in
1987− ". Maybe you forgot some code? Or maybe the body of `"
1988− <> Name.toChars name
1989− <> "` needs " <> ending
1990−
1991− _ : rest ->
1992− badSpaceExprEnd rest
19931664-}