summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2018-11-05 20:06:16 +0100
committerAndreas Rumpf <rumpf_a@web.de>2018-11-06 13:55:03 +0100
commit1fa22d4cfed734736e79572105a7730f1e0dbd5f (patch)
tree01919ee03702c5cda52784e72127d8dadf1f12fc
parent25cb2e0c70963667838954cb7cb4785081e55da2 (diff)
downloadNim-1fa22d4cfed734736e79572105a7730f1e0dbd5f.tar.gz
removed the undocumented #? strongSpaces parsing mode
-rw-r--r--changelog.md1
-rw-r--r--compiler/parser.nim18
-rw-r--r--compiler/syntaxes.nim12
-rw-r--r--tests/parser/tstrongspaces.nim83
4 files changed, 13 insertions, 101 deletions
diff --git a/changelog.md b/changelog.md
index 68fb2b2ca..9c799a540 100644
--- a/changelog.md
+++ b/changelog.md
@@ -19,6 +19,7 @@
   your previous annotations with `parallel for`.
 
 - The `unchecked` pragma was removed, instead use `system.UncheckedArray`.
+- The undocumented ``#? strongSpaces`` parsing mode has been removed.
 
 
 #### Breaking changes in the standard library
diff --git a/compiler/parser.nim b/compiler/parser.nim
index 02083ca83..1743372c2 100644
--- a/compiler/parser.nim
+++ b/compiler/parser.nim
@@ -37,8 +37,7 @@ type
   TParser* = object            # A TParser object represents a file that
                                # is being parsed
     currInd: int               # current indentation level
-    firstTok, strongSpaces: bool # Has the first token been read?
-                                 # Is strongSpaces on?
+    firstTok: bool             # Has the first token been read?
     hasProgress: bool          # some while loop requires progress ensurance
     lex*: TLexer               # The lexer that is used for parsing
     tok*: TToken               # The current token
@@ -102,8 +101,7 @@ proc getTok(p: var TParser) =
       emitTok(p.em, p.lex, p.tok)
 
 proc openParser*(p: var TParser, fileIdx: FileIndex, inputStream: PLLStream,
-                 cache: IdentCache; config: ConfigRef;
-                 strongSpaces=false) =
+                 cache: IdentCache; config: ConfigRef) =
   ## Open a parser, using the given arguments to set up its internal state.
   ##
   initToken(p.tok)
@@ -112,13 +110,11 @@ proc openParser*(p: var TParser, fileIdx: FileIndex, inputStream: PLLStream,
     openEmitter(p.em, cache, config, fileIdx)
   getTok(p)                   # read the first token
   p.firstTok = true
-  p.strongSpaces = strongSpaces
   p.emptyNode = newNode(nkEmpty)
 
 proc openParser*(p: var TParser, filename: AbsoluteFile, inputStream: PLLStream,
-                 cache: IdentCache; config: ConfigRef;
-                 strongSpaces=false) =
-  openParser(p, fileInfoIdx(config, filename), inputStream, cache, config, strongSpaces)
+                 cache: IdentCache; config: ConfigRef) =
+  openParser(p, fileInfoIdx(config, filename), inputStream, cache, config)
 
 proc closeParser(p: var TParser) =
   ## Close a parser, freeing up its resources.
@@ -798,7 +794,7 @@ proc parseOperators(p: var TParser, headNode: PNode,
                     limit: int, mode: TPrimaryMode): PNode =
   result = headNode
   # expand while operators have priorities higher than 'limit'
-  var opPrec = getPrecedence(p.tok, p.strongSpaces)
+  var opPrec = getPrecedence(p.tok, false)
   let modeB = if mode == pmTypeDef: pmTypeDesc else: mode
   # the operator itself must not start on a new line:
   # progress guaranteed
