GNU bug report logs - #21875
24.5; Invalid tokens in smie indentation rules

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Reported by: mail@HIDDEN; dated Wed, 11 Nov 2015 02:04:02 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at 21875 <at> debbugs.gnu.org:


Received: (at 21875) by debbugs.gnu.org; 13 Nov 2015 02:26:22 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Nov 12 21:26:22 2015
Received: from localhost ([127.0.0.1]:35310 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.80)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1Zx44D-00083N-Tz
	for submit <at> debbugs.gnu.org; Thu, 12 Nov 2015 21:26:22 -0500
Received: from ap4y.me ([45.79.156.233]:47360)
 by debbugs.gnu.org with esmtp (Exim 4.80)
 (envelope-from <mail@HIDDEN>) id 1Zx3fF-0007U7-Lp
 for 21875 <at> debbugs.gnu.org; Thu, 12 Nov 2015 21:00:52 -0500
Received: from [127.0.0.1] (localhost [127.0.0.1])
 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
 (No client certificate requested)
 by ap4y.me (Postfix) with ESMTPSA id CB9DD58E;
 Fri, 13 Nov 2015 02:00:22 +0000 (UTC)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ap4y.me; s=default;
 t=1447380024; bh=GhsspgwiGemIZh2l73ktFIhARgfUNfobTQuY8QswpAY=;
 h=References:From:To:Cc:Subject:In-reply-to:Date:From;
 b=RpGm4m7SwpRjLCkuvR0ai5YuTZ9EYlFRUP24EqIw/6FNvrEkeoy8m376P2Kfok1wK
 bu/ys6n/NKKDgARU1EGuVuliw9BRmEgFAnYkZBCJgsx9piFmUJus8rM+zmc9vLuiAt
 2qD7U3ve53C601g0K31LpHWv1tjFrLy1QV03+cC0=
References: <87si4dxsel.fsf@HIDDEN>
 <awoaf05pgd.fsf@HIDDEN>
 <jwvmvukntwg.fsf-monnier+emacsbugs@HIDDEN> <2mvukb3nd.fsf@HIDDEN>
From: Arthur Evstifeev <mail@HIDDEN>
To: Glenn Morris <rgm@HIDDEN>
Subject: Re: bug#21875: 24.5; Invalid tokens in smie indentation rules
In-reply-to: <2mvukb3nd.fsf@HIDDEN>
Date: Fri, 13 Nov 2015 15:00:26 +1300
Message-ID: <87r3juwtdx.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
X-Spam-Score: -0.4 (/)
X-Debbugs-Envelope-To: 21875
X-Mailman-Approved-At: Thu, 12 Nov 2015 21:26:20 -0500
Cc: 21875 <at> debbugs.gnu.org, Stefan Monnier <monnier@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.4 (/)

--=-=-=
Content-Type: text/plain


Sorry for the delay. I have attached full code of the swift-mode with
minimal smie implementation. I didn't clean other pieces of the mode
like syntax table and highlighting code, hope this won't be too
inconvenient to work with.


--=-=-=
Content-Type: application/emacs-lisp
Content-Disposition: attachment; filename=swift-mode.el
Content-Transfer-Encoding: quoted-printable

;;; swift-mode.el --- Major-mode for Apple's Swift programming language. -*=
- lexical-binding: t -*-

;; Copyright (C) 2014 Chris Barrett, Bozhidar Batsov, Arthur Evstifeev

;; Authors: Chris Barrett <chris.d.barrett@HIDDEN>
;;       Bozhidar Batsov <bozhidar@HIDDEN>
;;       Arthur Evstifeev <lod@HIDDEN>
;; Version: 0.4.0-cvs
;; Package-Requires: ((emacs "24.4"))
;; Keywords: languages swift

;; This file is not part of GNU Emacs.

;; This program is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.

;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with this program.  If not, see <http://www.gnu.org/licenses/>.

;;; Commentary:

;; Major-mode for Apple's Swift programming language.

;;; Code:

