From f79fbbc795f85969a7fc84f1e46ec8162c04b91b Mon Sep 17 00:00:00 2001 From: Chong Yidong Date: Sun, 31 Jul 2011 20:11:37 -0400 Subject: Tweak grammar files to match up with variable names used in parser files. --- etc/grammars/README | 18 +- etc/grammars/bovine-grammar.el | 9 +- etc/grammars/c.by | 2 +- etc/grammars/java-tags.wy | 16 +- etc/grammars/javascript-jv.wy | 526 ----------------------------------------- etc/grammars/js.wy | 526 +++++++++++++++++++++++++++++++++++++++++ etc/grammars/make.by | 2 +- etc/grammars/python.wy | 2 +- etc/grammars/scheme.by | 2 +- etc/grammars/wisent-grammar.el | 4 + 10 files changed, 556 insertions(+), 551 deletions(-) delete mode 100644 etc/grammars/javascript-jv.wy create mode 100644 etc/grammars/js.wy (limited to 'etc') diff --git a/etc/grammars/README b/etc/grammars/README index 657f9c20ec..c8328bbc88 100644 --- a/etc/grammars/README +++ b/etc/grammars/README @@ -3,15 +3,17 @@ generate the parser data in the lisp/semantic/bovine/ and lisp/semantic/wisent/ directories. You can run the parser generators with -emacs -batch --no-site-file \ - -l semantic/bovine -l semantic/wisent -l semantic/grammar \ - -l semantic/lex -l bovine-grammar.el \ - -f semantic-mode -f semantic-grammar-batch-build-packages *.by +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 semantic/bovine -l semantic/wisent -l semantic/grammar \ - -l semantic/lex -l wisent-grammar.el \ - -f semantic-mode -f semantic-grammar-batch-build-packages *.wy +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/. Currently, the parser files in lisp/ are not generated directly from these grammar files when making Emacs. This state of affairs, and the diff --git a/etc/grammars/bovine-grammar.el b/etc/grammars/bovine-grammar.el index 99da6ea559..5a94860867 100644 --- a/etc/grammars/bovine-grammar.el +++ b/etc/grammars/bovine-grammar.el @@ -32,6 +32,9 @@ (require 'semantic) (require 'semantic/grammar) (require 'semantic/find) +(require 'semantic/lex) +(require 'semantic/wisent) +(require 'semantic/bovine) (defun bovine-grammar-EXPAND (bounds nonterm) "Expand call to EXPAND grammar macro. @@ -112,7 +115,6 @@ FORM is a list in which we are substituting. Argument QUOTEMODE is non-nil if we are in backquote mode. When non-nil, optional argument INPLACE indicates that FORM is being expanded from elsewhere." - (when (listp form) (when (eq (car form) 'quote) (setq form (cdr form)) (cond @@ -218,7 +220,7 @@ expanded from elsewhere." )) (if inlist (insert ")")) (if inplace (insert ")"))) - ))) + )) (defun bovine-grammar-expand-action (textform quotemode) "Expand semantic action string TEXTFORM into Lisp code. @@ -226,7 +228,6 @@ QUOTEMODE is the mode in which quoted symbols are slurred." (if (string= "" textform) nil (let ((sexp (read textform))) - ;; We converted the lambda string into a list. Now write it ;; out as the bovine lambda expression, and do macro-like ;; conversion upon it. @@ -339,7 +340,6 @@ manual." (when (member nterm '("bovine-toplevel" "bovine-inner-scope")) (error "`%s' is a reserved internal name" nterm)) (insert "\n(" nterm) - ;; Process each rule (while rules (setq items (semantic-tag-get-attribute (car rules) :value) @@ -375,7 +375,6 @@ manual." (t (insert (semantic-grammar-item-text item))) )))) - (if prec (message "%%prec %S ignored" prec)) (if actn diff --git a/etc/grammars/c.by b/etc/grammars/c.by index cf8cb0c638..1797827679 100644 --- a/etc/grammars/c.by +++ b/etc/grammars/c.by @@ -38,7 +38,7 @@ ;; > * Can't parse signature element: "const RmcCmdMCDetailedStatus& status" ;; > * Can't parse signature element: "RmcBucStatus* rftBucStatus" -%package c-by +%package semantic-c-by %languagemode c-mode c++-mode %start declaration diff --git a/etc/grammars/java-tags.wy b/etc/grammars/java-tags.wy index aed39669c5..99d2b9df81 100644 --- a/etc/grammars/java-tags.wy +++ b/etc/grammars/java-tags.wy @@ -22,7 +22,7 @@ ;; You should have received a copy of the GNU General Public License ;; along with GNU Emacs. If not, see . -%package java-tags-wy +%package wisent-java-tags-wy %languagemode java-mode @@ -733,17 +733,17 @@ It ignores whitespaces, newlines and comments." semantic-lex-ignore-newline semantic-lex-ignore-comments ;;;; Auto-generated analyzers. - semantic/wisent/java-tags-wy---regexp-analyzer - semantic/wisent/java-tags-wy---sexp-analyzer + wisent-java-tags-wy---regexp-analyzer + wisent-java-tags-wy---sexp-analyzer ;; Must detect keywords before other symbols - semantic/wisent/java-tags-wy---keyword-analyzer - semantic/wisent/java-tags-wy---regexp-analyzer - semantic/wisent/java-tags-wy---string-analyzer - semantic/wisent/java-tags-wy---block-analyzer + wisent-java-tags-wy---keyword-analyzer + wisent-java-tags-wy---regexp-analyzer + wisent-java-tags-wy---string-analyzer + wisent-java-tags-wy---block-analyzer ;; In theory, unicode chars should be turned into normal chars ;; and then combined into regular ascii keywords and text. This ;; analyzer just keeps these things from making the lexer go boom. - semantic/wisent/java-tags-wy---regexp-analyzer + wisent-java-tags-wy---regexp-analyzer ;;;; semantic-lex-default-action) diff --git a/etc/grammars/javascript-jv.wy b/etc/grammars/javascript-jv.wy deleted file mode 100644 index ba518392ae..0000000000 --- a/etc/grammars/javascript-jv.wy +++ /dev/null @@ -1,526 +0,0 @@ -;;; javascript-jv.wy -- LALR grammar for Javascript - -;; Copyright (C) 2005-2011 Free Software Foundation, Inc. -;; Copyright (C) Ecma International. - -;; Author: Joakim Verona - -;; 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: - -;; The grammar itself is transcribed from the ECMAScript Language -;; Specification published at -;; -;; http://www.ecma-international.org/publications/standards/Ecma-262.htm -;; -;; and redistributed under the following license: - -;; Redistribution and use in source and binary forms, with or without -;; modification, are permitted provided that the following conditions -;; are met: - -;; 1. Redistributions of source code must retain the above copyright -;; notice, this list of conditions and the following disclaimer. - -;; 2. Redistributions in binary form must reproduce the above -;; copyright notice, this list of conditions and the following -;; disclaimer in the documentation and/or other materials provided -;; with the distribution. - -;; 3. Neither the name of the authors nor Ecma International may be -;; used to endorse or promote products derived from this software -;; without specific prior written permission. THIS SOFTWARE IS -;; PROVIDED BY THE ECMA INTERNATIONAL "AS IS" AND ANY EXPRESS OR -;; IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -;; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -;; ARE DISCLAIMED. IN NO EVENT SHALL ECMA INTERNATIONAL BE LIABLE FOR -;; ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -;; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -;; OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -;; BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -;; LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -;; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -;; USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH -;; DAMAGE. - -%package javascript-jv-wy -;; JAVE I prefere ecmascript-mode -%languagemode ecmascript-mode javascript-mode - -;; The default goal -%start Program -;; Other Goals -%start FormalParameterList - -;; with the terminals stuff, I used the javacript.y names, -;; but the semantic/wisent/java-tags.wy types -;; when possible -;; ------------------ -;; Operator terminals -;; ------------------ - -;;define-lex-string-type-analyzer gets called with the "syntax" comment -%type ;;syntax "\\(\\s.\\|\\s$\\|\\s'\\)+" matchdatatype string - -%token ASSIGN_SYMBOL "=" -%token BITWISE_AND "&" -%token BITWISE_AND_EQUALS "&=" -%token BITWISE_EXCLUSIVE_OR "^" -%token BITWISE_EXCLUSIVE_OR_EQUALS "^=" -%token BITWISE_OR "|" -%token BITWISE_OR_EQUALS "|=" -%token BITWISE_SHIFT_LEFT "<<" -%token BITWISE_SHIFT_LEFT_EQUALS "<<=" -%token BITWISE_SHIFT_RIGHT ">>" -%token BITWISE_SHIFT_RIGHT_EQUALS ">>=" -%token BITWISE_SHIFT_RIGHT_ZERO_FILL ">>>" -%token BITWISE_SHIFT_RIGHT_ZERO_FILL_EQUALS ">>>=" -%token NOT_EQUAL "!=" -%token DIV_EQUALS "/=" -%token EQUALS "==" -%token GREATER_THAN ">" -%token GT_EQUAL ">=" -%token LOGICAL_AND "&&" -%token LOGICAL_OR "||" -%token LOGICAL_NOT "!!" -%token LS_EQUAL "<=" -%token MINUS "-" -%token MINUS_EQUALS "-=" -%token MOD "%" -%token MOD_EQUALS "%=" -%token MULTIPLY "*" -%token MULTIPLY_EQUALS "*=" -%token PLUS "+" -%token PLUS_EQUALS "+=" -%token INCREMENT "++" -%token DECREMENT "--" -%token DIV "/" -%token COLON ":" -%token COMMA "," -%token DOT "." -%token LESS_THAN "<" -%token LINE_TERMINATOR "\n" -%token SEMICOLON ";" -%token ONES_COMPLIMENT "~" - - -;; ----------------------------- -;; Block & Parenthesis terminals -;; ----------------------------- -%type ;;syntax "\\s(\\|\\s)" matchdatatype block -%token PAREN_BLOCK "(OPEN_PARENTHESIS CLOSE_PARENTHESIS)" -%token BRACE_BLOCK "(START_BLOCK END_BLOCK)" -%token BRACK_BLOCK "(OPEN_SQ_BRACKETS CLOSE_SQ_BRACKETS)" - -%token OPEN_PARENTHESIS "(" -%token CLOSE_PARENTHESIS ")" - -%token START_BLOCK "{" -%token END_BLOCK "}" - -%token OPEN_SQ_BRACKETS "[" -%token CLOSE_SQ_BRACKETS "]" - - -;; ----------------- -;; Keyword terminals -;; ----------------- - -;; Generate a keyword analyzer -%type ;;syntax "\\(\\sw\\|\\s_\\)+" matchdatatype keyword - -%keyword IF "if" -%put IF summary -"if () [else ] (jv)" - -%keyword BREAK "break" -%put BREAK summary -"break [