]> git.eshelyaron.com Git - emacs.git/commitdiff
Tweak grammar files to match up with variable names used in parser files.
authorChong Yidong <cyd@stupidchicken.com>
Mon, 1 Aug 2011 00:11:37 +0000 (20:11 -0400)
committerChong Yidong <cyd@stupidchicken.com>
Mon, 1 Aug 2011 00:11:37 +0000 (20:11 -0400)
etc/grammars/README
etc/grammars/bovine-grammar.el
etc/grammars/c.by
etc/grammars/java-tags.wy
etc/grammars/javascript-jv.wy [deleted file]
etc/grammars/js.wy [new file with mode: 0644]
etc/grammars/make.by
etc/grammars/python.wy
etc/grammars/scheme.by
etc/grammars/wisent-grammar.el

index 657f9c20ecb76c50d66b5be24206aa67ad9eea5f..c8328bbc885ac32d49abb853657d1a4d8d208f5f 100644 (file)
@@ -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
index 99da6ea5599f9018205734277920613890f78a43..5a948608671ab11c9a0dd6668fcea40abecbc425 100644 (file)
@@ -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
index cf8cb0c638e24b7f44d54231719d6f097db6993d..1797827679b35293f72554da07eee3c26aa14af7 100644 (file)
@@ -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
index aed39669c5379888a71c369814286c8728b26c11..99d2b9df81d4b0d2527a055f71945d53a023a69f 100644 (file)
@@ -22,7 +22,7 @@
 ;; You should have received a copy of the GNU General Public License
 ;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
 
-%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--<number>-regexp-analyzer
-  semantic/wisent/java-tags-wy--<string>-sexp-analyzer
+  wisent-java-tags-wy--<number>-regexp-analyzer
+  wisent-java-tags-wy--<string>-sexp-analyzer
   ;; Must detect keywords before other symbols
-  semantic/wisent/java-tags-wy--<keyword>-keyword-analyzer
-  semantic/wisent/java-tags-wy--<symbol>-regexp-analyzer
-  semantic/wisent/java-tags-wy--<punctuation>-string-analyzer
-  semantic/wisent/java-tags-wy--<block>-block-analyzer
+  wisent-java-tags-wy--<keyword>-keyword-analyzer
+  wisent-java-tags-wy--<symbol>-regexp-analyzer
+  wisent-java-tags-wy--<punctuation>-string-analyzer
+  wisent-java-tags-wy--<block>-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--<unicode>-regexp-analyzer
+  wisent-java-tags-wy--<unicode>-regexp-analyzer
   ;;;;
   semantic-lex-default-action)
 
