Now on revision 106519. ------------------------------------------------------------ revno: 106519 committer: Paul Eggert branch nick: trunk timestamp: Fri 2011-11-25 23:42:44 -0800 message: Rename locals to avoid shadowing. * fileio.c (Finsert_file_contents): Rename inner 'gcpro1' to 'inner_gcpro1' to avoid shadowing. * process.c (wait_reading_process_output): Rename inner 'proc' to 'p' to avoid shadowing. Indent for consistency with usual Emacs style. diff: === modified file 'src/ChangeLog' --- src/ChangeLog 2011-11-25 19:52:46 +0000 +++ src/ChangeLog 2011-11-26 07:42:44 +0000 @@ -1,3 +1,12 @@ +2011-11-26 Paul Eggert + + Rename locals to avoid shadowing. + * fileio.c (Finsert_file_contents): + Rename inner 'gcpro1' to 'inner_gcpro1' to avoid shadowing. + * process.c (wait_reading_process_output): + Rename inner 'proc' to 'p' to avoid shadowing. + Indent for consistency with usual Emacs style. + 2011-11-25 Eli Zaretskii * xdisp.c (redisplay_window): If cursor row is not fully visible === modified file 'src/fileio.c' --- src/fileio.c 2011-11-23 07:03:56 +0000 +++ src/fileio.c 2011-11-26 07:42:44 +0000 @@ -3686,7 +3686,7 @@ int this_count = SPECPDL_INDEX (); int multibyte = ! NILP (BVAR (current_buffer, enable_multibyte_characters)); Lisp_Object conversion_buffer; - struct gcpro gcpro1; + struct gcpro inner_gcpro1; conversion_buffer = code_conversion_save (1, multibyte); @@ -3702,7 +3702,7 @@ inserted = 0; /* Bytes put into CONVERSION_BUFFER so far. */ unprocessed = 0; /* Bytes not processed in previous loop. */ - GCPRO1 (conversion_buffer); + GCPRO1_VAR (conversion_buffer, inner_gcpro); while (how_much < total) { /* We read one bunch by one (READ_BUF_SIZE bytes) to allow === modified file 'src/process.c' --- src/process.c 2011-11-25 07:14:48 +0000 +++ src/process.c 2011-11-26 07:42:44 +0000 @@ -4630,26 +4630,29 @@ the gnutls library -- 2.12.14 has been confirmed to need it. See http://comments.gmane.org/gmane.emacs.devel/145074 */ - struct Lisp_Process *proc; for (channel = 0; channel < MAXDESC; ++channel) - { - if (! NILP (chan_process[channel]) && - (proc = XPROCESS (chan_process[channel])) != NULL && - proc->gnutls_p && - proc->infd && - emacs_gnutls_record_check_pending (proc->gnutls_state) > 0) - { - nfds++; - FD_SET (proc->infd, &Available); - } - } + if (! NILP (chan_process[channel])) + { + struct Lisp_Process *p = + XPROCESS (chan_process[channel]); + if (p && p->gnutls_p && p->infd + && ((emacs_gnutls_record_check_pending + (p->gnutls_state)) + > 0)) + { + nfds++; + FD_SET (p->infd, &Available); + } + } } else { /* Check this specific channel. */ - if (wait_proc->gnutls_p && /* Check for valid process. */ + if (wait_proc->gnutls_p /* Check for valid process. */ /* Do we have pending data? */ - emacs_gnutls_record_check_pending (wait_proc->gnutls_state) > 0) + && ((emacs_gnutls_record_check_pending + (wait_proc->gnutls_state)) + > 0)) { nfds = 1; /* Set to Available. */ ------------------------------------------------------------ revno: 106518 committer: Chong Yidong branch nick: trunk timestamp: Sat 2011-11-26 14:28:10 +0800 message: Add grammar files for grammar-wy.el and wrt-wy.el. Regenerate the relevant CEDET parsers. * admin/grammars/bovine-grammar.el: * admin/grammars/wisent-grammar.el: Add scripts for generating the parsers. diff: === modified file 'admin/grammars/README' --- admin/grammars/README 2011-08-04 00:58:07 +0000 +++ admin/grammars/README 2011-11-26 06:28:10 +0000 @@ -3,17 +3,8 @@ lisp/semantic/wisent/ directories. You can run the parser generators with -emacs -batch --no-site-file -l bovine-grammar.el -f semantic-mode \ - -f semantic-grammar-batch-build-packages *.by - -emacs -batch --no-site-file -l wisent-grammar.el -f semantic-mode \ - -f semantic-grammar-batch-build-packages *.wy - -The output files were subsequently edited by hand to fix copyright -headers, variable names (to follow library name conventions), and -feature names. These changes do not alter the code logic, and can be -viewed by diffing to the files in lisp/semantic/bovine/ and -lisp/semantic/wisent/. +emacs -batch -Q -l bovine-grammar.el -f bovine-make-parsers +emacs -batch -Q -l wisent-grammar.el -f wisent-make-parsers Currently, the parser files in lisp/ are not generated directly from these grammar files when making Emacs. This state of affairs, and the === modified file 'admin/grammars/bovine-grammar.el' --- admin/grammars/bovine-grammar.el 2011-10-31 01:00:32 +0000 +++ admin/grammars/bovine-grammar.el 2011-11-26 06:28:10 +0000 @@ -454,4 +454,66 @@ (provide 'semantic/bovine/grammar) +(defun bovine-make-parsers () + "Generate Emacs' built-in Bovine-based parser files." + (semantic-mode 1) + ;; Loop through each .by file in current directory, and run + ;; `semantic-grammar-batch-build-one-package' to build the grammar. + (dolist (f (directory-files default-directory nil ".by$")) + (let ((packagename + (condition-case err + (with-current-buffer (find-file-noselect f) + (semantic-grammar-create-package)) + (error (message "%s" (error-message-string err)) nil))) + lang) + (when (and packagename + (string-match "^semantic-\\(.*\\)-by.el$" packagename)) + (setq lang (match-string 1 packagename)) + (with-temp-buffer + (insert-file-contents packagename) + (setq buffer-file-name (expand-file-name packagename)) + ;; Fix copyright header: + (goto-char (point-min)) + (re-search-forward "^;; Author:") + (setq copyright-end (match-beginning 0)) + (re-search-forward "^;;; Code:\n") + (delete-region copyright-end (match-end 0)) + (goto-char copyright-end) + (insert ";; This file is part of GNU Emacs. + +;; GNU Emacs 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. + +;; GNU Emacs 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 GNU Emacs. If not, see . + +;;; Commentary: +;; +;; This file was generated from admin/grammars/" + lang ".by. + +;;; Code: + +\(require 'semantic/lex) +\(eval-when-compile (require 'semantic/bovine))\n") + (goto-char (point-min)) + (delete-region (point-min) (line-end-position)) + (insert ";;; semantic/bovine/" lang + "-by.el --- Generated parser support file") + (delete-trailing-whitespace) + ;; Fix footer: + (goto-char (point-max)) + (re-search-backward ".\n;;; Analyzers") + (delete-region (point) (point-max)) + (insert "(provide 'semantic/bovine/" lang "-by)\n\n") + (insert ";;; semantic/bovine/" lang "-by.el ends here\n") + (save-buffer)))))) + ;;; bovine-grammar.el ends here === added file 'admin/grammars/grammar.wy' --- admin/grammars/grammar.wy 1970-01-01 00:00:00 +0000 +++ admin/grammars/grammar.wy 2011-11-26 06:28:10 +0000 @@ -0,0 +1,434 @@ +;;; semantic-grammar.wy -- LALR grammar of Semantic input grammars +;; +;; Copyright (C) 2002-2011 Free Software Foundation, Inc. +;; +;; Author: David Ponce +;; Maintainer: David Ponce +;; Created: 26 Aug 2002 +;; Keywords: syntax +;; X-RCS: $Id: semantic-grammar.wy,v 1.16 2005/09/30 20:20:27 zappo Exp $ + +;; This file is part of GNU Emacs. + +;; GNU Emacs 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. + +;; GNU Emacs 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 GNU Emacs. If not, see . + +%{ +(defvar semantic-grammar-lex-c-char-re) + +;; Current parsed nonterminal name. +(defvar semantic-grammar-wy--nterm nil) +;; Index of rule in a nonterminal clause. +(defvar semantic-grammar-wy--rindx nil) +} + +%package semantic-grammar-wy + +%languagemode wy-mode + +;; Main +%start grammar +;; Reparse +%start prologue epilogue declaration nonterminal rule +;; EXPANDFULL +%start put_names put_values use_names + +;; Keywords +%type +%keyword DEFAULT-PREC "%default-prec" +%keyword NO-DEFAULT-PREC "%no-default-prec" +%keyword KEYWORD "%keyword" +%keyword LANGUAGEMODE "%languagemode" +%keyword LEFT "%left" +%keyword NONASSOC "%nonassoc" +%keyword PACKAGE "%package" +%keyword PREC "%prec" +%keyword PUT "%put" +%keyword QUOTEMODE "%quotemode" +%keyword RIGHT "%right" +%keyword SCOPESTART "%scopestart" +%keyword START "%start" +%keyword TOKEN "%token" +%keyword TYPE "%type" +%keyword USE-MACROS "%use-macros" + +;; Literals +%type +%token STRING + +%type syntax ":?\\(\\sw\\|\\s_\\)+" +%token SYMBOL +%token PERCENT_PERCENT "\\`%%\\'" + +%type syntax semantic-grammar-lex-c-char-re +%token CHARACTER + +%type matchdatatype sexp syntax "\\s'\\s-*(" +%token PREFIXED_LIST + +%type matchdatatype sexp syntax "\\=" +%token SEXP + +;; Don't generate these analyzers which needs special handling code. +%token PROLOGUE "%{...%}" +%token EPILOGUE "%%...EOF" + +;; Blocks & Parenthesis +%type +%token PAREN_BLOCK "(LPAREN RPAREN)" +%token BRACE_BLOCK "(LBRACE RBRACE)" +%token LPAREN "(" +%token RPAREN ")" +%token LBRACE "{" +%token RBRACE "}" + +;; Punctuations +%type +%token COLON ":" +%token SEMI ";" +%token OR "|" +%token LT "<" +%token GT ">" + +%% + +grammar: + prologue + | epilogue + | declaration + | nonterminal + | PERCENT_PERCENT + ; + +;;; Prologue/Epilogue +;; +prologue: + PROLOGUE + (CODE-TAG "prologue" nil) + ; + +epilogue: + EPILOGUE + (CODE-TAG "epilogue" nil) + ; + +;;; Declarations +;; +declaration: + decl + (eval $1) + ; + +decl: + default_prec_decl + | no_default_prec_decl + | languagemode_decl + | package_decl + | precedence_decl + | put_decl + | quotemode_decl + | scopestart_decl + | start_decl + | keyword_decl + | token_decl + | type_decl + | use_macros_decl + ; + +default_prec_decl: + DEFAULT-PREC + `(TAG "default-prec" 'assoc :value '("t")) + ; + +no_default_prec_decl: + NO-DEFAULT-PREC + `(TAG "default-prec" 'assoc :value '("nil")) + ; + +languagemode_decl: + LANGUAGEMODE symbols + `(TAG ',(car $2) 'languagemode :rest ',(cdr $2)) + ; + +package_decl: + PACKAGE SYMBOL + `(PACKAGE-TAG ',$2 nil) + ; + +precedence_decl: + associativity token_type_opt items + `(TAG ',$1 'assoc :type ',$2 :value ',$3) + ; + +associativity: + LEFT + (progn "left") + | RIGHT + (progn "right") + | NONASSOC + (progn "nonassoc") + ; + +put_decl: + PUT put_name put_value + `(TAG ',$2 'put :value ',(list $3)) + | PUT put_name put_value_list + `(TAG ',$2 'put :value ',$3) + | PUT put_name_list put_value + `(TAG ',(car $2) 'put :rest ',(cdr $2) :value ',(list $3)) + | PUT put_name_list put_value_list + `(TAG ',(car $2) 'put :rest ',(cdr $2) :value ',$3) + ; + +put_name_list: + BRACE_BLOCK + (mapcar 'semantic-tag-name (EXPANDFULL $1 put_names)) + ; + +put_names: + LBRACE + () + | RBRACE + () + | put_name + ;; Must return a list of Semantic tags to EXPANDFULL! + (TAG $1 'put-name) + ; + +put_name: + SYMBOL + | token_type + ; + +put_value_list: + BRACE_BLOCK + (mapcar 'semantic-tag-code-detail (EXPANDFULL $1 put_values)) + ; + +put_values: + LBRACE + () + | RBRACE + () + | put_value + ;; Must return a list of Semantic tags to EXPANDFULL! + (CODE-TAG "put-value" $1) + ; + +put_value: + SYMBOL any_value + (cons $1 $2) + ; + +scopestart_decl: + SCOPESTART SYMBOL + `(TAG ',$2 'scopestart) + ; + +quotemode_decl: + QUOTEMODE SYMBOL + `(TAG ',$2 'quotemode) + ; + +start_decl: + START symbols + `(TAG ',(car $2) 'start :rest ',(cdr $2)) + ; + +keyword_decl: + KEYWORD SYMBOL string_value + `(TAG ',$2 'keyword :value ',$3) + ; + +token_decl: + TOKEN token_type_opt SYMBOL string_value + `(TAG ',$3 ',(if $2 'token 'keyword) :type ',$2 :value ',$4) + | TOKEN token_type_opt symbols + `(TAG ',(car $3) 'token :type ',$2 :rest ',(cdr $3)) + ; + +token_type_opt: + ;; EMPTY + | token_type + ; + +token_type: + LT SYMBOL GT + (progn $2) + ; + +type_decl: + TYPE token_type plist_opt + `(TAG ',$2 'type :value ',$3) + ; + +plist_opt: + ;;EMPTY + | plist + ; + +plist: + plist put_value + (append (list $2) $1) + | put_value + (list $1) + ; + +use_name_list: + BRACE_BLOCK + (mapcar 'semantic-tag-name (EXPANDFULL $1 use_names)) + ; + +use_names: + LBRACE + () + | RBRACE + () + | SYMBOL + ;; Must return a list of Semantic tags to EXPANDFULL! + (TAG $1 'use-name) + ; + +use_macros_decl: + USE-MACROS SYMBOL use_name_list + `(TAG "macro" 'macro :type ',$2 :value ',$3) + ; + +string_value: + STRING + (read $1) + ; + +;; Return a Lisp readable form +any_value: + SYMBOL + | STRING + | PAREN_BLOCK + | PREFIXED_LIST + | SEXP + ; + +symbols: + lifo_symbols + (nreverse $1) + ; + +lifo_symbols: + lifo_symbols SYMBOL + (cons $2 $1) + | SYMBOL + (list $1) + ; + +;;; Grammar rules +;; +nonterminal: + SYMBOL + (setq semantic-grammar-wy--nterm $1 + semantic-grammar-wy--rindx 0) + COLON rules SEMI + (TAG $1 'nonterminal :children $4) + ; + +rules: + lifo_rules + (apply 'nconc (nreverse $1)) + ; + +lifo_rules: + lifo_rules OR rule + (cons $3 $1) + | rule + (list $1) + ; + +rule: + rhs + (let* ((nterm semantic-grammar-wy--nterm) + (rindx semantic-grammar-wy--rindx) + (rhs $1) + comps prec action elt) + (setq semantic-grammar-wy--rindx (1+ semantic-grammar-wy--rindx)) + (while rhs + (setq elt (car rhs) + rhs (cdr rhs)) + (cond + ;; precedence level + ((vectorp elt) + (if prec + (error "Duplicate %%prec in `%s:%d' rule" nterm rindx)) + (setq prec (aref elt 0))) + ;; action + ((consp elt) + ;; don't forget that rhs items are in reverse order, so + ;; the end-of-rule semantic action is the first item. + (if (or action comps) + ;; a mid-rule action + (setq comps (cons elt comps) + ;; keep rule and action index synchronized + semantic-grammar-wy--rindx + (1+ semantic-grammar-wy--rindx)) + ;; the end-of-rule action + (setq action (car elt)))) + ;; item + (t + (setq comps (cons elt comps))))) + (EXPANDTAG + (TAG (format "%s:%d" nterm rindx) 'rule + :type (if comps "group" "empty") + :value comps :prec prec :expr action))) + ; + +rhs: + ;; EMPTY + | rhs item + (cons $2 $1) + | rhs action + (cons (list $2) $1) + | rhs PREC item + (cons (vector $3) $1) + ; + +action: + PAREN_BLOCK + | PREFIXED_LIST + | BRACE_BLOCK + (format "(progn\n%s)" + (let ((s $1)) + (if (string-match "^{[\r\n\t ]*" s) + (setq s (substring s (match-end 0)))) + (if (string-match "[\r\n\t ]*}$" s) + (setq s (substring s 0 (match-beginning 0)))) + s)) + ; + +items: + lifo_items + (nreverse $1) + ; + +lifo_items: + lifo_items item + (cons $2 $1) + | item + (list $1) + ; + +item: + SYMBOL + | CHARACTER + ; + +%% + +;;; grammar.wy ends here === added file 'admin/grammars/srecode-template.wy' --- admin/grammars/srecode-template.wy 1970-01-01 00:00:00 +0000 +++ admin/grammars/srecode-template.wy 2011-11-26 06:28:10 +0000 @@ -0,0 +1,235 @@ +;;; srecode-template.wy --- Semantic Recoder Template parser + +;; Copyright (C) 2005-2011 Free Software Foundation, Inc. + +;; Author: Eric Ludlam +;; Keywords: syntax +;; X-RCS: $Id: srecode-template.wy,v 1.10 2009-01-09 23:01:54 zappo Exp $ + +;; This file is part of GNU Emacs. + +;; GNU Emacs 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. + +;; GNU Emacs 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 GNU Emacs. If not, see . + +;;; Commentary: +;; +;; Parser for the Semantic Recoder template language +;; +;; Semantic Recoder templates are based on Google Templates +;; and are at the bottom of the Semantic Recoder API. + +%languagemode srecode-mode + +%start template_file + +;;; KEYWORDS +%type +%keyword SET "set" +%put SET summary "set " +%keyword SHOW "show" +%put SHOW summary "show ; to show a section" +%keyword MACRO "macro" +%put MACRO summary "... macro \"string\" ..." +%keyword CONTEXT "context" +%put CONTEXT summary "context " +%keyword TEMPLATE "template" +%put TEMPLATE summary "template \\n