(require 'rx)
(require 'comint)
(require 'cl-lib)

(defgroup swift nil
  "Configuration for swift-mode."
  :group 'languages
  :prefix "swift-")

(defcustom swift-indent-offset 4
  "Defines the indentation offset for Swift code."
  :group 'swift
  :type 'integer)

(defcustom swift-indent-switch-case-offset 0
  "Defines the indentation offset for cases in a switch statement."
  :group 'swift
  :type 'integer)

(defcustom swift-indent-multiline-statement-offset 2
  "Defines the indentation offset for multiline statements."
  :group 'swift
  :type 'integer
  :package-version '(swift-mode "0.3.0"))

(defcustom swift-indent-hanging-comma-offset nil
  "Defines the indentation offset for hanging comma."
  :group 'swift
  :type '(choice (const :tag "Use default relative formatting" nil)
                 (integer :tag "Custom offset"))
  :package-version '(swift-mode "0.4.0"))

(defcustom swift-repl-executable
  "xcrun swift"
  "Path to the Swift CLI."
  :group 'swift)

;;; Indentation

(require 'smie)

(defconst swift-smie-grammar
  (smie-prec2->grammar
   (smie-merge-prec2s
    (smie-bnf->prec2
     '((id)
       (inst ("if" exp "begin" insts "end")
             (exp))
       (insts (insts ";" insts) (inst))
       (exp (exp "." id)
            (id ":" exp)
            (exp "=3D" exp))
       (exps (exps "," exps) (exp)))
     ;; Conflicts
     '((assoc ";"))
     '((assoc ","))
     '((right "=3D") (assoc ".") (assoc ":") (assoc ",")))

    (smie-precs->prec2
     '(
       (right "*=3D" "/=3D" "%=3D" "+=3D" "-=3D" "<<=3D" ">>=3D" "&=3D"
              "^=3D" "|=3D" "&&=3D" "||=3D" "=3D")                       ;;=
 Assignment (Right associative, precedence level 90)
       (right "?" ":")                                         ;; Ternary C=
onditional (Right associative, precedence level 100)
       (left "||")                                             ;; Disjuncti=
ve (Left associative, precedence level 110)
       (left "&&")                                             ;; Conjuncti=
ve (Left associative, precedence level 120)
       (right "??")                                            ;; Nil Coale=
scing (Right associativity, precedence level 120)
       (nonassoc "<" "<=3D" ">" ">=3D" "=3D=3D" "!=3D" "=3D=3D=3D" "!=3D=3D=
" "~=3D") ;; Comparative (No associativity, precedence level 130)
       (nonassoc "is" "as" "as!" "as?")                        ;; Cast (No =
associativity, precedence level 132)
       (nonassoc "..<" "...")                                  ;; Range (No=
 associativity, precedence level 135)
       (left "+" "-" "&+" "&-" "|" "^")                        ;; Additive =
(Left associative, precedence level 140)
       (left "*" "/" "%" "&*" "&/" "&%" "&")                   ;; Multiplic=
ative (Left associative, precedence level 150)
       (nonassoc "<<" ">>")                                    ;; Exponenti=
ative (No associativity, precedence level 160)
       ))
    )))

(defun verbose-swift-smie-rules (kind token)
  (let ((value (swift-smie-rules kind token)))
    (message "%s '%s'; sibling-p:%s parent:%s hanging:%s =3D=3D %s" kind to=
ken
             (ignore-errors (smie-rule-sibling-p))
             (ignore-errors smie--parent)
             (ignore-errors (smie-rule-hanging-p))
             value)
    value))

(defvar swift-smie--operators
  '("*=3D" "/=3D" "%=3D" "+=3D" "-=3D" "<<=3D" ">>=3D" "&=3D" "^=3D" "|=3D"=
 "&&=3D" "||=3D"
   "<" "<=3D" ">" ">=3D" "=3D=3D" "!=3D" "=3D=3D=3D" "!=3D=3D" "~=3D" "||" =
"&&"
   "is" "as" "as!" "as?" "..<" "..."
   "+" "-" "&+" "&-" "|" "^"
   "*" "/" "%" "&*" "&/" "&%" "&"
   "<<" ">>" "??"))

(defvar swift-smie--operators-regexp
  (regexp-opt swift-smie--operators))

(defun swift-smie--implicit-semi-p ()
  (save-excursion
    (skip-chars-backward " \t")
    (not (or (bolp)
             (memq (char-before) '(?\{ ?\[ ?, ?. ?: ?=3D ?\())
             ;; Checking for operators form for "?" and "!",
             ;; they can be a part of the type.
             ;; Special case: is? and as? are operators.
             (looking-back "[[:space:]][?!]" (- (point) 2) t)
             ;; ??, is? and as? are operators
             (looking-back "[?][?]\\|as[?]\\|is[?]" (- (point) 3) t)
             ;; "in" operator in closure
             (looking-back "\\bin" (- (point) 3) t)
             ;; Characters placed on the second line in multi-line expressi=
on
             (save-excursion
               (forward-comment (buffer-size))
               (looking-at "[.?:()]"))
             ;; Operators placed on the second line in multi-line expression
             ;; Should respect here possible comments strict before the lin=
ebreak
             (save-excursion
               (forward-comment (buffer-size))
               (looking-at swift-smie--operators-regexp))

             (and (looking-back swift-smie--operators-regexp (- (point) 3) =
t)
                  ;; Not a generic type
                  (not (looking-back "[[:upper:]]>" (- (point) 2) t)))
             ))))

(defun swift-smie--forward-token-debug ()
  (let ((op (point))
        (token (swift-smie--forward-token)))
    (message "forward: %s -> %s =3D %s" op (point) token)
    token
    ))

(defun swift-smie--backward-token-debug ()
  (let ((op (point))
        (token (swift-smie--backward-token)))
    (message "backward: %s -> %s =3D %s" op (point) token)
      token
    ))

(defvar swift-smie--case-exp-regexp
  "\\(case.*?[^{}:=3D]+\\|default[[:space:]]*\\):")

(defun swift-smie--case-signature-p ()
  (save-excursion
    (up-list 1) (backward-list 1)
    (not (looking-back "enum.*" (line-beginning-position -1)))))

(defun swift-smie--closure-signature-p ()
    (let ((tok (smie-default-forward-token)))
      (or (equal tok "in")
          (and (equal tok "->")
               (equal (smie-default-forward-token) "in")))))

(defun swift-smie--forward-token ()
  (skip-chars-forward " \t")
  (cond
   ((and (looking-at "\n\\|\/\/")
         (swift-smie--implicit-semi-p))
    (if (eolp) (forward-char 1) (forward-comment 1))
    (skip-chars-forward " \t")
    (if (looking-at swift-smie--case-exp-regexp)
        "case-;" ";"))
   (t
    (forward-comment (point-max))
    (cond
     ((looking-at "{") (forward-char 1) "begin")
     ((looking-at "}") (forward-char 1) "end")

     (t (smie-default-forward-token))
     ))))

(defun swift-smie--backward-token ()
  (let ((pos (point)))
    (forward-comment (- (point)))
    (cond
     ((and (> pos (line-end-position))
           (swift-smie--implicit-semi-p))
      (if (save-excursion
            (forward-comment 1)
            (looking-at swift-smie--case-exp-regexp))
          "case-;" ";"))

     ((eq (char-before) ?\{) (backward-char 1) "begin")
     ((eq (char-before) ?\}) (backward-char 1) "end")

     (t (smie-default-backward-token))
     )))

(defun swift-smie-rules (kind token)
  (pcase (cons kind token)
    (`(:elem . basic) swift-indent-offset)))

;;; Font lock

(defvar swift-mode--type-decl-keywords
  '("class" "enum" "protocol" "struct" "typealias"))

(defvar swift-mode--val-decl-keywords
  '("let" "var"))

(defvar swift-mode--context-variables-keywords
  '("self" "super"))

(defvar swift-mode--fn-decl-keywords
  '("deinit" "func" "init"))

(defvar swift-mode--misc-keywords
  '("import" "static" "subscript" "extension"))

(defvar swift-mode--statement-keywords
  '("break" "case" "continue" "default" "do" "else" "fallthrough"
    "if" "in" "for" "return" "switch" "where" "repeat" "while" "guard"))

(defvar swift-mode--contextual-keywords
  '("associativity" "didSet" "get" "infix" "inout" "left" "mutating" "none"
    "nonmutating" "operator" "override" "postfix" "precedence" "prefix" "ri=
ght"
    "set" "unowned" "unowned(safe)" "unowned(unsafe)" "weak" "willSet" "con=
venience"
    "required" "dynamic" "final" "lazy" "optional" "private" "public" "inte=
rnal"))

(defvar swift-mode--attribute-keywords
  '("class_protocol" "exported" "noreturn"
    "NSCopying" "NSManaged" "objc" "autoclosure"
    "available" "noescape" "nonobjc" "NSApplicationMain" "testable" "UIAppl=
icationMain" "warn_unused_result" "convention"
    "IBAction" "IBDesignable" "IBInspectable" "IBOutlet"))

(defvar swift-mode--keywords
  (append swift-mode--type-decl-keywords
          swift-mode--val-decl-keywords
          swift-mode--context-variables-keywords
          swift-mode--fn-decl-keywords
          swift-mode--misc-keywords
          swift-mode--statement-keywords
          swift-mode--contextual-keywords)
  "Keywords used in the Swift language.")

(defvar swift-mode--constants
  '("true" "false" "nil"))

(defvar swift-font-lock-keywords
  `(
    ;; Keywords
    ;;
    ;; Swift allows reserved words to be used as identifiers when enclosed
    ;; with backticks, in which case they should be highlighted as
    ;; identifiers, not keywords.
    (,(rx-to-string
       `(and (or bol (not (any "`"))) bow
             (group (or ,@swift-mode--keywords))
             eow)
       t)
     1 font-lock-keyword-face)

    ;; Attributes
    ;;
    ;; Highlight attributes with keyword face
    (,(rx-to-string
       `(and "@" bow (or ,@swift-mode--attribute-keywords) eow)
       t)
     0 font-lock-keyword-face)

    ;; Types
    ;;
    ;; Any token beginning with an uppercase character is highlighted as a
    ;; type.
    (,(rx bow upper (* word) eow)
     0 font-lock-type-face)

    ;; Function names
    ;;
    ;; Any token beginning after `func' is highlighted as a function name.
    (,(rx bow "func" eow (+ space) (group bow (+ word) eow))
     1 font-lock-function-name-face)

    ;; Value bindings
    ;;
    ;; Any token beginning after `let' or `var' is highlighted as an
    ;; identifier.
    (,(rx-to-string `(and bow
                           (or ,@swift-mode--val-decl-keywords)
                           eow
                           (+ space)
                           (? "(")
                           (group (+ (or (+ (? ?`) word (? ?`)) ?, space)))
                           (? ")"))
                     t)
       1 font-lock-variable-name-face)

    ;; Use high-visibility face for pattern match wildcards.
    (,(rx (not (any word digit)) (group "_") (or eol (not (any word digit))=
))
     1 font-lock-negation-char-face)

    ;; Constants
    ;;
    ;; Highlight nil and boolean literals.
    (,(rx-to-string `(and bow (or ,@swift-mode--constants) eow))
     0 font-lock-constant-face)

    ;; Attributes
    ;;
    ;; Use string face for attribute name.
    (,(rx (or bol space)(group "@" (+ word)) eow)
     1 font-lock-string-face)

    ;; Imported modules
    ;;
    ;; Highlight the names of imported modules. Use `font-lock-string-face'=
 for
    ;; consistency with C modes.
    (,(rx bow "import" eow (+ space) (group (+ word)))
     1 font-lock-string-face)

    ;; String interpolation
    ;;
    ;; Highlight interpolation expression as identifier.
    (swift-match-interpolation 0 font-lock-variable-name-face t)
    ))

(defun swift-syntax-propertize-function (start end)
  "Syntactic keywords for Swift mode."
  (let (case-fold-search)
    (goto-char start)
    (remove-text-properties start end '(swift-interpolation-match-data))
    (funcall
     (syntax-propertize-rules
      ((rx (group "\\(" (* (any alnum " ()+-._/*[]!?<>&~!:|^%")) ")"))
       (0 (ignore (swift-syntax-propertize-interpolation)))))
     start end)))

(defun swift-syntax-propertize-interpolation ()
  (let* ((beg (match-beginning 0))
         (context (save-excursion (save-match-data (syntax-ppss beg)))))
    (put-text-property beg (1+ beg) 'swift-interpolation-match-data
                       (cons (nth 3 context) (match-data)))))

(defun swift-match-interpolation (limit)
  (let ((pos (next-single-char-property-change (point) 'swift-interpolation=
-match-data
                                               nil limit)))
    (when (and pos (> pos (point)))
      (goto-char pos)
      (let ((value (get-text-property pos 'swift-interpolation-match-data)))
        (if (eq (car value) ?\")
            (progn
              (set-match-data (cdr value))
              t)
          (swift-match-interpolation limit))))))

;;; Imenu

(defun swift-mode--mk-regex-for-def (keyword)
  "Make a regex matching the identifier introduced by KEYWORD."
  (let ((ident (rx (any word nonascii "_") (* (any word nonascii digit "_")=
))))
    (rx-to-string `(and bow ,keyword eow (+ space) (group (regexp ,ident)))
                  t)))

(defvar swift-mode--imenu-generic-expression
  (list
   (list "Functions" (swift-mode--mk-regex-for-def "func") 1)
   (list "Classes"   (swift-mode--mk-regex-for-def "class") 1)
   (list "Enums"     (swift-mode--mk-regex-for-def "enum") 1)
   (list "Protocols" (swift-mode--mk-regex-for-def "protocol") 1)
   (list "Structs"   (swift-mode--mk-regex-for-def "struct") 1)
   (list "Constants" (swift-mode--mk-regex-for-def "let") 1)
   (list "Variables" (swift-mode--mk-regex-for-def "var") 1))
  "Value for `imenu-generic-expression' in swift-mode.")

;;; Flycheck

(with-eval-after-load 'flycheck
  (flycheck-def-option-var flycheck-swift-sdk-path nil swift
     "A path to the targeted SDK"
     :type '(choice (const :tag "Don't link against sdk" nil)
                    (string :tag "Targeted SDK path"))
     :safe #'stringp)

   (flycheck-def-option-var flycheck-swift-linked-sources nil swift
     "Source files path to link against. Can be glob, i.e. *.swift"
     :type '(choice (const :tag "Don't use linked sources" nil)
                    (string :tag "Linked Sources"))
     :safe #'stringp)

   (flycheck-def-option-var flycheck-swift-framework-search-paths nil swift
     "A list of framework search paths"
     :type '(repeat (directory :tag "Include directory"))
     :safe #'flycheck-string-list-p)

   (flycheck-def-option-var flycheck-swift-cc-include-search-paths nil swift
     "A list of include file search paths to pass to the Objective C compil=
er"
     :type '(repeat (directory :tag "Include directory"))
     :safe #'flycheck-string-list-p)

   (flycheck-def-option-var flycheck-swift-target "i386-apple-ios8.1" swift
     "Target used by swift compiler"
     :type '(choice (const :tag "Don't specify target" nil)
                    (string :tag "Build target"))
     :safe #'stringp)

   (flycheck-def-option-var flycheck-swift-import-objc-header nil swift
     "Objective C header file to import, if any"
     :type '(choice (const :tag "Don't specify objective C bridging header"=
 nil)
                    (string :tag "Objective C bridging header path"))
     :safe #'stringp)

   (flycheck-define-checker swift
     "Flycheck plugin for for Apple's Swift programming language."
     :command ("swift"
               "-frontend" "-parse"
               (option "-sdk" flycheck-swift-sdk-path)
               (option-list "-F" flycheck-swift-framework-search-paths)
               ;; Swift compiler will complain about redeclaration
               ;; if we will include original file along with
               ;; temporary source file created by flycheck.
               ;; We also don't want a hidden emacs interlock files.
               (eval
                (let (source file)
                  (when flycheck-swift-linked-sources
                    (setq source (car (flycheck-substitute-argument 'source=
 'swift)))
                    (setq file (file-name-nondirectory source))
                    (cl-remove-if-not
                     #'(lambda (path)
                         (and
                          (eq (string-match ".#" path) nil)
                          (eq (string-match file path) nil)))
                     (file-expand-wildcards flycheck-swift-linked-sources))=
)))
               (option "-target" flycheck-swift-target)
               (option "-import-objc-header" flycheck-swift-import-objc-hea=
der)
               (eval
                (cl-mapcan
                 #'(lambda (path) (list "-Xcc" (concat "-I" path)))
                 flycheck-swift-cc-include-search-paths))
               "-primary-file" source)
     :error-patterns
     ((error line-start (file-name) ":" line ":" column ": "
             "error: " (message) line-end)
      (warning line-start (file-name) ":" line ":" column ": "
               "warning: " (message) line-end))
     :modes swift-mode))

;;; REPL

(defvar swift-repl-buffer nil
  "Stores the name of the current swift REPL buffer, or nil.")

;;;###autoload
(defun swift-mode-run-repl (cmd &optional dont-switch-p)
  "Run a REPL process, input and output via buffer `*swift-repl*'.
If there is a process already running in `*swift-repl*', switch to that buf=
fer.
With argument CMD allows you to edit the command line (default is value
of `swift-repl-executable').
With DONT-SWITCH-P cursor will stay in current buffer.
Runs the hook `swift-repl-mode-hook' \(after the `comint-mode-hook'
is run).
\(Type \\[describe-mode] in the process buffer for a list of commands.)"

  (interactive (list (if current-prefix-arg
                         (read-string "Run swift REPL: " swift-repl-executa=
ble)
                       swift-repl-executable)))
  (unless (comint-check-proc "*swift-repl*")
    (save-excursion (let ((cmdlist (split-string cmd)))
                      (set-buffer (apply 'make-comint "swift-repl" (car cmd=
list)
                                         nil (cdr cmdlist)))
                      (swift-repl-mode))))
  (setq swift-repl-executable cmd)
  (setq swift-repl-buffer "*swift-repl*")
  (unless dont-switch-p
    (pop-to-buffer "*swift-repl*")))

(defun swift-mode-send-region (start end)
  "Send the current region to the inferior swift process.
START and END define region within current buffer"
  (interactive "r")
  (swift-mode-run-repl swift-repl-executable t)
  (comint-send-region swift-repl-buffer start end)
  (comint-send-string swift-repl-buffer "\n"))

(defun swift-mode-send-buffer ()
  "Send the buffer to the Swift REPL process."
  (interactive)
  (swift-mode-send-region (point-min) (point-max)))

(define-derived-mode swift-repl-mode comint-mode "Swift REPL"
  "Major mode for interacting with Swift REPL.

A REPL can be fired up with M-x swift-mode-run-repl.

Customization: Entry to this mode runs the hooks on comint-mode-hook and
swift-repl-mode-hook (in that order).

You can send text to the REPL process from other buffers containing source.
    swift-mode-send-region sends the current region to the REPL process,
    swift-mode-send-buffer sends the current buffer to the REPL process.
")

;;; Mode definition

(defvar swift-mode-syntax-table
  (let ((table (make-syntax-table)))

    ;; Operators
    (dolist (i '(?+ ?- ?* ?/ ?& ?| ?^ ?< ?> ?~))
      (modify-syntax-entry i "." table))

    ;; Strings
    (modify-syntax-entry ?\" "\"" table)
    (modify-syntax-entry ?\\ "\\" table)

    ;; Additional symbols
    (modify-syntax-entry ?_ "w" table)
    (modify-syntax-entry ?? "_" table)
    (modify-syntax-entry ?! "_" table)
    (modify-syntax-entry ?: "." table)

    ;; Comments
    (modify-syntax-entry ?/  ". 124b" table)
    (modify-syntax-entry ?*  ". 23n"  table)
    (modify-syntax-entry ?\n "> b"    table)

    ;; Parenthesis, braces and brackets
    (modify-syntax-entry ?\( "()" table)
    (modify-syntax-entry ?\) ")(" table)
    (modify-syntax-entry ?\[ "(]" table)
    (modify-syntax-entry ?\] ")[" table)
    (modify-syntax-entry ?\{ "(}" table)
    (modify-syntax-entry ?\} "){" table)

    table))

(defvar swift-mode-map
  (let ((map (make-sparse-keymap)))
    (define-key map (kbd "C-c C-z") 'swift-mode-run-repl)
    (define-key map (kbd "C-c C-f") 'swift-mode-send-buffer)
    (define-key map (kbd "C-c C-r") 'swift-mode-send-region)
    (easy-menu-define swift-menu map "Swift Mode menu"
      `("Swift"
        :help "Swift-specific Features"
        ["Run REPL" swift-mode-run-repl
         :help "Run Swift REPL"]
        ["Send buffer to REPL" swift-mode-send-buffer
         :help "Send the current buffer's contents to the REPL"]
        ["Send region to REPL" swift-mode-send-region
         :help "Send currently selected region to the REPL"]))
    map)
  "Key map for swift mode.")

;;;###autoload
(define-derived-mode swift-mode prog-mode "Swift"
  "Major mode for Apple's Swift programming language.

\\<swift-mode-map>"
  :group 'swift
  :syntax-table swift-mode-syntax-table
  (setq font-lock-defaults '((swift-font-lock-keywords) nil nil))
  (setq-local syntax-propertize-function #'swift-syntax-propertize-function)

  (setq-local imenu-generic-expression swift-mode--imenu-generic-expression)

  (setq-local comment-start "// ")
  (setq-local comment-end "")
  (setq-local indent-tabs-mode nil)
  (setq-local electric-indent-chars
              (append '(?. ?, ?: ?\) ?\] ?\}) electric-indent-chars))
  (smie-setup swift-smie-grammar 'verbose-swift-smie-rules ;; 'verbose-swif=
t-smie-rules
              :forward-token 'swift-smie--forward-token-debug
              :backward-token 'swift-smie--backward-token-debug))

;;;###autoload
(add-to-list 'auto-mode-alist '("\\.swift\\'" . swift-mode))

(provide 'swift-mode)

;;; swift-mode.el ends here

--=-=-=
Content-Type: text/plain


Glenn Morris writes:

> [resending including the OP in the list of recipients]
>
> Stefan Monnier wrote:
>
>>>> And lexer rule that overrides braces with begin/end tokens, for example
>>>> like this:
>>>>
>>>> ((looking-at "{") (forward-char 1) "begin")
>>>> ((looking-at "}") (forward-char 1) "end")
>>
>> This is not enough info: we need the complete code so we can run it on
>> our side and single-step through it to see what's going on.

--
Sent with my mu4e

--=-=-=--




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#21875; Package emacs. Full text available.

Message received at 21875 <at> debbugs.gnu.org:


Received: (at 21875) by debbugs.gnu.org; 11 Nov 2015 21:57:54 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Nov 11 16:57:54 2015
Received: from localhost ([127.0.0.1]:33667 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.80)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1ZwdOr-0003YM-Pu
	for submit <at> debbugs.gnu.org; Wed, 11 Nov 2015 16:57:54 -0500
Received: from eggs.gnu.org ([208.118.235.92]:41718)
 by debbugs.gnu.org with esmtp (Exim 4.80)
 (envelope-from <rgm@HIDDEN>) id 1ZwdOX-0003Xt-VD
 for 21875 <at> debbugs.gnu.org; Wed, 11 Nov 2015 16:57:52 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <rgm@HIDDEN>) id 1ZwdOV-0007hY-L0
 for 21875 <at> debbugs.gnu.org; Wed, 11 Nov 2015 16:57:33 -0500
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=-0.8 required=5.0 tests=BAYES_05,RP_MATCHES_RCVD
 autolearn=disabled version=3.3.2
Received: from fencepost.gnu.org ([2001:4830:134:3::e]:33789)
 by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from <rgm@HIDDEN>)
 id 1ZwdOR-0007ge-Tz; Wed, 11 Nov 2015 16:57:27 -0500
Received: from rgm by fencepost.gnu.org with local (Exim 4.82)
 (envelope-from <rgm@HIDDEN>)
 id 1ZwdOR-0004Go-4t; Wed, 11 Nov 2015 16:57:27 -0500
From: Glenn Morris <rgm@HIDDEN>
To: mail@HIDDEN
Subject: Re: bug#21875: 24.5; Invalid tokens in smie indentation rules
References: <87si4dxsel.fsf@HIDDEN>
 <awoaf05pgd.fsf@HIDDEN>
 <jwvmvukntwg.fsf-monnier+emacsbugs@HIDDEN>
X-Spook: Power lines WHO Spammer Beltran-Leyva Nationalist Cohiba
X-Ran: <{]CQt=,QMb`"[<>-$K'gp4de6(2cFqG_h6?yZ284E.beIs/o8fmwp6.)sp7;!"]1CG>u@
X-Hue: green
X-Debbugs-No-Ack: yes
X-Attribution: GM
Date: Wed, 11 Nov 2015 16:57:26 -0500
In-Reply-To: <jwvmvukntwg.fsf-monnier+emacsbugs@HIDDEN> (Stefan Monnier's
 message of "Wed, 11 Nov 2015 15:51:32 -0500")
Message-ID: <2mvukb3nd.fsf@HIDDEN>
User-Agent: Gnus (www.gnus.org), GNU Emacs (www.gnu.org/software/emacs/)
MIME-Version: 1.0
Content-Type: text/plain
X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address
 (bad octet value).
X-Received-From: 2001:4830:134:3::e
X-Spam-Score: -5.3 (-----)
X-Debbugs-Envelope-To: 21875
Cc: 21875 <at> debbugs.gnu.org, Stefan Monnier <monnier@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -5.3 (-----)


[resending including the OP in the list of recipients]

Stefan Monnier wrote:

>>> And lexer rule that overrides braces with begin/end tokens, for example
>>> like this:
>>>
>>> ((looking-at "{") (forward-char 1) "begin")
>>> ((looking-at "}") (forward-char 1) "end")
>
> This is not enough info: we need the complete code so we can run it on
> our side and single-step through it to see what's going on.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#21875; Package emacs. Full text available.

Message received at 21875 <at> debbugs.gnu.org:


Received: (at 21875) by debbugs.gnu.org; 11 Nov 2015 20:51:37 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Nov 11 15:51:37 2015
Received: from localhost ([127.0.0.1]:33616 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.80)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1ZwcMj-00020O-AQ
	for submit <at> debbugs.gnu.org; Wed, 11 Nov 2015 15:51:37 -0500
Received: from ironport2-out.teksavvy.com ([206.248.154.181]:1822)
 by debbugs.gnu.org with esmtp (Exim 4.80)
 (envelope-from <monnier@HIDDEN>) id 1ZwcMf-00020E-O6
 for 21875 <at> debbugs.gnu.org; Wed, 11 Nov 2015 15:51:34 -0500
X-IronPort-Anti-Spam-Filtered: true
X-IronPort-Anti-Spam-Result: A0A1FgA731xV/8uQWxdcgxCEAoVVwwsEAgKBPDwRAQEBAQEBAYEKQQWDXQEBAwFWMws0EhQYDYhbCM8jAQEIAiCLOoUMFoQXBYwwqFQjhBYggngBAQE
X-IPAS-Result: A0A1FgA731xV/8uQWxdcgxCEAoVVwwsEAgKBPDwRAQEBAQEBAYEKQQWDXQEBAwFWMws0EhQYDYhbCM8jAQEIAiCLOoUMFoQXBYwwqFQjhBYggngBAQE
X-IronPort-AV: E=Sophos;i="5.13,465,1427774400"; d="scan'208";a="177820227"
Received: from 23-91-144-203.cpe.pppoe.ca (HELO pastel.home) ([23.91.144.203])
 by ironport2-out.teksavvy.com with ESMTP; 11 Nov 2015 15:51:32 -0500
Received: by pastel.home (Postfix, from userid 20848)
 id 92126601DD; Wed, 11 Nov 2015 15:51:32 -0500 (EST)
From: Stefan Monnier <monnier@HIDDEN>
To: 21875 <at> debbugs.gnu.org
Subject: Re: bug#21875: 24.5; Invalid tokens in smie indentation rules
Message-ID: <jwvmvukntwg.fsf-monnier+emacsbugs@HIDDEN>
References: <87si4dxsel.fsf@HIDDEN>
 <awoaf05pgd.fsf@HIDDEN>
Date: Wed, 11 Nov 2015 15:51:32 -0500
In-Reply-To: <awoaf05pgd.fsf@HIDDEN> (Glenn Morris's message of
 "Wed, 11 Nov 2015 14:02:58 -0500")
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: 0.3 (/)
X-Debbugs-Envelope-To: 21875
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 0.3 (/)

>> And lexer rule that overrides braces with begin/end tokens, for example
>> like this:
>>
>> ((looking-at "{") (forward-char 1) "begin")
>> ((looking-at "}") (forward-char 1) "end")

This is not enough info: we need the complete code so we can run it on
our side and single-step through it to see what's going on.


        Stefan




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#21875; Package emacs. Full text available.

Message received at 21875 <at> debbugs.gnu.org:


Received: (at 21875) by debbugs.gnu.org; 11 Nov 2015 19:03:06 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Nov 11 14:03:06 2015
Received: from localhost ([127.0.0.1]:33559 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.80)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1Zwafh-0004iT-Ni
	for submit <at> debbugs.gnu.org; Wed, 11 Nov 2015 14:03:06 -0500
Received: from eggs.gnu.org ([208.118.235.92]:49803)
 by debbugs.gnu.org with esmtp (Exim 4.80)
 (envelope-from <rgm@HIDDEN>) id 1Zwaff-0004iI-FA
 for 21875 <at> debbugs.gnu.org; Wed, 11 Nov 2015 14:03:03 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <rgm@HIDDEN>) id 1Zwafe-0004EC-Be
 for 21875 <at> debbugs.gnu.org; Wed, 11 Nov 2015 14:03:03 -0500
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD
 autolearn=disabled version=3.3.2
Received: from fencepost.gnu.org ([2001:4830:134:3::e]:59093)
 by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from <rgm@HIDDEN>)
 id 1Zwafc-0004Dh-1V; Wed, 11 Nov 2015 14:03:00 -0500
Received: from rgm by fencepost.gnu.org with local (Exim 4.82)
 (envelope-from <rgm@HIDDEN>)
 id 1Zwafb-0004Bx-2d; Wed, 11 Nov 2015 14:02:59 -0500
From: Glenn Morris <rgm@HIDDEN>
To: Stefan Monnier <monnier@HIDDEN>
Subject: Re: bug#21875: 24.5; Invalid tokens in smie indentation rules
References: <87si4dxsel.fsf@HIDDEN>
X-Spook: Disaster management Bridge AVN INSCOM Border Patrol
X-Ran: )n,@dX7bFydav5<x5[Vc'Kc(3;h@P]kHLyKN26+!fi@M2`WWpWBizzIh|I{`]it*U?_ct3
X-Hue: blue
X-Attribution: GM
Date: Wed, 11 Nov 2015 14:02:58 -0500
In-Reply-To: <87si4dxsel.fsf@HIDDEN>
 (mail@HIDDEN's message of "Wed, 11 Nov 2015 13:59:30 +1300")
Message-ID: <awoaf05pgd.fsf@HIDDEN>
User-Agent: Gnus (www.gnus.org), GNU Emacs (www.gnu.org/software/emacs/)
MIME-Version: 1.0
Content-Type: text/plain
Content-Transfer-Encoding: quoted-printable
X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address
 (bad octet value).
X-Received-From: 2001:4830:134:3::e
X-Spam-Score: -5.3 (-----)
X-Debbugs-Envelope-To: 21875
Cc: 21875 <at> debbugs.gnu.org, mail@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -5.3 (-----)


Stefan, FYI:


mail@HIDDEN wrote:

> For the simple grammar like this:
>
> (id)
> (inst ("if" exp "begin" insts "end")
>       (exp))
> (insts (insts ";" insts) (inst))
> (exp (exp "." id)
>      (id ":" exp)
>      (exp "=3D" exp))
> (exps (exps "," exps) (exp))
>
> And lexer rule that overrides braces with begin/end tokens, for example
> like this:
>
> ((looking-at "{") (forward-char 1) "begin")
> ((looking-at "}") (forward-char 1) "end")
>
> When trying to indent such construction:
>
> if true {
>     bar
> |}
>
> I'm recieveing indentation request for :close-all '}', but no such
> token was returned by lexer, full log:
>
> forward: 19 -> 20 =3D end
> backward: 20 -> 19 =3D end
> backward: 19 -> 18 =3D ;
> backward: 18 -> 15 =3D bar
> backward: 15 -> 9 =3D begin
> backward: 9 -> 4 =3D true
> backward: 4 -> 1 =3D if
> :close-all '}'; sibling-p:t parent:(nil 1 if) hanging:nil =3D=3D nil
> backward: 20 -> 19 =3D end
> backward: 19 -> 18 =3D ;
> backward: 18 -> 15 =3D bar
> backward: 15 -> 9 =3D begin
> backward: 9 -> 4 =3D true
> backward: 4 -> 1 =3D if
>
>
>
> In GNU Emacs 24.5.1 (x86_64-unknown-linux-gnu, GTK+ Version 3.16.6)
>  of 2015-09-10 on foutrelis
> Windowing system distributor `The X.Org Foundation', version 11.0.11702000
> System Description:	Arch Linux
>
> Configured using:
>  `configure --prefix=3D/usr --sysconfdir=3D/etc --libexecdir=3D/usr/lib
>  --localstatedir=3D/var --with-x-toolkit=3Dgtk3 --with-xft
>  'CFLAGS=3D-march=3Dx86-64 -mtune=3Dgeneric -O2 -pipe -fstack-protector-s=
trong
>  --param=3Dssp-buffer-size=3D4' CPPFLAGS=3D-D_FORTIFY_SOURCE=3D2
>  LDFLAGS=3D-Wl,-O1,--sort-common,--as-needed,-z,relro'
>
> Important settings:
>   value of $EMACSLOADPATH: /home/ap4y/github/swift-mode/.cask/24.5.1/elpa=
/flycheck-cask-20150920.453:/home/ap4y/github/swift-mode/.cask/24.5.1/elpa/=
flycheck-20151027.755:/home/ap4y/github/swift-mode/.cask/24.5.1/elpa/dash-2=
0151021.113:/home/ap4y/github/swift-mode/.cask/24.5.1/elpa/pkg-info-2015051=
7.443:/home/ap4y/github/swift-mode/.cask/24.5.1/elpa/epl-20150517.433:/home=
/ap4y/github/swift-mode/.cask/24.5.1/elpa/let-alist-1.0.4:/home/ap4y/github=
/swift-mode/.cask/24.5.1/elpa/s-20150924.406:/usr/share/emacs/24.5/lisp:/us=
r/share/emacs/24.5/lisp/vc:/usr/share/emacs/24.5/lisp/url:/usr/share/emacs/=
24.5/lisp/textmodes:/usr/share/emacs/24.5/lisp/progmodes:/usr/share/emacs/2=
4.5/lisp/play:/usr/share/emacs/24.5/lisp/org:/usr/share/emacs/24.5/lisp/nxm=
l:/usr/share/emacs/24.5/lisp/net:/usr/share/emacs/24.5/lisp/mh-e:/usr/share=
/emacs/24.5/lisp/mail:/usr/share/emacs/24.5/lisp/leim:/usr/share/emacs/24.5=
/lisp/language:/usr/share/emacs/24.5/lisp/international:/usr/share/emacs/24=
.5/lisp/gnus:/usr/share/emacs/24.5/lisp/eshell:/usr/share/emacs/24.5/lisp/e=
rc:/usr/share/emacs/24.5/lisp/emulation:/usr/share/emacs/24.5/lisp/emacs-pa=
rallel:/usr/share/emacs/24.5/lisp/emacs-lisp:/usr/share/emacs/24.5/lisp/ced=
et:/usr/share/emacs/24.5/lisp/calendar:/usr/share/emacs/24.5/lisp/calc:/usr=
/share/emacs/24.5/lisp/obsolete
>   value of $LANG: en_US.UTF-8
>   locale-coding-system: utf-8-unix
>
> Major mode: Swift
>
> Minor modes in effect:
>   tooltip-mode: t
>   electric-indent-mode: t
>   mouse-wheel-mode: t
>   tool-bar-mode: t
>   menu-bar-mode: t
>   file-name-shadow-mode: t
>   global-font-lock-mode: t
>   font-lock-mode: t
>   blink-cursor-mode: t
>   auto-composition-mode: t
>   auto-encryption-mode: t
>   auto-compression-mode: t
>   line-number-mode: t
>   transient-mark-mode: t
>
> Recent messages:
> For information about GNU Emacs and the GNU system, type C-h C-a.
> File mode specification error: (wrong-type-argument stringp func-args)
>
> Load-path shadows:
> None found.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#21875; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 11 Nov 2015 02:03:05 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Nov 10 21:03:05 2015
Received: from localhost ([127.0.0.1]:60794 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.80)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1ZwKkI-0007Yb-HC
	for submit <at> debbugs.gnu.org; Tue, 10 Nov 2015 21:03:05 -0500
Received: from eggs.gnu.org ([208.118.235.92]:37633)
 by debbugs.gnu.org with esmtp (Exim 4.80)
 (envelope-from <mail@HIDDEN>) id 1ZwJlZ-00068J-PI
 for submit <at> debbugs.gnu.org; Tue, 10 Nov 2015 20:00:05 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <mail@HIDDEN>) id 1ZwJlX-0003pB-Vm
 for submit <at> debbugs.gnu.org; Tue, 10 Nov 2015 20:00:01 -0500
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,T_DKIM_INVALID
 autolearn=disabled version=3.3.2
Received: from lists.gnu.org ([2001:4830:134:3::11]:60762)
 by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from <mail@HIDDEN>)
 id 1ZwJlX-0003p7-Sv
 for submit <at> debbugs.gnu.org; Tue, 10 Nov 2015 19:59:59 -0500
Received: from eggs.gnu.org ([2001:4830:134:3::10]:47631)
 by lists.gnu.org with esmtp (Exim 4.71)
 (envelope-from <mail@HIDDEN>) id 1ZwJlW-0006s7-Rc
 for bug-gnu-emacs@HIDDEN; Tue, 10 Nov 2015 19:59:59 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <mail@HIDDEN>) id 1ZwJlS-0003oY-Oj
 for bug-gnu-emacs@HIDDEN; Tue, 10 Nov 2015 19:59:58 -0500
Received: from ap4y.me ([45.79.156.233]:59247)
 by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from <mail@HIDDEN>)
 id 1ZwJlS-0003oA-KL
 for bug-gnu-emacs@HIDDEN; Tue, 10 Nov 2015 19:59:54 -0500
Received: from [127.0.0.1] (localhost [127.0.0.1])
 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
 (No client certificate requested)
 by ap4y.me (Postfix) with ESMTPSA id 3C4FD58F
 for <bug-gnu-emacs@HIDDEN>; Wed, 11 Nov 2015 00:59:37 +0000 (UTC)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ap4y.me; s=default;
 t=1447203578; bh=FbPgjMDw7gzb4zbbjz1F6EM0IZHOu1tfjc2c/raLU8k=;
 h=From:To:Subject:Date:From;
 b=qvF9TXFpa2B7/iLiGVVziuia+Qv/wq4x6F4GCotNZg1VgbQrmyNkIywreqBWSyR+m
 vv0jVHLf2HpuY93aT+bD1uFqq29ZSv9jeUa0WVrn4UNe+lcmlhBKsccwnfiBVmqX9n
 FTiwK/oHKhd8BzG/AT3F4fCCV91B2vk0wtHBVeto=
From: mail@HIDDEN
To: bug-gnu-emacs@HIDDEN
Subject: 24.5; Invalid tokens in smie indentation rules
Date: Wed, 11 Nov 2015 13:59:30 +1300
Message-ID: <87si4dxsel.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
Content-Transfer-Encoding: quoted-printable
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address
 (bad octet value).
X-Received-From: 2001:4830:134:3::11
X-Spam-Score: -4.1 (----)
X-Debbugs-Envelope-To: submit
X-Mailman-Approved-At: Tue, 10 Nov 2015 21:02:44 -0500
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -4.1 (----)


For the simple grammar like this:

(id)
(inst ("if" exp "begin" insts "end")
      (exp))
(insts (insts ";" insts) (inst))
(exp (exp "." id)
     (id ":" exp)
     (exp "=3D" exp))
(exps (exps "," exps) (exp))

And lexer rule that overrides braces with begin/end tokens, for example
like this:

((looking-at "{") (forward-char 1) "begin")
((looking-at "}") (forward-char 1) "end")

When trying to indent such construction:

if true {
    bar
|}

I'm recieveing indentation request for :close-all '}', but no such
token was returned by lexer, full log:

forward: 19 -> 20 =3D end
backward: 20 -> 19 =3D end
backward: 19 -> 18 =3D ;
backward: 18 -> 15 =3D bar
backward: 15 -> 9 =3D begin
backward: 9 -> 4 =3D true
backward: 4 -> 1 =3D if
:close-all '}'; sibling-p:t parent:(nil 1 if) hanging:nil =3D=3D nil
backward: 20 -> 19 =3D end
backward: 19 -> 18 =3D ;
backward: 18 -> 15 =3D bar
backward: 15 -> 9 =3D begin
backward: 9 -> 4 =3D true
backward: 4 -> 1 =3D if



In GNU Emacs 24.5.1 (x86_64-unknown-linux-gnu, GTK+ Version 3.16.6)
 of 2015-09-10 on foutrelis
Windowing system distributor `The X.Org Foundation', version 11.0.11702000
System Description:	Arch Linux

Configured using:
 `configure --prefix=3D/usr --sysconfdir=3D/etc --libexecdir=3D/usr/lib
 --localstatedir=3D/var --with-x-toolkit=3Dgtk3 --with-xft
 'CFLAGS=3D-march=3Dx86-64 -mtune=3Dgeneric -O2 -pipe -fstack-protector-str=
ong
 --param=3Dssp-buffer-size=3D4' CPPFLAGS=3D-D_FORTIFY_SOURCE=3D2
 LDFLAGS=3D-Wl,-O1,--sort-common,--as-needed,-z,relro'

Important settings:
  value of $EMACSLOADPATH: /home/ap4y/github/swift-mode/.cask/24.5.1/elpa/f=
lycheck-cask-20150920.453:/home/ap4y/github/swift-mode/.cask/24.5.1/elpa/fl=
ycheck-20151027.755:/home/ap4y/github/swift-mode/.cask/24.5.1/elpa/dash-201=
51021.113:/home/ap4y/github/swift-mode/.cask/24.5.1/elpa/pkg-info-20150517.=
443:/home/ap4y/github/swift-mode/.cask/24.5.1/elpa/epl-20150517.433:/home/a=
p4y/github/swift-mode/.cask/24.5.1/elpa/let-alist-1.0.4:/home/ap4y/github/s=
wift-mode/.cask/24.5.1/elpa/s-20150924.406:/usr/share/emacs/24.5/lisp:/usr/=
share/emacs/24.5/lisp/vc:/usr/share/emacs/24.5/lisp/url:/usr/share/emacs/24=
.5/lisp/textmodes:/usr/share/emacs/24.5/lisp/progmodes:/usr/share/emacs/24.=
5/lisp/play:/usr/share/emacs/24.5/lisp/org:/usr/share/emacs/24.5/lisp/nxml:=
/usr/share/emacs/24.5/lisp/net:/usr/share/emacs/24.5/lisp/mh-e:/usr/share/e=
macs/24.5/lisp/mail:/usr/share/emacs/24.5/lisp/leim:/usr/share/emacs/24.5/l=
isp/language:/usr/share/emacs/24.5/lisp/international:/usr/share/emacs/24.5=
/lisp/gnus:/usr/share/emacs/24.5/lisp/eshell:/usr/share/emacs/24.5/lisp/erc=
:/usr/share/emacs/24.5/lisp/emulation:/usr/share/emacs/24.5/lisp/emacs-para=
llel:/usr/share/emacs/24.5/lisp/emacs-lisp:/usr/share/emacs/24.5/lisp/cedet=
:/usr/share/emacs/24.5/lisp/calendar:/usr/share/emacs/24.5/lisp/calc:/usr/s=
hare/emacs/24.5/lisp/obsolete
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Swift

Minor modes in effect:
  tooltip-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent messages:
For information about GNU Emacs and the GNU system, type C-h C-a.
File mode specification error: (wrong-type-argument stringp func-args)

Load-path shadows:
None found.

Features:
(shadow sort gnus-util mail-extr emacsbug message format-spec rfc822 mml
mml-sec mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev
gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums mm-util
help-fns mail-prsvr mail-utils vc-git swift-mode edmacro kmacro easymenu
derived pcase smie cl-loaddefs cl-lib comint ansi-color ring rx
time-date tooltip electric uniquify ediff-hook vc-hooks lisp-float-type
mwheel x-win x-dnd tool-bar dnd fontset image regexp-opt fringe
tabulated-list newcomment lisp-mode prog-mode register page menu-bar
rfn-eshadow timer select scroll-bar mouse jit-lock font-lock syntax
facemenu font-core frame cham georgian utf-8-lang misc-lang vietnamese
tibetan thai tai-viet lao korean japanese hebrew greek romanian slovak
czech european ethiopic indian cyrillic chinese case-table epa-hook
jka-cmpr-hook help simple abbrev minibuffer nadvice loaddefs button
faces cus-face macroexp files text-properties overlay sha1 md5 base64
format env code-pages mule custom widget hashtable-print-readable
backquote make-network-process dbusbind gfilenotify dynamic-setting
system-font-setting font-render-setting move-toolbar gtk x-toolkit x
multi-tty emacs)

Memory information:
((conses 16 81358 6097)
 (symbols 48 18856 0)
 (miscs 40 38 135)
 (strings 32 13410 4787)
 (string-bytes 1 381215)
 (vectors 16 10445)
 (vector-slots 8 396568 6410)
 (floats 8 66 65)
 (intervals 56 205 0)
 (buffers 960 12)
 (heap 1024 36497 1152))




Acknowledgement sent to mail@HIDDEN:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#21875; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Mon, 25 Nov 2019 12:00:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.