diff --git a/etc/grammars/javascript-jv.wy b/etc/grammars/javascript-jv.wy
deleted file mode 100644 (file)
index ba51839..0000000
+++ /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 <http://www.gnu.org/licenses/>.
-
-;;; 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 <punctuation> ;;syntax "\\(\\s.\\|\\s$\\|\\s'\\)+" matchdatatype string
-
-%token <punctuation> ASSIGN_SYMBOL            "="
-%token <punctuation> BITWISE_AND              "&"
-%token <punctuation> BITWISE_AND_EQUALS       "&="
-%token <punctuation> BITWISE_EXCLUSIVE_OR     "^"
-%token <punctuation> BITWISE_EXCLUSIVE_OR_EQUALS "^="
-%token <punctuation> BITWISE_OR               "|"
-%token <punctuation> BITWISE_OR_EQUALS        "|="
-%token <punctuation> BITWISE_SHIFT_LEFT       "<<"
-%token <punctuation> BITWISE_SHIFT_LEFT_EQUALS "<<="
-%token <punctuation> BITWISE_SHIFT_RIGHT      ">>"
-%token <punctuation> BITWISE_SHIFT_RIGHT_EQUALS ">>="
-%token <punctuation> BITWISE_SHIFT_RIGHT_ZERO_FILL ">>>"
-%token <punctuation> BITWISE_SHIFT_RIGHT_ZERO_FILL_EQUALS ">>>="
-%token <punctuation> NOT_EQUAL "!="
-%token <punctuation> DIV_EQUALS "/="
-%token <punctuation> EQUALS "=="
-%token <punctuation> GREATER_THAN ">"
-%token <punctuation> GT_EQUAL ">="
-%token <punctuation> LOGICAL_AND "&&"
-%token <punctuation> LOGICAL_OR "||"
-%token <punctuation> LOGICAL_NOT "!!"
-%token <punctuation> LS_EQUAL "<="
-%token <punctuation> MINUS "-"
-%token <punctuation> MINUS_EQUALS "-="
-%token <punctuation> MOD "%"
-%token <punctuation> MOD_EQUALS "%="
-%token <punctuation> MULTIPLY "*"
-%token <punctuation> MULTIPLY_EQUALS "*="
-%token <punctuation> PLUS "+"
-%token <punctuation> PLUS_EQUALS "+="
-%token <punctuation> INCREMENT "++"
-%token <punctuation> DECREMENT "--"
-%token <punctuation> DIV "/"
-%token <punctuation> COLON ":"
-%token <punctuation> COMMA ","
-%token <punctuation> DOT "."
-%token <punctuation> LESS_THAN "<"
-%token <punctuation> LINE_TERMINATOR "\n"
-%token <punctuation> SEMICOLON ";"
-%token <punctuation> ONES_COMPLIMENT "~"
-
-
-;; -----------------------------
-;; Block & Parenthesis terminals
-;; -----------------------------
-%type  <block>       ;;syntax "\\s(\\|\\s)" matchdatatype block
-%token <block>       PAREN_BLOCK "(OPEN_PARENTHESIS CLOSE_PARENTHESIS)"
-%token <block>       BRACE_BLOCK "(START_BLOCK END_BLOCK)"
-%token <block>       BRACK_BLOCK "(OPEN_SQ_BRACKETS CLOSE_SQ_BRACKETS)"
-
-%token <open-paren>  OPEN_PARENTHESIS  "("
-%token <close-paren>  CLOSE_PARENTHESIS ")"
-
-%token <open-paren>  START_BLOCK       "{"
-%token <close-paren>  END_BLOCK         "}"
-
-%token <open-paren>  OPEN_SQ_BRACKETS  "["
-%token <close-paren>  CLOSE_SQ_BRACKETS "]"
-
-
-;; -----------------
-;; Keyword terminals
-;; -----------------
-
-;; Generate a keyword analyzer
-%type  <keyword> ;;syntax "\\(\\sw\\|\\s_\\)+" matchdatatype keyword
-
-%keyword IF           "if"
-%put     IF summary
-"if (<expr>) <stmt> [else <stmt>] (jv)"
-
-%keyword BREAK        "break"
-%put     BREAK summary
-"break [<label>] ;"
-
-%keyword CONTINUE     "continue"
-%put     CONTINUE summary
-"continue [<label>] ;"
-
-%keyword ELSE         "else"
-%put     ELSE summary
-"if (<expr>) <stmt> else <stmt>"
-
-
-%keyword FOR          "for"
-%put     FOR summary
-"for ([<init-expr>]; [<expr>]; [<update-expr>]) <stmt>"
-
-
-%keyword FUNCTION  "function"
-%put     FUNCTION summary
-"function declaration blah blah"
-
-%keyword THIS         "this"
-%put THIS summary
-"this"
-
-
-%keyword RETURN       "return"
-%put     RETURN summary
-"return [<expr>] ;"
-
-%keyword WHILE        "while"
-%put     WHILE summary
-"while (<expr>) <stmt> | do <stmt> while (<expr>);"
-
-%keyword VOID_SYMBOL         "void"
-%put     VOID_SYMBOL summary
-"Method return type: void <name> ..."
-
-
-
-%keyword NEW          "new"
-%put NEW summary
-"new <objecttype> - Creates a new object."
-
-%keyword DELETE "delete"
-%put DELETE summary
-"delete(<objectreference>) - Deletes the object."
-
-%keyword VAR "var"
-%put VAR  summary
-"var <variablename> [= value];"
-
-%keyword WITH "with"
-%put WITH summary
-"with "
-
-%keyword TYPEOF "typeof"
-%put TYPEOF summary
-"typeof "
-
-%keyword IN "in"
-%put IN  summary
-"in something"
-
-
-;; -----------------
-;; Literal terminals
-;; -----------------
-
-;;the .y file uses VARIABLE as IDENTIFIER, which seems a bit evil
-;; it think the normal .wy convention is better than this
-%type  <symbol>      ;;syntax "\\(\\sw\\|\\s_\\)+"
-%token <symbol>      VARIABLE
-
-%type  <string>      ;;syntax "\\s\"" matchdatatype sexp
-%token <string>      STRING
-
-%type  <number>      ;;syntax semantic-lex-number-expression
-%token <number>      NUMBER
-
-
-%token FALSE
-%token TRUE
-%token QUERY
-
-
-%token NULL_TOKEN
-
-;;%token UNDEFINED_TOKEN
-;;%token INFINITY
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; associativity and stuff
-%left PLUS MINUS
-%left MULTIPLY DIV MOD
-
-%nonassoc FALSE
-%nonassoc HIGHER_THAN_FALSE
-%nonassoc ELSE
-%nonassoc LOWER_THAN_CLOSE_PARENTHESIS
-%nonassoc CLOSE_PARENTHESIS
-
-%%
-
-Program : SourceElement
-        ;
-
-SourceElement : Statement
-              | FunctionDeclaration
-              ;
-
-Statement : Block
-          | VariableStatement
-          | EmptyStatement
-          | ExpressionStatement
-          | IfStatement
-          | IterationExpression
-          | ContinueStatement
-          | BreakStatement
-          | ReturnStatement
-          | WithStatement
-          ;   
-      
-FunctionDeclaration : FUNCTION VARIABLE FormalParameterListBlock Block
-                     (FUNCTION-TAG $2 nil $3)
-                    ;
-
-FormalParameterListBlock : PAREN_BLOCK
-                          (EXPANDFULL $1 FormalParameterList)
-                       ;
-
-FormalParameterList: OPEN_PARENTHESIS
-                    ()
-                  | VARIABLE
-                    (VARIABLE-TAG $1 nil nil)
-                  | CLOSE_PARENTHESIS
-                    ()
-                  | COMMA
-                    ()
-                  ;
-
-StatementList : Statement
-              | StatementList Statement
-              ;
-
-Block : BRACE_BLOCK
-     ;; If you want to parse the body of the function
-     ;; ( EXPANDFULL $1 BlockExpand )
-      ;
-
-BlockExpand: START_BLOCK StatementList END_BLOCK
-          | START_BLOCK END_BLOCK
-          ;
-
-VariableStatement : VAR VariableDeclarationList SEMICOLON
-                   (VARIABLE-TAG $2 nil nil)
-                  ;
-
-VariableDeclarationList : VariableDeclaration
-                         (list $1)
-                        | VariableDeclarationList COMMA VariableDeclaration
-                         (append $1 (list $3))
-                        ;
-
-VariableDeclaration : VARIABLE
-                     (append (list $1 nil) $region)
-                    | VARIABLE Initializer
-                     (append (cons $1 $2) $region)
-                    ;
-
-Initializer : ASSIGN_SYMBOL AssignmentExpression
-             (list $2)
-            ;
-
-EmptyStatement : SEMICOLON
-               ;
-
-ExpressionStatement : Expression SEMICOLON
-                    ;
-
-IfStatement : IF OPEN_PARENTHESIS Expression CLOSE_PARENTHESIS Statement  %prec HIGHER_THAN_FALSE
-            | IF OPEN_PARENTHESIS Expression CLOSE_PARENTHESIS Statement ELSE Statement
-            | IF OPEN_PARENTHESIS FALSE CLOSE_PARENTHESIS Statement
-            | IF OPEN_PARENTHESIS LeftHandSideExpression AssignmentOperator AssignmentExpression CLOSE_PARENTHESIS Statement
-            ;
-
-IterationExpression : WHILE OPEN_PARENTHESIS Expression CLOSE_PARENTHESIS Statement %prec HIGHER_THAN_FALSE
-                    | WHILE OPEN_PARENTHESIS FALSE CLOSE_PARENTHESIS Statement
-                    | WHILE OPEN_PARENTHESIS LeftHandSideExpression AssignmentOperator AssignmentExpression CLOSE_PARENTHESIS Statement
-                    | FOR OPEN_PARENTHESIS OptionalExpression SEMICOLON OptionalExpression SEMICOLON OptionalExpression CLOSE_PARENTHESIS Statement
-                    | FOR OPEN_PARENTHESIS VAR VariableDeclarationList SEMICOLON OptionalExpression SEMICOLON OptionalExpression CLOSE_PARENTHESIS Statement
-                    | FOR OPEN_PARENTHESIS LeftHandSideExpression IN Expression CLOSE_PARENTHESIS Statement
-                    | FOR OPEN_PARENTHESIS VAR VARIABLE OptionalInitializer IN Expression CLOSE_PARENTHESIS Statement
-                    ;
-
-ContinueStatement : CONTINUE SEMICOLON
-                  ;
-
-;;JAVE break needs labels 
-BreakStatement : BREAK SEMICOLON
-              ;;               | BREAK identifier SEMICOLON
-               ;
-
-ReturnStatement : RETURN Expression SEMICOLON
-                | RETURN SEMICOLON
-                ;
-
-WithStatement : WITH OPEN_PARENTHESIS Expression CLOSE_PARENTHESIS   Statement
-              ;
-
-OptionalInitializer : Initializer
-                    |
-                    ;
-
-PrimaryExpression : THIS
-                  | VARIABLE
-                  | NUMBER
-                  | STRING
-                  | NULL_TOKEN
-                  | TRUE
-                  | FALSE
-                  | OPEN_PARENTHESIS Expression CLOSE_PARENTHESIS
-                  ;
-
-MemberExpression : PrimaryExpression
-                 | MemberExpression OPEN_SQ_BRACKETS Expression  CLOSE_SQ_BRACKETS
-                 | MemberExpression DOT VARIABLE
-                 | NEW MemberExpression Arguments
-                 ;
-
-NewExpression : MemberExpression
-              | NEW NewExpression
-              ;
-
-CallExpression : MemberExpression Arguments
-               | CallExpression Arguments
-               | CallExpression OPEN_SQ_BRACKETS Expression  CLOSE_SQ_BRACKETS
-               | CallExpression DOT VARIABLE
-               ;
-
-Arguments : OPEN_PARENTHESIS CLOSE_PARENTHESIS
-          | OPEN_PARENTHESIS ArgumentList CLOSE_PARENTHESIS
-          ;
-
-ArgumentList : AssignmentExpression
-             | ArgumentList COMMA AssignmentExpression
-             ;
-
-LeftHandSideExpression : NewExpression
-                       | CallExpression
-                       ;
-
-PostfixExpression : LeftHandSideExpression
-                  | LeftHandSideExpression INCREMENT
-                  | LeftHandSideExpression DECREMENT
-                  ;
-
-UnaryExpression : PostfixExpression
-                | DELETE UnaryExpression
-                | VOID_SYMBOL UnaryExpression
-                | TYPEOF UnaryExpression
-                | INCREMENT UnaryExpression
-                | DECREMENT UnaryExpression
-                | PLUS UnaryExpression
-                | MINUS UnaryExpression
-                | ONES_COMPLIMENT UnaryExpression
-                | LOGICAL_NOT UnaryExpression
-                ;
-
-MultiplicativeExpression : UnaryExpression
-                         | MultiplicativeExpression MULTIPLY UnaryExpression
-                         | MultiplicativeExpression DIV UnaryExpression
-                         | MultiplicativeExpression MOD UnaryExpression
-                         ;
-
-AdditiveExpression : MultiplicativeExpression
-                   | AdditiveExpression PLUS MultiplicativeExpression
-                   | AdditiveExpression MINUS MultiplicativeExpression
-                   ;
-
-ShiftExpression : AdditiveExpression
-                | ShiftExpression BITWISE_SHIFT_LEFT AdditiveExpression
-                | ShiftExpression BITWISE_SHIFT_RIGHT AdditiveExpression
-                | ShiftExpression BITWISE_SHIFT_RIGHT_ZERO_FILL  AdditiveExpression
-                ;
-
-RelationalExpression : ShiftExpression
-                     | RelationalExpression LESS_THAN ShiftExpression
-                     | RelationalExpression GREATER_THAN ShiftExpression
-                     | RelationalExpression LS_EQUAL ShiftExpression
-                     | RelationalExpression GT_EQUAL ShiftExpression
-                     ;
-
-EqualityExpression : RelationalExpression
-                   | EqualityExpression EQUALS RelationalExpression
-                   | EqualityExpression NOT_EQUAL RelationalExpression
-                   ;
-
-BitwiseANDExpression : EqualityExpression
-                     | BitwiseANDExpression BITWISE_AND EqualityExpression
-                     ;
-
-BitwiseXORExpression : BitwiseANDExpression
-                     | BitwiseXORExpression BITWISE_EXCLUSIVE_OR     BitwiseANDExpression
-                     ;
-
-BitwiseORExpression : BitwiseXORExpression
-                    | BitwiseORExpression BITWISE_OR BitwiseXORExpression
-                    ;
-
-LogicalANDExpression : BitwiseORExpression
-                     | LogicalANDExpression LOGICAL_AND BitwiseORExpression
-                     ;
-
-LogicalORExpression : LogicalANDExpression
-                    | LogicalORExpression LOGICAL_OR LogicalANDExpression
-                    ;
-
-ConditionalExpression : LogicalORExpression
-                      | LogicalORExpression QUERY AssignmentExpression COLON    AssignmentExpression
-                      ;
-
-AssignmentExpression : ConditionalExpression
-                     | LeftHandSideExpression AssignmentOperator  AssignmentExpression %prec LOWER_THAN_CLOSE_PARENTHESIS
-                     ;
-
-AssignmentOperator : ASSIGN_SYMBOL
-                   | MULTIPLY_EQUALS
-                   | DIV_EQUALS
-                   | MOD_EQUALS
-                   | PLUS_EQUALS
-                   | MINUS_EQUALS
-                   | BITWISE_SHIFT_LEFT_EQUALS
-                   | BITWISE_SHIFT_RIGHT_EQUALS
-                   | BITWISE_SHIFT_RIGHT_ZERO_FILL_EQUALS
-                   | BITWISE_AND_EQUALS
-                   | BITWISE_EXCLUSIVE_OR_EQUALS
-                   | BITWISE_OR_EQUALS
-                   ;
-
-Expression : AssignmentExpression
-           | Expression COMMA AssignmentExpression
-           ;
-
-OptionalExpression : Expression
-                   |
-                   ;
-
-%%
-
-;;here something like:
-;;(define-lex wisent-java-tags-lexer
-;; should go
-(define-lex javascript-lexer-jv
-"javascript thingy"
-;;std stuff
-  semantic-lex-ignore-whitespace
-  semantic-lex-ignore-newline
-  semantic-lex-ignore-comments
-
-  ;;stuff generated from the wy file(one for each "type" declaration)
-  semantic/wisent/javascript-jv-wy--<number>-regexp-analyzer
-  semantic/wisent/javascript-jv-wy--<string>-sexp-analyzer
-
-  semantic/wisent/javascript-jv-wy--<keyword>-keyword-analyzer
-
-  semantic/wisent/javascript-jv-wy--<symbol>-regexp-analyzer
-  semantic/wisent/javascript-jv-wy--<punctuation>-string-analyzer
-  semantic/wisent/javascript-jv-wy--<block>-block-analyzer
-
-
-  ;;;;more std stuff
-  semantic-lex-default-action
-  )
-
-;;; javascript-jv.wy ends here
diff --git a/etc/grammars/js.wy b/etc/grammars/js.wy
new file mode 100644 (file)
index 0000000..a13abf5
--- /dev/null
@@ -0,0 +1,526 @@
+;;; javascript-jv.wy -- LALR grammar for Javascript
+
+;; Copyright (C) 2005-2011 Free Software Foundation, Inc.
+;; Copyright (C) 1998-2011 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 <http://www.gnu.org/licenses/>.
+
+;;; 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 wisent-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 <punctuation> ;;syntax "\\(\\s.\\|\\s$\\|\\s'\\)+" matchdatatype string
+
+%token <punctuation> ASSIGN_SYMBOL            "="
+%token <punctuation> BITWISE_AND              "&"
+%token <punctuation> BITWISE_AND_EQUALS       "&="
+%token <punctuation> BITWISE_EXCLUSIVE_OR     "^"
+%token <punctuation> BITWISE_EXCLUSIVE_OR_EQUALS "^="
+%token <punctuation> BITWISE_OR               "|"
+%token <punctuation> BITWISE_OR_EQUALS        "|="
+%token <punctuation> BITWISE_SHIFT_LEFT       "<<"
+%token <punctuation> BITWISE_SHIFT_LEFT_EQUALS "<<="
+%token <punctuation> BITWISE_SHIFT_RIGHT      ">>"
+%token <punctuation> BITWISE_SHIFT_RIGHT_EQUALS ">>="
+%token <punctuation> BITWISE_SHIFT_RIGHT_ZERO_FILL ">>>"
+%token <punctuation> BITWISE_SHIFT_RIGHT_ZERO_FILL_EQUALS ">>>="
+%token <punctuation> NOT_EQUAL "!="
+%token <punctuation> DIV_EQUALS "/="
+%token <punctuation> EQUALS "=="
+%token <punctuation> GREATER_THAN ">"
+%token <punctuation> GT_EQUAL ">="
+%token <punctuation> LOGICAL_AND "&&"
+%token <punctuation> LOGICAL_OR "||"
+%token <punctuation> LOGICAL_NOT "!!"
+%token <punctuation> LS_EQUAL "<="
+%token <punctuation> MINUS "-"
+%token <punctuation> MINUS_EQUALS "-="
+%token <punctuation> MOD "%"
+%token <punctuation> MOD_EQUALS "%="
+%token <punctuation> MULTIPLY "*"
+%token <punctuation> MULTIPLY_EQUALS "*="
+%token <punctuation> PLUS "+"
+%token <punctuation> PLUS_EQUALS "+="
+%token <punctuation> INCREMENT "++"
+%token <punctuation> DECREMENT "--"
+%token <punctuation> DIV "/"
+%token <punctuation> COLON ":"
+%token <punctuation> COMMA ","
+%token <punctuation> DOT "."
+%token <punctuation> LESS_THAN "<"
+%token <punctuation> LINE_TERMINATOR "\n"
+%token <punctuation> SEMICOLON ";"
+%token <punctuation> ONES_COMPLIMENT "~"
+
+
+;; -----------------------------
+;; Block & Parenthesis terminals
+;; -----------------------------
+%type  <block>       ;;syntax "\\s(\\|\\s)" matchdatatype block
+%token <block>       PAREN_BLOCK "(OPEN_PARENTHESIS CLOSE_PARENTHESIS)"
+%token <block>       BRACE_BLOCK "(START_BLOCK END_BLOCK)"
+%token <block>       BRACK_BLOCK "(OPEN_SQ_BRACKETS CLOSE_SQ_BRACKETS)"
+
+%token <open-paren>  OPEN_PARENTHESIS  "("
+%token <close-paren>  CLOSE_PARENTHESIS ")"
+
+%token <open-paren>  START_BLOCK       "{"
+%token <close-paren>  END_BLOCK         "}"
+
+%token <open-paren>  OPEN_SQ_BRACKETS  "["
+%token <close-paren>  CLOSE_SQ_BRACKETS "]"
+
+
+;; -----------------
+;; Keyword terminals
+;; -----------------
+
+;; Generate a keyword analyzer
+%type  <keyword> ;;syntax "\\(\\sw\\|\\s_\\)+" matchdatatype keyword
+
+%keyword IF           "if"
+%put     IF summary
+"if (<expr>) <stmt> [else <stmt>] (jv)"
+
+%keyword BREAK        "break"
+%put     BREAK summary
+"break [<label>] ;"
+
+%keyword CONTINUE     "continue"
+%put     CONTINUE summary
+"continue [<label>] ;"
+
+%keyword ELSE         "else"
+%put     ELSE summary
+"if (<expr>) <stmt> else <stmt>"
+
+
+%keyword FOR          "for"
+%put     FOR summary
+"for ([<init-expr>]; [<expr>]; [<update-expr>]) <stmt>"
+
+
+%keyword FUNCTION  "function"
+%put     FUNCTION summary
+"function declaration blah blah"
+
+%keyword THIS         "this"
+%put THIS summary
+"this"
+
+
+%keyword RETURN       "return"
+%put     RETURN summary
+"return [<expr>] ;"
+
+%keyword WHILE        "while"
+%put     WHILE summary
+"while (<expr>) <stmt> | do <stmt> while (<expr>);"
+
+%keyword VOID_SYMBOL         "void"
+%put     VOID_SYMBOL summary
+"Method return type: void <name> ..."
+
+
+
+%keyword NEW          "new"
+%put NEW summary
+"new <objecttype> - Creates a new object."
+
+%keyword DELETE "delete"
+%put DELETE summary
+"delete(<objectreference>) - Deletes the object."
+
+%keyword VAR "var"
+%put VAR  summary
+"var <variablename> [= value];"
+
+%keyword WITH "with"
+%put WITH summary
+"with "
+
+%keyword TYPEOF "typeof"
+%put TYPEOF summary
+"typeof "
+
+%keyword IN "in"
+%put IN  summary
+"in something"
+
+
+;; -----------------
+;; Literal terminals
+;; -----------------
+
+;;the .y file uses VARIABLE as IDENTIFIER, which seems a bit evil
+;; it think the normal .wy convention is better than this
+%type  <symbol>      ;;syntax "\\(\\sw\\|\\s_\\)+"
+%token <symbol>      VARIABLE
+
+%type  <string>      ;;syntax "\\s\"" matchdatatype sexp
+%token <string>      STRING
+
+%type  <number>      ;;syntax semantic-lex-number-expression
+%token <number>      NUMBER
+
+
+%token FALSE
+%token TRUE
+%token QUERY
+
+
+%token NULL_TOKEN
+
+;;%token UNDEFINED_TOKEN
+;;%token INFINITY
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; associativity and stuff
+%left PLUS MINUS
+%left MULTIPLY DIV MOD
+
+%nonassoc FALSE
+%nonassoc HIGHER_THAN_FALSE
+%nonassoc ELSE
+%nonassoc LOWER_THAN_CLOSE_PARENTHESIS
+%nonassoc CLOSE_PARENTHESIS
+
+%%
+
+Program : SourceElement
+        ;
+
+SourceElement : Statement
+              | FunctionDeclaration
+              ;
+
+Statement : Block
+          | VariableStatement
+          | EmptyStatement
+          | ExpressionStatement
+          | IfStatement
+          | IterationExpression
+          | ContinueStatement
+          | BreakStatement
+          | ReturnStatement
+          | WithStatement
+          ;   
+      
+FunctionDeclaration : FUNCTION VARIABLE FormalParameterListBlock Block
+                     (FUNCTION-TAG $2 nil $3)
+                    ;
+
+FormalParameterListBlock : PAREN_BLOCK
+                          (EXPANDFULL $1 FormalParameterList)
+                       ;
+
+FormalParameterList: OPEN_PARENTHESIS
+                    ()
+                  | VARIABLE
+                    (VARIABLE-TAG $1 nil nil)
+                  | CLOSE_PARENTHESIS
+                    ()
+                  | COMMA
+                    ()
+                  ;
+
+StatementList : Statement
+              | StatementList Statement
+              ;
+
+Block : BRACE_BLOCK
+     ;; If you want to parse the body of the function
+     ;; ( EXPANDFULL $1 BlockExpand )
+      ;
+
+BlockExpand: START_BLOCK StatementList END_BLOCK
+          | START_BLOCK END_BLOCK
+          ;
+
+VariableStatement : VAR VariableDeclarationList SEMICOLON
+                   (VARIABLE-TAG $2 nil nil)
+                  ;
+
+VariableDeclarationList : VariableDeclaration
+                         (list $1)
+                        | VariableDeclarationList COMMA VariableDeclaration
+                         (append $1 (list $3))
+                        ;
+
+VariableDeclaration : VARIABLE
+                     (append (list $1 nil) $region)
+                    | VARIABLE Initializer
+                     (append (cons $1 $2) $region)
+                    ;
+
+Initializer : ASSIGN_SYMBOL AssignmentExpression
+             (list $2)
+            ;
+
+EmptyStatement : SEMICOLON
+               ;
+
+ExpressionStatement : Expression SEMICOLON
+                    ;
+
+IfStatement : IF OPEN_PARENTHESIS Expression CLOSE_PARENTHESIS Statement  %prec HIGHER_THAN_FALSE
+            | IF OPEN_PARENTHESIS Expression CLOSE_PARENTHESIS Statement ELSE Statement
+            | IF OPEN_PARENTHESIS FALSE CLOSE_PARENTHESIS Statement
+            | IF OPEN_PARENTHESIS LeftHandSideExpression AssignmentOperator AssignmentExpression CLOSE_PARENTHESIS Statement
+            ;
+
+IterationExpression : WHILE OPEN_PARENTHESIS Expression CLOSE_PARENTHESIS Statement %prec HIGHER_THAN_FALSE
+                    | WHILE OPEN_PARENTHESIS FALSE CLOSE_PARENTHESIS Statement
+                    | WHILE OPEN_PARENTHESIS LeftHandSideExpression AssignmentOperator AssignmentExpression CLOSE_PARENTHESIS Statement
+                    | FOR OPEN_PARENTHESIS OptionalExpression SEMICOLON OptionalExpression SEMICOLON OptionalExpression CLOSE_PARENTHESIS Statement
+                    | FOR OPEN_PARENTHESIS VAR VariableDeclarationList SEMICOLON OptionalExpression SEMICOLON OptionalExpression CLOSE_PARENTHESIS Statement
+                    | FOR OPEN_PARENTHESIS LeftHandSideExpression IN Expression CLOSE_PARENTHESIS Statement
+                    | FOR OPEN_PARENTHESIS VAR VARIABLE OptionalInitializer IN Expression CLOSE_PARENTHESIS Statement
+                    ;
+
+ContinueStatement : CONTINUE SEMICOLON
+                  ;
+
+;;JAVE break needs labels 
+BreakStatement : BREAK SEMICOLON
+              ;;               | BREAK identifier SEMICOLON
+               ;
+
+ReturnStatement : RETURN Expression SEMICOLON
+                | RETURN SEMICOLON
+                ;
+
+WithStatement : WITH OPEN_PARENTHESIS Expression CLOSE_PARENTHESIS   Statement
+              ;
+
+OptionalInitializer : Initializer
+                    |
+                    ;
+
+PrimaryExpression : THIS
+                  | VARIABLE
+                  | NUMBER
+                  | STRING
+                  | NULL_TOKEN
+                  | TRUE
+                  | FALSE
+                  | OPEN_PARENTHESIS Expression CLOSE_PARENTHESIS
+                  ;
+
+MemberExpression : PrimaryExpression
+                 | MemberExpression OPEN_SQ_BRACKETS Expression  CLOSE_SQ_BRACKETS
+                 | MemberExpression DOT VARIABLE
+                 | NEW MemberExpression Arguments
+                 ;
+
+NewExpression : MemberExpression
+              | NEW NewExpression
+              ;
+
+CallExpression : MemberExpression Arguments
+               | CallExpression Arguments
+               | CallExpression OPEN_SQ_BRACKETS Expression  CLOSE_SQ_BRACKETS
+               | CallExpression DOT VARIABLE
+               ;
+
+Arguments : OPEN_PARENTHESIS CLOSE_PARENTHESIS
+          | OPEN_PARENTHESIS ArgumentList CLOSE_PARENTHESIS
+          ;
+
+ArgumentList : AssignmentExpression
+             | ArgumentList COMMA AssignmentExpression
+             ;
+
+LeftHandSideExpression : NewExpression
+                       | CallExpression
+                       ;
+
+PostfixExpression : LeftHandSideExpression
+                  | LeftHandSideExpression INCREMENT
+                  | LeftHandSideExpression DECREMENT
+                  ;
+
+UnaryExpression : PostfixExpression
+                | DELETE UnaryExpression
+                | VOID_SYMBOL UnaryExpression
+                | TYPEOF UnaryExpression
+                | INCREMENT UnaryExpression
+                | DECREMENT UnaryExpression
+                | PLUS UnaryExpression
+                | MINUS UnaryExpression
+                | ONES_COMPLIMENT UnaryExpression
+                | LOGICAL_NOT UnaryExpression
+                ;
+
+MultiplicativeExpression : UnaryExpression
+                         | MultiplicativeExpression MULTIPLY UnaryExpression
+                         | MultiplicativeExpression DIV UnaryExpression
+                         | MultiplicativeExpression MOD UnaryExpression
+                         ;
+
+AdditiveExpression : MultiplicativeExpression
+                   | AdditiveExpression PLUS MultiplicativeExpression
+                   | AdditiveExpression MINUS MultiplicativeExpression
+                   ;
+
+ShiftExpression : AdditiveExpression
+                | ShiftExpression BITWISE_SHIFT_LEFT AdditiveExpression
+                | ShiftExpression BITWISE_SHIFT_RIGHT AdditiveExpression
+                | ShiftExpression BITWISE_SHIFT_RIGHT_ZERO_FILL  AdditiveExpression
+                ;
+
+RelationalExpression : ShiftExpression
+                     | RelationalExpression LESS_THAN ShiftExpression
+                     | RelationalExpression GREATER_THAN ShiftExpression
+                     | RelationalExpression LS_EQUAL ShiftExpression
+                     | RelationalExpression GT_EQUAL ShiftExpression
+                     ;
+
+EqualityExpression : RelationalExpression
+                   | EqualityExpression EQUALS RelationalExpression
+                   | EqualityExpression NOT_EQUAL RelationalExpression
+                   ;
+
+BitwiseANDExpression : EqualityExpression
+                     | BitwiseANDExpression BITWISE_AND EqualityExpression
+                     ;
+
+BitwiseXORExpression : BitwiseANDExpression
+                     | BitwiseXORExpression BITWISE_EXCLUSIVE_OR     BitwiseANDExpression
+                     ;
+
+BitwiseORExpression : BitwiseXORExpression
+                    | BitwiseORExpression BITWISE_OR BitwiseXORExpression
+                    ;
+
+LogicalANDExpression : BitwiseORExpression
+                     | LogicalANDExpression LOGICAL_AND BitwiseORExpression
+                     ;
+
+LogicalORExpression : LogicalANDExpression
+                    | LogicalORExpression LOGICAL_OR LogicalANDExpression
+                    ;
+
+ConditionalExpression : LogicalORExpression
+                      | LogicalORExpression QUERY AssignmentExpression COLON    AssignmentExpression
+                      ;
+
+AssignmentExpression : ConditionalExpression
+                     | LeftHandSideExpression AssignmentOperator  AssignmentExpression %prec LOWER_THAN_CLOSE_PARENTHESIS
+                     ;
+
+AssignmentOperator : ASSIGN_SYMBOL
+                   | MULTIPLY_EQUALS
+                   | DIV_EQUALS
+                   | MOD_EQUALS
+                   | PLUS_EQUALS
+                   | MINUS_EQUALS
+                   | BITWISE_SHIFT_LEFT_EQUALS
+                   | BITWISE_SHIFT_RIGHT_EQUALS
+                   | BITWISE_SHIFT_RIGHT_ZERO_FILL_EQUALS
+                   | BITWISE_AND_EQUALS
+                   | BITWISE_EXCLUSIVE_OR_EQUALS
+                   | BITWISE_OR_EQUALS
+                   ;
+
+Expression : AssignmentExpression
+           | Expression COMMA AssignmentExpression
+           ;
+
+OptionalExpression : Expression
+                   |
+                   ;
+
+%%
+
+;;here something like:
+;;(define-lex wisent-java-tags-lexer
+;; should go
+(define-lex javascript-lexer-jv
+"javascript thingy"
+;;std stuff
+  semantic-lex-ignore-whitespace
+  semantic-lex-ignore-newline
+  semantic-lex-ignore-comments
+
+  ;;stuff generated from the wy file(one for each "type" declaration)
+  wisent-javascript-jv-wy--<number>-regexp-analyzer
+  wisent-javascript-jv-wy--<string>-sexp-analyzer
+
+  wisent-javascript-jv-wy--<keyword>-keyword-analyzer
+
+  wisent-javascript-jv-wy--<symbol>-regexp-analyzer
+  wisent-javascript-jv-wy--<punctuation>-string-analyzer
+  wisent-javascript-jv-wy--<block>-block-analyzer
+
+
+  ;;;;more std stuff
+  semantic-lex-default-action
+  )
+
+;;; javascript-jv.wy ends here
index 3eb56bf2b49dfbee31ad7ea6b6b870db243a6187..dab4472b737b558eb400062849381e7b879a8357 100644 (file)
@@ -21,7 +21,7 @@
 ;; You should have received a copy of the GNU General Public License
 ;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
 
-%package make-by
+%package semantic-make-by
 
 %languagemode  makefile-mode
 %start         Makefile
index 8a7b7771d53db6bfb3dafab7ac5c50a1d62f8d8a..a0af813e5e8f413c19844242152d55e7ee95801e 100644 (file)
@@ -86,7 +86,7 @@
 ;; Settings
 ;; --------
 
-%package python-wy
+%package wisent-python-wy
 
 %languagemode python-mode
 
index 9e57afe7438137a4c4e22822086fd0f0c337970b..bc6612d4c708a69387a9e3fde5c6e0021912a366 100644 (file)
@@ -17,7 +17,7 @@
 ;; You should have received a copy of the GNU General Public License
 ;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
 
-%package scm-by
+%package semantic-scm-by
 
 %languagemode  scheme-mode
 %start         scheme
index 1bef2646645a05113ac5b49ff553d71f22526d46..d7de1ee6f7b0454336ee4711f546c6bae79bb067 100644 (file)
 ;; Major mode for editing Wisent's input grammar (.wy) files.
 
 ;;; Code:
+(require 'semantic)
 (require 'semantic/grammar)
 (require 'semantic/find)
+(require 'semantic/lex)
+(require 'semantic/wisent)
+(require 'semantic/bovine)
 
 (defsubst wisent-grammar-region-placeholder (symb)
   "Given a $N placeholder symbol in SYMB, return a $regionN symbol.