@@ -815,7 +811,7 @@ proc parseOperators(p: var TParser, headNode: PNode,
     addSon(a, result)
     addSon(a, b)
     result = a
-    opPrec = getPrecedence(p.tok, p.strongSpaces)
+    opPrec = getPrecedence(p.tok, false)
 
 proc simpleExprAux(p: var TParser, limit: int, mode: TPrimaryMode): PNode =
   result = primary(p, mode)
@@ -2239,7 +2235,7 @@ proc parseString*(s: string; cache: IdentCache; config: ConfigRef;
   # XXX for now the builtin 'parseStmt/Expr' functions do not know about strong
   # spaces...
   parser.lex.errorHandler = errorHandler
-  openParser(parser, AbsoluteFile filename, stream, cache, config, false)
+  openParser(parser, AbsoluteFile filename, stream, cache, config)
 
   result = parser.parseAll
   closeParser(parser)
diff --git a/compiler/syntaxes.nim b/compiler/syntaxes.nim
index decdf1715..7a89452c6 100644
--- a/compiler/syntaxes.nim
+++ b/compiler/syntaxes.nim
@@ -17,10 +17,10 @@ type
   TFilterKind* = enum
     filtNone, filtTemplate, filtReplace, filtStrip
   TParserKind* = enum
-    skinStandard, skinStrongSpaces, skinEndX
+    skinStandard, skinEndX
 
 const
-  parserNames*: array[TParserKind, string] = ["standard", "strongspaces",
+  parserNames*: array[TParserKind, string] = ["standard",
                                               "endx"]
   filterNames*: array[TFilterKind, string] = ["none", "stdtmpl", "replace",
                                               "strip"]
@@ -34,14 +34,14 @@ template config(p: TParsers): ConfigRef = p.parser.lex.config
 
 proc parseAll*(p: var TParsers): PNode =
   case p.skin
-  of skinStandard, skinStrongSpaces:
+  of skinStandard:
     result = parser.parseAll(p.parser)
   of skinEndX:
     internalError(p.config, "parser to implement")
 
 proc parseTopLevelStmt*(p: var TParsers): PNode =
   case p.skin
-  of skinStandard, skinStrongSpaces:
+  of skinStandard:
     result = parser.parseTopLevelStmt(p.parser)
   of skinEndX:
     internalError(p.config, "parser to implement")
@@ -153,9 +153,7 @@ proc openParsers*(p: var TParsers, fileIdx: FileIndex, inputstream: PLLStream;
   else: s = inputstream
   case p.skin
   of skinStandard, skinEndX:
-    parser.openParser(p.parser, fileIdx, s, cache, config, false)
-  of skinStrongSpaces:
-    parser.openParser(p.parser, fileIdx, s, cache, config, true)
+    parser.openParser(p.parser, fileIdx, s, cache, config)
 
 proc closeParsers*(p: var TParsers) =
   parser.closeParser(p.parser)
diff --git a/tests/parser/tstrongspaces.nim b/tests/parser/tstrongspaces.nim
deleted file mode 100644
index adab7f709..000000000
--- a/tests/parser/tstrongspaces.nim
+++ /dev/null
@@ -1,83 +0,0 @@
-#? strongSpaces
-
-discard """
-  output: '''35
-true
-true
-4
-true
-1
-false
-77
-(Field0: 1, Field1: 2, Field2: 2)
-ha
-true
-tester args
-all
-all args
-19
--3
-false
--2
-'''
-"""
-
-echo 2+5 * 5
-
-# Keyword operators
-echo 1 + 16 shl 1 == 1 + (16 shl 1)
-echo 2 and 1  in  {0, 30}
-echo 2+2 * 2 shr 1
-echo false  or  2 and 1  in  {0, 30}
-
-proc `^`(a, b: int): int = a + b div 2
-echo 19 mod 16 ^ 4  +  2 and 1
-echo 18 mod 16 ^ 4 > 0
-
-# echo $foo gotcha
-let foo = 77
-echo $foo
-
-echo (1, 2, 2)
-
-template `&`(a, b: int): int = a and b
-template `|`(a, b: int): int = a - b
-template `++`(a, b: int): bool = a + b == 8009
-
-when true:
-  let b = 66
-  let c = 90
-  let bar = 8000
-  if foo+4 * 4 == 8  and  b&c | 9  ++
-      bar:
-    echo "ho"
-  else:
-    echo "ha"
-
-  let booA = foo+4 * 4  -  b&c | 9  +
-      bar
-  # is parsed as
-  let booB = ((foo+4)*4) - ((b&c) | 9) + bar
-
-  echo booA == booB
-
-
-template `|`(a, b): untyped = (if a.len > 0: a else: b)
-
-const
-  tester = "tester"
-  args = "args"
-
-echo tester & " " & args|"all"
-echo "all"  |  tester & " " & args
-echo "all"|tester & " " & args
-
-# Test arrow like operators. See also tests/macros/tclosuremacro.nim
-proc `+->`(a, b: int): int = a + b*4
-template `===>`(a, b: int): int = a - b shr 1
-
-echo 3 +-> 2 + 2 and 4
-var arrowed = 3+->2 + 2 and 4  # arrowed = 4
-echo arrowed ===> 15
-echo (2 * 3+->2) == (2*3 +-> 2)
-echo arrowed ===> 2 + 3+->2