mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2024-11-21 06:55:39 +00:00
Stop keeping (all but one) generated cedet grammar files in the repository
* configure.ac (SUBDIR_MAKEFILES, AC_CONFIG_FILES): Add admin/grammars Makefile. * Makefile.in (distclean, bootstrap-clean, maintainer-clean): Also clean admin/grammars, if present. * admin/grammars/README: Remove. * admin/grammars/Makefile.in: New file. * admin/grammars/c.by, admin/grammars/java-tags.wy, admin/grammars/js.wy: * admin/grammars/python.wy: Update declarations to match generated outputs. * lisp/Makefile.in (semantic): New. (compile-main): Depend on semantic. * lisp/cedet/semantic/bovine/grammar.el (bovine--make-parser-1): New function, split from bovine-make-parsers. (bovine-make-parsers): Use bovine--make-parser-1. (bovine-batch-make-parser): New function. * lisp/cedet/semantic/wisent/grammar.el (wisent--make-parser-1): New function, split from wisent-make-parsers. (wisent-make-parsers): Use wisent--make-parser-1. (wisent-batch-make-parser): New function. * lisp/cedet/semantic/db.el (semanticdb-save-all-db): Avoid prompting in batch mode. * lisp/cedet/semantic/grammar.el (semantic-grammar-footer-template): Disable version-control and autoloads in the output. (semantic-grammar-create-package): Add option to return nil if output is up-to-date. * lisp/cedet/semantic/bovine/c-by.el, lisp/cedet/semantic/bovine/make-by.el: * lisp/cedet/semantic/bovine/scm-by.el, lisp/cedet/semantic/wisent/javat-wy.el: * lisp/cedet/semantic/wisent/js-wy.el, lisp/cedet/semantic/wisent/python-wy.el: * lisp/cedet/srecode/srt-wy.el: Remove generated files from repository. * .bzrignore: Update for this.
This commit is contained in:
parent
a64133bd25
commit
f9b697ddaa
@ -1,3 +1,11 @@
|
||||
2013-11-30 Glenn Morris <rgm@gnu.org>
|
||||
|
||||
Stop keeping (most) generated cedet grammar files in the repository.
|
||||
* configure.ac (SUBDIR_MAKEFILES, AC_CONFIG_FILES):
|
||||
Add admin/grammars Makefile.
|
||||
* Makefile.in (distclean, bootstrap-clean, maintainer-clean):
|
||||
Also clean admin/grammars, if present.
|
||||
|
||||
2013-11-29 Dani Moncayo <dmoncayo@gmail.com>
|
||||
|
||||
* Makefile.in (epaths-force-w32): Fix 2013-11-20 typo.
|
||||
|
@ -857,7 +857,7 @@ distclean: FRC
|
||||
cd leim && $(MAKE) $(MFLAGS) distclean
|
||||
cd lisp && $(MAKE) $(MFLAGS) distclean
|
||||
cd nextstep && $(MAKE) $(MFLAGS) distclean
|
||||
for dir in test/automated admin/unidata; do \
|
||||
for dir in test/automated admin/grammars admin/unidata; do \
|
||||
[ ! -d $$dir ] || (cd $$dir && $(MAKE) $(MFLAGS) distclean); \
|
||||
done
|
||||
${top_distclean}
|
||||
@ -879,7 +879,7 @@ bootstrap-clean: FRC
|
||||
cd leim && $(MAKE) $(MFLAGS) bootstrap-clean
|
||||
cd lisp && $(MAKE) $(MFLAGS) bootstrap-clean
|
||||
cd nextstep && $(MAKE) $(MFLAGS) maintainer-clean
|
||||
for dir in test/automated admin/unidata; do \
|
||||
for dir in test/automated admin/grammars admin/unidata; do \
|
||||
[ ! -d $$dir ] || (cd $$dir && $(MAKE) $(MFLAGS) bootstrap-clean); \
|
||||
done
|
||||
[ ! -f config.log ] || mv -f config.log config.log~
|
||||
@ -903,7 +903,7 @@ maintainer-clean: bootstrap-clean FRC
|
||||
cd src && $(MAKE) $(MFLAGS) maintainer-clean
|
||||
cd leim && $(MAKE) $(MFLAGS) maintainer-clean
|
||||
cd lisp && $(MAKE) $(MFLAGS) maintainer-clean
|
||||
for dir in test/automated admin/unidata; do \
|
||||
for dir in test/automated admin/grammars admin/unidata; do \
|
||||
[ ! -d $$dir ] || (cd $$dir && $(MAKE) $(MFLAGS) maintainer-clean); \
|
||||
done
|
||||
${top_maintainer_clean}
|
||||
|
@ -1,3 +1,11 @@
|
||||
2013-11-30 Glenn Morris <rgm@gnu.org>
|
||||
|
||||
Stop keeping (most) generated cedet grammar files in the repository.
|
||||
* grammars/README: Remove.
|
||||
* grammars/Makefile.in: New file.
|
||||
* grammars/c.by, grammars/java-tags.wy, grammars/js.wy:
|
||||
* grammars/python.wy: Update declarations to match generated outputs.
|
||||
|
||||
2013-11-28 Glenn Morris <rgm@gnu.org>
|
||||
|
||||
* unidata/unidata-gen.el (unidata-gen-files):
|
||||
|
105
admin/grammars/Makefile.in
Normal file
105
admin/grammars/Makefile.in
Normal file
@ -0,0 +1,105 @@
|
||||
### @configure_input@
|
||||
|
||||
## Copyright (C) 2013 Free Software Foundation, Inc.
|
||||
|
||||
## 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:
|
||||
|
||||
## This directory contains grammar files in Bison and Wisent,
|
||||
## used to generate the parser data in the lisp/cedet directory.
|
||||
|
||||
SHELL = @SHELL@
|
||||
|
||||
srcdir = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
top_builddir = @top_builddir@
|
||||
|
||||
EMACS = ${top_builddir}/src/emacs
|
||||
emacs = EMACSLOADPATH= "${EMACS}" -batch --no-site-file --no-site-lisp
|
||||
|
||||
make_bovine = ${emacs} -l semantic/bovine/grammar -f bovine-batch-make-parser
|
||||
make_wisent = ${emacs} -l semantic/wisent/grammar -f wisent-batch-make-parser
|
||||
|
||||
cedetdir = ${top_srcdir}/lisp/cedet
|
||||
bovinedir = ${cedetdir}/semantic/bovine
|
||||
wisentdir = ${cedetdir}/semantic/wisent
|
||||
|
||||
BOVINE = \
|
||||
${bovinedir}/c-by.el \
|
||||
${bovinedir}/make-by.el \
|
||||
${bovinedir}/scm-by.el
|
||||
|
||||
## FIXME Should include this one too:
|
||||
## ${cedetdir}/semantic/grammar-wy.el
|
||||
## but semantic/grammar.el (which is what we use to generate grammar-wy.el)
|
||||
## requires it!
|
||||
WISENT = \
|
||||
${wisentdir}/javat-wy.el \
|
||||
${wisentdir}/js-wy.el \
|
||||
${wisentdir}/python-wy.el \
|
||||
${cedetdir}/srecode/srt-wy.el
|
||||
|
||||
ALL = ${BOVINE} ${WISENT}
|
||||
|
||||
.PHONY: all bovine wisent
|
||||
|
||||
all: ${ALL}
|
||||
|
||||
bovine: ${BOVINE}
|
||||
|
||||
wisent: ${WISENT}
|
||||
|
||||
|
||||
${bovinedir}/c-by.el: ${srcdir}/c.by
|
||||
${make_bovine} -o "$@" ${srcdir}/c.by
|
||||
|
||||
${bovinedir}/make-by.el: ${srcdir}/make.by
|
||||
${make_bovine} -o "$@" ${srcdir}/make.by
|
||||
|
||||
${bovinedir}/scm-by.el: ${srcdir}/scheme.by
|
||||
${make_bovine} -o "$@" ${srcdir}/scheme.by
|
||||
|
||||
|
||||
${cedetdir}/semantic/grammar-wy.el: ${srcdir}/grammar.wy
|
||||
${make_wisent} -o "$@" ${srcdir}/grammar.wy
|
||||
|
||||
${wisentdir}/javat-wy.el: ${srcdir}/java-tags.wy
|
||||
${make_wisent} -o "$@" ${srcdir}/java-tags.wy
|
||||
|
||||
${wisentdir}/js-wy.el: ${srcdir}/js.wy
|
||||
${make_wisent} -o "$@" ${srcdir}/js.wy
|
||||
|
||||
${wisentdir}/python-wy.el: ${srcdir}/python.wy
|
||||
${make_wisent} -o "$@" ${srcdir}/python.wy
|
||||
|
||||
${cedetdir}/srecode/srt-wy.el: ${srcdir}/srecode-template.wy
|
||||
${make_wisent} -o "$@" ${srcdir}/srecode-template.wy
|
||||
|
||||
|
||||
.PHONY: distclean bootstrap-clean maintainer-clean extraclean
|
||||
|
||||
distclean:
|
||||
rm -f Makefile
|
||||
|
||||
bootstrap-clean maintainer-clean: distclean
|
||||
|
||||
## We do not normally delete the generated files, even in bootstrap.
|
||||
## Creating them does not take long, so we could easily change this.
|
||||
extraclean:
|
||||
rm -f ${ALL}
|
||||
|
||||
# Makefile.in ends here
|
@ -1,11 +0,0 @@
|
||||
This directory contains grammar files in Bison and Wisent, used to
|
||||
generate the parser data in the lisp/semantic/bovine/ and
|
||||
lisp/semantic/wisent/ directories. You can run the parser generators
|
||||
with
|
||||
|
||||
emacs -batch -Q -l semantic/bovine/grammar -f bovine-make-parsers
|
||||
emacs -batch -Q -l semantic/wisent/grammar -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
|
||||
contents of this directory, will change in a future version of Emacs.
|
@ -41,9 +41,13 @@
|
||||
%provide semantic/bovine/c-by
|
||||
|
||||
%{
|
||||
(declare-function semantic-c-reconstitute-token "semantic/bovine/c")
|
||||
(declare-function semantic-c-reconstitute-template "semantic/bovine/c")
|
||||
(declare-function semantic-expand-c-tag "semantic/bovine/c")
|
||||
(declare-function semantic-c-reconstitute-token "semantic/bovine/c"
|
||||
(tokenpart declmods typedecl))
|
||||
(declare-function semantic-c-reconstitute-template "semantic/bovine/c"
|
||||
(tag specifier))
|
||||
(declare-function semantic-expand-c-tag "semantic/bovine/c" (tag))
|
||||
(declare-function semantic-parse-region "semantic"
|
||||
(start end &optional nonterminal depth returnonerror))
|
||||
}
|
||||
|
||||
%languagemode c-mode c++-mode
|
||||
|
@ -25,6 +25,11 @@
|
||||
%package wisent-java-tags-wy
|
||||
%provide semantic/wisent/javat-wy
|
||||
|
||||
%{
|
||||
(declare-function semantic-parse-region "semantic"
|
||||
(start end &optional nonterminal depth returnonerror))
|
||||
}
|
||||
|
||||
%languagemode java-mode
|
||||
|
||||
;; The default start symbol
|
||||
|
@ -59,6 +59,12 @@
|
||||
|
||||
%package wisent-javascript-jv-wy
|
||||
%provide semantic/wisent/js-wy
|
||||
|
||||
%{
|
||||
(declare-function semantic-parse-region "semantic"
|
||||
(start end &optional nonterminal depth returnonerror))
|
||||
}
|
||||
|
||||
;; JAVE I prefere ecmascript-mode
|
||||
%languagemode ecmascript-mode javascript-mode
|
||||
|
||||
|
@ -91,8 +91,12 @@
|
||||
%provide semantic/wisent/python-wy
|
||||
|
||||
%{
|
||||
(declare-function wisent-python-reconstitute-function-tag "semantic/wisent/python")
|
||||
(declare-function wisent-python-reconstitute-class-tag "semantic/wisent/python")
|
||||
(declare-function wisent-python-reconstitute-function-tag
|
||||
"semantic/wisent/python" (tag suite))
|
||||
(declare-function wisent-python-reconstitute-class-tag "semantic/wisent/python"
|
||||
(tag))
|
||||
(declare-function semantic-parse-region "semantic"
|
||||
(start end &optional nonterminal depth returnonerror))
|
||||
}
|
||||
|
||||
%languagemode python-mode
|
||||
|
11
configure.ac
11
configure.ac
@ -4971,13 +4971,12 @@ if test -f "$srcdir/$opt_makefile.in"; then
|
||||
fi
|
||||
|
||||
|
||||
dnl admin/ may or may not be present.
|
||||
opt_makefile=admin/unidata/Makefile
|
||||
|
||||
if test -f "$srcdir/$opt_makefile.in"; then
|
||||
SUBDIR_MAKEFILES="$SUBDIR_MAKEFILES $opt_makefile"
|
||||
dnl The admin/ directory used to be excluded from tarfiles.
|
||||
if test -d $srcdir/admin; then
|
||||
SUBDIR_MAKEFILES="$SUBDIR_MAKEFILES admin/unidata/Makefile admin/grammars/Makefile"
|
||||
AC_CONFIG_FILES([admin/unidata/Makefile])
|
||||
fi
|
||||
AC_CONFIG_FILES([admin/grammars/Makefile])
|
||||
fi dnl -d admin
|
||||
|
||||
|
||||
SUBDIR_MAKEFILES_IN=`echo " ${SUBDIR_MAKEFILES}" | sed -e 's| | $(srcdir)/|g' -e 's|Makefile|Makefile.in|g'`
|
||||
|
@ -1,3 +1,9 @@
|
||||
2013-11-30 Glenn Morris <rgm@gnu.org>
|
||||
|
||||
Stop keeping (most) generated cedet grammar files in the repository.
|
||||
* Makefile.in (semantic): New.
|
||||
(compile-main): Depend on semantic.
|
||||
|
||||
2013-11-29 Stefan Monnier <monnier@iro.umontreal.ca>
|
||||
|
||||
* net/newst-reader.el (newsticker-html-renderer): Default to SHR if
|
||||
|
@ -296,7 +296,7 @@ compile-targets: $(TARGETS)
|
||||
|
||||
# Compile all the Elisp files that need it. Beware: it approximates
|
||||
# `no-byte-compile', so watch out for false-positives!
|
||||
compile-main: leim compile-clean
|
||||
compile-main: leim semantic compile-clean
|
||||
@(cd $(lisp) && $(setwins); \
|
||||
els=`echo "$$wins " | sed -e 's|/\./|/|g' -e 's|/\. | |g' -e 's| |/*.el |g'`; \
|
||||
for el in $$els; do \
|
||||
@ -320,10 +320,18 @@ compile-clean:
|
||||
fi \
|
||||
done
|
||||
|
||||
.PHONY: leim
|
||||
.PHONY: leim semantic
|
||||
leim:
|
||||
cd ../leim && $(MAKE) $(MFLAGS) all EMACS="$(EMACS)"
|
||||
|
||||
# FIXME. Yuck.
|
||||
semantic:
|
||||
case ${EMACS} in \
|
||||
.*) EMACS="../${EMACS}" ;; \
|
||||
*) EMACS="${EMACS}" ;; \
|
||||
esac; \
|
||||
cd ../admin/grammars && $(MAKE) $(MFLAGS) all EMACS="$${EMACS}"
|
||||
|
||||
# Compile all Lisp files, but don't recompile those that are up to
|
||||
# date. Some .el files don't get compiled because they set the
|
||||
# local variable no-byte-compile.
|
||||
|
@ -1,3 +1,25 @@
|
||||
2013-11-30 Glenn Morris <rgm@gnu.org>
|
||||
|
||||
Stop keeping (most) generated cedet grammar files in the repository.
|
||||
* semantic/bovine/grammar.el (bovine--make-parser-1):
|
||||
New function, split from bovine-make-parsers.
|
||||
(bovine-make-parsers): Use bovine--make-parser-1.
|
||||
(bovine-batch-make-parser): New function.
|
||||
* semantic/wisent/grammar.el (wisent--make-parser-1):
|
||||
New function, split from wisent-make-parsers.
|
||||
(wisent-make-parsers): Use wisent--make-parser-1.
|
||||
(wisent-batch-make-parser): New function.
|
||||
* semantic/db.el (semanticdb-save-all-db):
|
||||
Avoid prompting in batch mode.
|
||||
* semantic/grammar.el (semantic-grammar-footer-template):
|
||||
Disable version-control and autoloads in the output.
|
||||
(semantic-grammar-create-package):
|
||||
Add option to return nil if output is up-to-date.
|
||||
* semantic/bovine/c-by.el, semantic/bovine/make-by.el:
|
||||
* semantic/bovine/scm-by.el, semantic/wisent/javat-wy.el:
|
||||
* semantic/wisent/js-wy.el, semantic/wisent/python-wy.el:
|
||||
* srecode/srt-wy.el: Remove generated files from repository.
|
||||
|
||||
2013-11-16 Barry O'Reilly <gundaetiapo@gmail.com>
|
||||
|
||||
* semantic/fw.el (semantic-exit-on-input)
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -443,34 +443,39 @@ Menu items are appended to the common grammar menu.")
|
||||
)
|
||||
"Semantic grammar macros used in bovine grammars.")
|
||||
|
||||
(defun bovine-make-parsers ()
|
||||
"Generate Emacs' built-in Bovine-based parser files."
|
||||
(interactive)
|
||||
(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 filename copyright-end)
|
||||
(when (and packagename
|
||||
(string-match "^.*/\\(.*\\)-by\\.el\\'" packagename))
|
||||
(setq lang (match-string 1 packagename))
|
||||
(setq filename (concat lang "-by.el"))
|
||||
(with-temp-buffer
|
||||
(insert-file-contents filename)
|
||||
(setq buffer-file-name (expand-file-name filename))
|
||||
;; 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.
|
||||
(defun bovine--make-parser-1 (infile &optional outdir)
|
||||
(if outdir (setq outdir (file-name-directory (expand-file-name outdir))))
|
||||
;; It would be nicer to use a temp-buffer rather than find-file-noselect.
|
||||
;; The only thing stopping us is bovine-grammar-setupcode-builder's
|
||||
;; use of (buffer-name). Perhaps that could be changed to
|
||||
;; (file-name-nondirectory (buffer-file-name)) ?
|
||||
;; (with-temp-buffer
|
||||
;; (insert-file-contents infile)
|
||||
;; (bovine-grammar-mode)
|
||||
;; (setq buffer-file-name (expand-file-name infile))
|
||||
;; (if outdir (setq default-directory outdir))
|
||||
(let ((packagename
|
||||
;; This is with-demoted-errors.
|
||||
(condition-case err
|
||||
(with-current-buffer (find-file-noselect infile)
|
||||
(if outdir (setq default-directory outdir))
|
||||
(semantic-grammar-create-package nil t))
|
||||
(error (message "%s" (error-message-string err)) nil)))
|
||||
lang filename copyright-end)
|
||||
(when (and packagename
|
||||
(string-match "^.*/\\(.*\\)-by\\.el\\'" packagename))
|
||||
(setq lang (match-string 1 packagename))
|
||||
(setq filename (expand-file-name (concat lang "-by.el") outdir))
|
||||
(with-temp-file filename
|
||||
(insert-file-contents filename)
|
||||
;; 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
|
||||
@ -488,18 +493,50 @@ Menu items are appended to the common grammar menu.")
|
||||
;;; Commentary:
|
||||
;;
|
||||
;; This file was generated from admin/grammars/"
|
||||
lang ".by.
|
||||
lang ".by.
|
||||
|
||||
;;; Code:
|
||||
")
|
||||
(goto-char (point-min))
|
||||
(delete-region (point-min) (line-end-position))
|
||||
(insert ";;; " packagename
|
||||
" --- Generated parser support file")
|
||||
(delete-trailing-whitespace)
|
||||
(re-search-forward ";;; \\(.*\\) ends here")
|
||||
(replace-match packagename nil nil nil 1)
|
||||
(save-buffer))))))
|
||||
(goto-char (point-min))
|
||||
(delete-region (point-min) (line-end-position))
|
||||
(insert ";;; " packagename
|
||||
" --- Generated parser support file")
|
||||
(delete-trailing-whitespace)
|
||||
(re-search-forward ";;; \\(.*\\) ends here")
|
||||
(replace-match packagename nil nil nil 1)))))
|
||||
|
||||
(defun bovine-make-parsers ()
|
||||
"Generate Emacs's built-in Bovine-based parser files."
|
||||
(interactive)
|
||||
(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\\'"))
|
||||
(bovine--make-parser-1 f)))
|
||||
|
||||
|
||||
(defun bovine-batch-make-parser (&optional infile outdir)
|
||||
"Generate a Bovine parser from input INFILE, writing to OUTDIR.
|
||||
This is mainly intended for use in batch mode:
|
||||
|
||||
emacs -batch -l semantic/bovine/grammar -f bovine-make-parser-batch \\
|
||||
[-dir output-dir | -o output-file] file.by
|
||||
|
||||
If -o is supplied, only the directory part is used."
|
||||
(semantic-mode 1)
|
||||
(when (and noninteractive (not infile))
|
||||
(let (arg)
|
||||
(while command-line-args-left
|
||||
(setq arg (pop command-line-args-left))
|
||||
(cond ((string-equal arg "-dir")
|
||||
(setq outdir (pop command-line-args-left)))
|
||||
((string-equal arg "-o")
|
||||
(setq outdir (file-name-directory (pop command-line-args-left))))
|
||||
(t (setq infile arg))))))
|
||||
(or infile (error "No input file specified"))
|
||||
(or (file-readable-p infile)
|
||||
(error "Input file `%s' not readable" infile))
|
||||
(bovine--make-parser-1 infile outdir))
|
||||
|
||||
(provide 'semantic/bovine/grammar)
|
||||
|
||||
|
@ -1,391 +0,0 @@
|
||||
;;; semantic/bovine/make-by.el --- Generated parser support file
|
||||
|
||||
;; Copyright (C) 1999-2004, 2008-2013 Free Software Foundation, Inc.
|
||||
|
||||
;; 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:
|
||||
;;
|
||||
;; This file was generated from admin/grammars/make.by.
|
||||
|
||||
;;; Code:
|
||||
|
||||
(require 'semantic/lex)
|
||||
(eval-when-compile (require 'semantic/bovine))
|
||||
|
||||
;;; Prologue
|
||||
;;
|
||||
|
||||
;;; Declarations
|
||||
;;
|
||||
(defconst semantic-make-by--keyword-table
|
||||
(semantic-lex-make-keyword-table
|
||||
'(("if" . IF)
|
||||
("ifdef" . IFDEF)
|
||||
("ifndef" . IFNDEF)
|
||||
("ifeq" . IFEQ)
|
||||
("ifneq" . IFNEQ)
|
||||
("else" . ELSE)
|
||||
("endif" . ENDIF)
|
||||
("include" . INCLUDE))
|
||||
'(("include" summary "Macro: include filename1 filename2 ...")
|
||||
("ifneq" summary "Conditional: ifneq (expression) ... else ... endif")
|
||||
("ifeq" summary "Conditional: ifeq (expression) ... else ... endif")
|
||||
("ifndef" summary "Conditional: ifndef (expression) ... else ... endif")
|
||||
("ifdef" summary "Conditional: ifdef (expression) ... else ... endif")
|
||||
("endif" summary "Conditional: if (expression) ... else ... endif")
|
||||
("else" summary "Conditional: if (expression) ... else ... endif")
|
||||
("if" summary "Conditional: if (expression) ... else ... endif")))
|
||||
"Table of language keywords.")
|
||||
|
||||
(defconst semantic-make-by--token-table
|
||||
(semantic-lex-make-type-table
|
||||
'(("punctuation"
|
||||
(BACKSLASH . "\\`[\\]\\'")
|
||||
(DOLLAR . "\\`[$]\\'")
|
||||
(EQUAL . "\\`[=]\\'")
|
||||
(PLUS . "\\`[+]\\'")
|
||||
(COLON . "\\`[:]\\'")))
|
||||
'nil)
|
||||
"Table of lexical tokens.")
|
||||
|
||||
(defconst semantic-make-by--parse-table
|
||||
`(
|
||||
(bovine-toplevel
|
||||
(Makefile)
|
||||
) ;; end bovine-toplevel
|
||||
|
||||
(Makefile
|
||||
(bol
|
||||
newline
|
||||
,(semantic-lambda
|
||||
(list nil))
|
||||
)
|
||||
(bol
|
||||
variable
|
||||
,(semantic-lambda
|
||||
(nth 1 vals))
|
||||
)
|
||||
(bol
|
||||
rule
|
||||
,(semantic-lambda
|
||||
(nth 1 vals))
|
||||
)
|
||||
(bol
|
||||
conditional
|
||||
,(semantic-lambda
|
||||
(nth 1 vals))
|
||||
)
|
||||
(bol
|
||||
include
|
||||
,(semantic-lambda
|
||||
(nth 1 vals))
|
||||
)
|
||||
(whitespace
|
||||
,(semantic-lambda
|
||||
(list nil))
|
||||
)
|
||||
(newline
|
||||
,(semantic-lambda
|
||||
(list nil))
|
||||
)
|
||||
) ;; end Makefile
|
||||
|
||||
(variable
|
||||
(symbol
|
||||
opt-whitespace
|
||||
equals
|
||||
opt-whitespace
|
||||
element-list
|
||||
,(semantic-lambda
|
||||
(semantic-tag-new-variable
|
||||
(nth 0 vals) nil
|
||||
(nth 4 vals)))
|
||||
)
|
||||
) ;; end variable
|
||||
|
||||
(rule
|
||||
(targets
|
||||
opt-whitespace
|
||||
colons
|
||||
opt-whitespace
|
||||
element-list
|
||||
commands
|
||||
,(semantic-lambda
|
||||
(semantic-tag-new-function
|
||||
(nth 0 vals) nil
|
||||
(nth 4 vals)))
|
||||
)
|
||||
) ;; end rule
|
||||
|
||||
(targets
|
||||
(target
|
||||
opt-whitespace
|
||||
targets
|
||||
,(semantic-lambda
|
||||
(list
|
||||
(car
|
||||
(nth 0 vals))
|
||||
(car
|
||||
(nth 2 vals))))
|
||||
)
|
||||
(target
|
||||
,(semantic-lambda
|
||||
(list
|
||||
(car
|
||||
(nth 0 vals))))
|
||||
)
|
||||
) ;; end targets
|
||||
|
||||
(target
|
||||
(sub-target
|
||||
target
|
||||
,(semantic-lambda
|
||||
(list
|
||||
(concat
|
||||
(car
|
||||
(nth 0 vals))
|
||||
(car
|
||||
(nth 2 vals)))))
|
||||
)
|
||||
(sub-target
|
||||
,(semantic-lambda
|
||||
(list
|
||||
(car
|
||||
(nth 0 vals))))
|
||||
)
|
||||
) ;; end target
|
||||
|
||||
(sub-target
|
||||
(symbol)
|
||||
(string)
|
||||
(varref)
|
||||
) ;; end sub-target
|
||||
|
||||
(conditional
|
||||
(IF
|
||||
some-whitespace
|
||||
symbol
|
||||
newline
|
||||
,(semantic-lambda
|
||||
(list nil))
|
||||
)
|
||||
(IFDEF
|
||||
some-whitespace
|
||||
symbol
|
||||
newline
|
||||
,(semantic-lambda
|
||||
(list nil))
|
||||
)
|
||||
(IFNDEF
|
||||
some-whitespace
|
||||
symbol
|
||||
newline
|
||||
,(semantic-lambda
|
||||
(list nil))
|
||||
)
|
||||
(IFEQ
|
||||
some-whitespace
|
||||
expression
|
||||
newline
|
||||
,(semantic-lambda
|
||||
(list nil))
|
||||
)
|
||||
(IFNEQ
|
||||
some-whitespace
|
||||
expression
|
||||
newline
|
||||
,(semantic-lambda
|
||||
(list nil))
|
||||
)
|
||||
(ELSE
|
||||
newline
|
||||
,(semantic-lambda
|
||||
(list nil))
|
||||
)
|
||||
(ENDIF
|
||||
newline
|
||||
,(semantic-lambda
|
||||
(list nil))
|
||||
)
|
||||
) ;; end conditional
|
||||
|
||||
(expression
|
||||
(semantic-list)
|
||||
) ;; end expression
|
||||
|
||||
(include
|
||||
(INCLUDE
|
||||
some-whitespace
|
||||
element-list
|
||||
,(semantic-lambda
|
||||
(semantic-tag-new-include
|
||||
(nth 2 vals) nil))
|
||||
)
|
||||
) ;; end include
|
||||
|
||||
(equals
|
||||
(punctuation
|
||||
"\\`[:]\\'"
|
||||
punctuation
|
||||
"\\`[=]\\'"
|
||||
,(semantic-lambda)
|
||||
)
|
||||
(punctuation
|
||||
"\\`[+]\\'"
|
||||
punctuation
|
||||
"\\`[=]\\'"
|
||||
,(semantic-lambda)
|
||||
)
|
||||
(punctuation
|
||||
"\\`[=]\\'"
|
||||
,(semantic-lambda)
|
||||
)
|
||||
) ;; end equals
|
||||
|
||||
(colons
|
||||
(punctuation
|
||||
"\\`[:]\\'"
|
||||
punctuation
|
||||
"\\`[:]\\'"
|
||||
,(semantic-lambda)
|
||||
)
|
||||
(punctuation
|
||||
"\\`[:]\\'"
|
||||
,(semantic-lambda)
|
||||
)
|
||||
) ;; end colons
|
||||
|
||||
(element-list
|
||||
(elements
|
||||
newline
|
||||
,(semantic-lambda
|
||||
(nth 0 vals))
|
||||
)
|
||||
) ;; end element-list
|
||||
|
||||
(elements
|
||||
(element
|
||||
some-whitespace
|
||||
elements
|
||||
,(semantic-lambda
|
||||
(nth 0 vals)
|
||||
(nth 2 vals))
|
||||
)
|
||||
(element
|
||||
,(semantic-lambda
|
||||
(nth 0 vals))
|
||||
)
|
||||
( ;;EMPTY
|
||||
)
|
||||
) ;; end elements
|
||||
|
||||
(element
|
||||
(sub-element
|
||||
element
|
||||
,(semantic-lambda
|
||||
(list
|
||||
(concat
|
||||
(car
|
||||
(nth 0 vals))
|
||||
(car
|
||||
(nth 1 vals)))))
|
||||
)
|
||||
( ;;EMPTY
|
||||
)
|
||||
) ;; end element
|
||||
|
||||
(sub-element
|
||||
(symbol)
|
||||
(string)
|
||||
(punctuation)
|
||||
(semantic-list
|
||||
,(semantic-lambda
|
||||
(list
|
||||
(buffer-substring-no-properties
|
||||
(identity start)
|
||||
(identity end))))
|
||||
)
|
||||
) ;; end sub-element
|
||||
|
||||
(varref
|
||||
(punctuation
|
||||
"\\`[$]\\'"
|
||||
semantic-list
|
||||
,(semantic-lambda
|
||||
(list
|
||||
(buffer-substring-no-properties
|
||||
(identity start)
|
||||
(identity end))))
|
||||
)
|
||||
) ;; end varref
|
||||
|
||||
(commands
|
||||
(bol
|
||||
shell-command
|
||||
newline
|
||||
commands
|
||||
,(semantic-lambda
|
||||
(list
|
||||
(nth 0 vals))
|
||||
(nth 1 vals))
|
||||
)
|
||||
( ;;EMPTY
|
||||
,(semantic-lambda)
|
||||
)
|
||||
) ;; end commands
|
||||
|
||||
(opt-whitespace
|
||||
(some-whitespace
|
||||
,(semantic-lambda
|
||||
(list nil))
|
||||
)
|
||||
( ;;EMPTY
|
||||
)
|
||||
) ;; end opt-whitespace
|
||||
|
||||
(some-whitespace
|
||||
(whitespace
|
||||
some-whitespace
|
||||
,(semantic-lambda
|
||||
(list nil))
|
||||
)
|
||||
(whitespace
|
||||
,(semantic-lambda
|
||||
(list nil))
|
||||
)
|
||||
) ;; end some-whitespace
|
||||
)
|
||||
"Parser table.")
|
||||
|
||||
(defun semantic-make-by--install-parser ()
|
||||
"Setup the Semantic Parser."
|
||||
(setq semantic--parse-table semantic-make-by--parse-table
|
||||
semantic-debug-parser-source "make.by"
|
||||
semantic-debug-parser-class 'semantic-bovine-debug-parser
|
||||
semantic-flex-keywords-obarray semantic-make-by--keyword-table
|
||||
))
|
||||
|
||||
|
||||
;;; Analyzers
|
||||
;;
|
||||
|
||||
;;; Epilogue
|
||||
;;
|
||||
|
||||
(provide 'semantic/bovine/make-by)
|
||||
|
||||
;;; semantic/bovine/make-by.el ends here
|
@ -1,196 +0,0 @@
|
||||
;;; semantic/bovine/scm-by.el --- Generated parser support file
|
||||
|
||||
;; Copyright (C) 2001, 2003, 2009-2013 Free Software Foundation, Inc.
|
||||
|
||||
;; 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:
|
||||
;;
|
||||
;; This file was generated from admin/grammars/scm.by.
|
||||
|
||||
;;; Code:
|
||||
|
||||
(require 'semantic/lex)
|
||||
(eval-when-compile (require 'semantic/bovine))
|
||||
|
||||
;;; Prologue
|
||||
;;
|
||||
|
||||
;;; Declarations
|
||||
;;
|
||||
(defconst semantic-scm-by--keyword-table
|
||||
(semantic-lex-make-keyword-table
|
||||
'(("define" . DEFINE)
|
||||
("define-module" . DEFINE-MODULE)
|
||||
("load" . LOAD))
|
||||
'(("load" summary "Function: (load \"filename\")")
|
||||
("define-module" summary "Function: (define-module (name arg1 ...)) ")
|
||||
("define" summary "Function: (define symbol expression)")))
|
||||
"Table of language keywords.")
|
||||
|
||||
(defconst semantic-scm-by--token-table
|
||||
(semantic-lex-make-type-table
|
||||
'(("close-paren"
|
||||
(CLOSEPAREN . ")"))
|
||||
("open-paren"
|
||||
(OPENPAREN . "(")))
|
||||
'nil)
|
||||
"Table of lexical tokens.")
|
||||
|
||||
(defconst semantic-scm-by--parse-table
|
||||
`(
|
||||
(bovine-toplevel
|
||||
(scheme)
|
||||
) ;; end bovine-toplevel
|
||||
|
||||
(scheme
|
||||
(semantic-list
|
||||
,(lambda (vals start end)
|
||||
(semantic-bovinate-from-nonterminal
|
||||
(car
|
||||
(nth 0 vals))
|
||||
(cdr
|
||||
(nth 0 vals))
|
||||
'scheme-list))
|
||||
)
|
||||
) ;; end scheme
|
||||
|
||||
(scheme-list
|
||||
(open-paren
|
||||
"("
|
||||
scheme-in-list
|
||||
close-paren
|
||||
")"
|
||||
,(semantic-lambda
|
||||
(nth 1 vals))
|
||||
)
|
||||
) ;; end scheme-list
|
||||
|
||||
(scheme-in-list
|
||||
(DEFINE
|
||||
symbol
|
||||
expression
|
||||
,(semantic-lambda
|
||||
(semantic-tag-new-variable
|
||||
(nth 1 vals) nil
|
||||
(nth 2 vals)))
|
||||
)
|
||||
(DEFINE
|
||||
name-args
|
||||
opt-doc
|
||||
sequence
|
||||
,(semantic-lambda
|
||||
(semantic-tag-new-function
|
||||
(car
|
||||
(nth 1 vals)) nil
|
||||
(cdr
|
||||
(nth 1 vals))))
|
||||
)
|
||||
(DEFINE-MODULE
|
||||
name-args
|
||||
,(semantic-lambda
|
||||
(semantic-tag-new-package
|
||||
(nth
|
||||
(length
|
||||
(nth 1 vals))
|
||||
(nth 1 vals)) nil))
|
||||
)
|
||||
(LOAD
|
||||
string
|
||||
,(semantic-lambda
|
||||
(semantic-tag-new-include
|
||||
(file-name-nondirectory
|
||||
(read
|
||||
(nth 1 vals)))
|
||||
(read
|
||||
(nth 1 vals))))
|
||||
)
|
||||
(symbol
|
||||
,(semantic-lambda
|
||||
(semantic-tag-new-code
|
||||
(nth 0 vals) nil))
|
||||
)
|
||||
) ;; end scheme-in-list
|
||||
|
||||
(name-args
|
||||
(semantic-list
|
||||
,(lambda (vals start end)
|
||||
(semantic-bovinate-from-nonterminal
|
||||
(car
|
||||
(nth 0 vals))
|
||||
(cdr
|
||||
(nth 0 vals))
|
||||
'name-arg-expand))
|
||||
)
|
||||
) ;; end name-args
|
||||
|
||||
(name-arg-expand
|
||||
(open-paren
|
||||
name-arg-expand
|
||||
,(semantic-lambda
|
||||
(nth 1 vals))
|
||||
)
|
||||
(symbol
|
||||
name-arg-expand
|
||||
,(semantic-lambda
|
||||
(cons
|
||||
(nth 0 vals)
|
||||
(nth 1 vals)))
|
||||
)
|
||||
( ;;EMPTY
|
||||
,(semantic-lambda)
|
||||
)
|
||||
) ;; end name-arg-expand
|
||||
|
||||
(opt-doc
|
||||
(string)
|
||||
( ;;EMPTY
|
||||
)
|
||||
) ;; end opt-doc
|
||||
|
||||
(sequence
|
||||
(expression
|
||||
sequence)
|
||||
(expression)
|
||||
) ;; end sequence
|
||||
|
||||
(expression
|
||||
(symbol)
|
||||
(semantic-list)
|
||||
(string)
|
||||
(number)
|
||||
) ;; end expression
|
||||
)
|
||||
"Parser table.")
|
||||
|
||||
(defun semantic-scm-by--install-parser ()
|
||||
"Setup the Semantic Parser."
|
||||
(setq semantic--parse-table semantic-scm-by--parse-table
|
||||
semantic-debug-parser-source "scheme.by"
|
||||
semantic-debug-parser-class 'semantic-bovine-debug-parser
|
||||
semantic-flex-keywords-obarray semantic-scm-by--keyword-table
|
||||
))
|
||||
|
||||
|
||||
;;; Analyzers
|
||||
;;
|
||||
|
||||
;;; Epilogue
|
||||
;;
|
||||
|
||||
(provide 'semantic/bovine/scm-by)
|
||||
|
||||
;;; semantic/bovine/scm-by.el ends here
|
@ -697,7 +697,7 @@ form."
|
||||
(interactive)
|
||||
(unless noninteractive
|
||||
(message "Saving tag summaries..."))
|
||||
(let ((semanticdb--inhibit-make-directory nil))
|
||||
(let ((semanticdb--inhibit-make-directory noninteractive))
|
||||
(mapc 'semanticdb-save-db semanticdb-database-list))
|
||||
(unless noninteractive
|
||||
(message "Saving tag summaries...done")))
|
||||
|
@ -33,6 +33,8 @@
|
||||
(require 'semantic/wisent)
|
||||
(require 'semantic/ctxt)
|
||||
(require 'semantic/format)
|
||||
;; FIXME this is a generated file, but we need to load this file to
|
||||
;; generate it!
|
||||
(require 'semantic/grammar-wy)
|
||||
(require 'semantic/idle)
|
||||
(require 'help-fns)
|
||||
@ -605,6 +607,11 @@ The symbols in the template are local variables in
|
||||
|
||||
\(provide '" libr ")
|
||||
|
||||
;; Local Variables:
|
||||
;; version-control: never
|
||||
;; no-update-autoloads: t
|
||||
;; End:
|
||||
|
||||
;;; " file " ends here
|
||||
")
|
||||
"Generated footer template.
|
||||
@ -822,9 +829,10 @@ Block definitions are read from the current table of lexical types."
|
||||
(noninteractive)
|
||||
noninteractive))
|
||||
|
||||
(defun semantic-grammar-create-package (&optional force)
|
||||
(defun semantic-grammar-create-package (&optional force uptodate)
|
||||
"Create package Lisp code from grammar in current buffer.
|
||||
Does nothing if the Lisp code seems up to date.
|
||||
If the Lisp code seems up to date, do nothing (if UPTODATE
|
||||
is non-nil, return nil in such cases).
|
||||
If optional argument FORCE is non-nil, unconditionally re-generate the
|
||||
Lisp code."
|
||||
(interactive "P")
|
||||
@ -854,7 +862,12 @@ Lisp code."
|
||||
(file-newer-than-file-p
|
||||
(buffer-file-name semantic--grammar-output-buffer)
|
||||
(buffer-file-name semantic--grammar-input-buffer)))
|
||||
(message "Package `%s' is up to date." semantic--grammar-package)
|
||||
(progn
|
||||
(message "Package `%s' is up to date." semantic--grammar-package)
|
||||
;; It would be better if this were always the case, IMO,
|
||||
;; but the (unspecified) return value of this function is
|
||||
;; assumed to be non-nil in some places, it seems.
|
||||
(if uptodate (setq output nil)))
|
||||
;; Create the package
|
||||
(set-buffer semantic--grammar-output-buffer)
|
||||
;; Use Unix EOLs, so that the file is portable to all platforms.
|
||||
@ -1914,6 +1927,7 @@ Optional argument COLOR determines if color is added to the text."
|
||||
|
||||
(provide 'semantic/grammar)
|
||||
|
||||
|
||||
;; Local variables:
|
||||
;; generated-autoload-load-name: "semantic/grammar"
|
||||
;; End:
|
||||
|
@ -473,6 +473,54 @@ Menu items are appended to the common grammar menu.")
|
||||
\;; 2009, 2010 Python Software Foundation; All Rights Reserved"
|
||||
,wisent-make-parsers--python-license)))
|
||||
|
||||
;; Cf bovine--make-parser-1.
|
||||
(defun wisent--make-parser-1 (infile &optional outdir)
|
||||
(if outdir (setq outdir (file-name-directory (expand-file-name outdir))))
|
||||
(let ((packagename
|
||||
;; This is with-demoted-errors.
|
||||
(condition-case err
|
||||
(with-current-buffer (find-file-noselect infile)
|
||||
(if outdir (setq default-directory outdir))
|
||||
(semantic-grammar-create-package nil t))
|
||||
(error (message "%s" (error-message-string err)) nil)))
|
||||
output-data)
|
||||
(when (setq output-data (assoc packagename wisent-make-parsers--parser-file-name))
|
||||
(let ((additional-copyright (nth 1 output-data))
|
||||
(additional-license (nth 2 output-data))
|
||||
(filename (expand-file-name
|
||||
(progn (string-match ".*/\\(.*\\)" packagename)
|
||||
(match-string 1 packagename))
|
||||
outdir))
|
||||
copyright-end)
|
||||
;; Touch up the generated parsers for Emacs integration.
|
||||
(with-temp-file filename
|
||||
(insert-file-contents filename)
|
||||
;; Fix copyright header:
|
||||
(goto-char (point-min))
|
||||
(when additional-copyright
|
||||
(re-search-forward "Copyright (C).*$")
|
||||
(insert "\n;; " additional-copyright))
|
||||
(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 wisent-make-parsers--emacs-license)
|
||||
(insert "\n\n;;; Commentary:
|
||||
;;
|
||||
;; This file was generated from admin/grammars/"
|
||||
(file-name-nondirectory infile) ".")
|
||||
(when additional-license
|
||||
(insert "\n" additional-license))
|
||||
(insert "\n\n;;; Code:\n")
|
||||
(goto-char (point-min))
|
||||
(delete-region (point-min) (line-end-position))
|
||||
(insert ";;; " packagename
|
||||
" --- Generated parser support file")
|
||||
(re-search-forward ";;; \\(.*\\) ends here")
|
||||
(replace-match packagename nil nil nil 1)
|
||||
(delete-trailing-whitespace))))))
|
||||
|
||||
(defun wisent-make-parsers ()
|
||||
"Generate Emacs' built-in Wisent-based parser files."
|
||||
(interactive)
|
||||
@ -480,46 +528,32 @@ Menu items are appended to the common grammar menu.")
|
||||
;; Loop through each .wy file in current directory, and run
|
||||
;; `semantic-grammar-batch-build-one-package' to build the grammar.
|
||||
(dolist (f (directory-files default-directory nil "\\.wy\\'"))
|
||||
(let ((packagename
|
||||
(condition-case err
|
||||
(with-current-buffer (find-file-noselect f)
|
||||
(semantic-grammar-create-package))
|
||||
(error (message "%s" (error-message-string err)) nil)))
|
||||
output-data)
|
||||
(when (setq output-data (assoc packagename wisent-make-parsers--parser-file-name))
|
||||
(let ((additional-copyright (nth 1 output-data))
|
||||
(additional-license (nth 2 output-data))
|
||||
(filename (progn (string-match ".*/\\(.*\\)" packagename) (match-string 1 packagename)))
|
||||
copyright-end)
|
||||
;; Touch up the generated parsers for Emacs integration.
|
||||
(with-temp-buffer
|
||||
(insert-file-contents filename)
|
||||
;; Fix copyright header:
|
||||
(goto-char (point-min))
|
||||
(when additional-copyright
|
||||
(re-search-forward "Copyright (C).*$")
|
||||
(insert "\n;; " additional-copyright))
|
||||
(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 wisent-make-parsers--emacs-license)
|
||||
(insert "\n\n;;; Commentary:
|
||||
;;
|
||||
;; This file was generated from admin/grammars/"
|
||||
f ".")
|
||||
(when additional-license
|
||||
(insert "\n" additional-license))
|
||||
(insert "\n\n;;; Code:\n")
|
||||
(goto-char (point-min))
|
||||
(delete-region (point-min) (line-end-position))
|
||||
(insert ";;; " packagename
|
||||
" --- Generated parser support file")
|
||||
(re-search-forward ";;; \\(.*\\) ends here")
|
||||
(replace-match packagename nil nil nil 1)
|
||||
(delete-trailing-whitespace)
|
||||
(write-region nil nil (expand-file-name filename))))))))
|
||||
(wisent--make-parser-1 f)))
|
||||
|
||||
|
||||
(defun wisent-batch-make-parser (&optional infile outdir)
|
||||
"Generate a Wisent parser from input INFILE, writing to OUTDIR.
|
||||
This is mainly intended for use in batch mode:
|
||||
|
||||
emacs -batch -l semantic/wisent/grammar -f wisent-make-parser-batch \\
|
||||
[-dir output-dir | -o output-file] file.by
|
||||
|
||||
If -o is supplied, only the directory part is used."
|
||||
(semantic-mode 1)
|
||||
(when (and noninteractive (not infile))
|
||||
(let (arg)
|
||||
(while command-line-args-left
|
||||
(setq arg (pop command-line-args-left))
|
||||
(cond ((string-equal arg "-dir")
|
||||
(setq outdir (pop command-line-args-left)))
|
||||
((string-equal arg "-o")
|
||||
(setq outdir (file-name-directory (pop command-line-args-left))))
|
||||
(t (setq infile arg))))))
|
||||
(or infile (error "No input file specified"))
|
||||
(or (file-readable-p infile)
|
||||
(error "Input file `%s' not readable" infile))
|
||||
(wisent--make-parser-1 infile outdir))
|
||||
|
||||
|
||||
(provide 'semantic/wisent/grammar)
|
||||
|
||||
|
@ -1,688 +0,0 @@
|
||||
;;; semantic/wisent/javat-wy.el --- Generated parser support file
|
||||
|
||||
;; Copyright (C) 2002-2013 Free Software Foundation, Inc.
|
||||
|
||||
;; 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:
|
||||
;;
|
||||
;; This file was generated from admin/grammars/java-tags.wy.
|
||||
|
||||
;;; Code:
|
||||
|
||||
(require 'semantic/lex)
|
||||
(eval-when-compile (require 'semantic/bovine))
|
||||
|
||||
;;; Prologue
|
||||
;;
|
||||
(declare-function semantic-parse-region "semantic"
|
||||
(start end &optional nonterminal depth returnonerror))
|
||||
|
||||
;;; Declarations
|
||||
;;
|
||||
(defconst wisent-java-tags-wy--keyword-table
|
||||
(semantic-lex-make-keyword-table
|
||||
'(("abstract" . ABSTRACT)
|
||||
("boolean" . BOOLEAN)
|
||||
("break" . BREAK)
|
||||
("byte" . BYTE)
|
||||
("case" . CASE)
|
||||
("catch" . CATCH)
|
||||
("char" . CHAR)
|
||||
("class" . CLASS)
|
||||
("const" . CONST)
|
||||
("continue" . CONTINUE)
|
||||
("default" . DEFAULT)
|
||||
("do" . DO)
|
||||
("double" . DOUBLE)
|
||||
("else" . ELSE)
|
||||
("extends" . EXTENDS)
|
||||
("final" . FINAL)
|
||||
("finally" . FINALLY)
|
||||
("float" . FLOAT)
|
||||
("for" . FOR)
|
||||
("goto" . GOTO)
|
||||
("if" . IF)
|
||||
("implements" . IMPLEMENTS)
|
||||
("import" . IMPORT)
|
||||
("instanceof" . INSTANCEOF)
|
||||
("int" . INT)
|
||||
("interface" . INTERFACE)
|
||||
("long" . LONG)
|
||||
("native" . NATIVE)
|
||||
("new" . NEW)
|
||||
("package" . PACKAGE)
|
||||
("private" . PRIVATE)
|
||||
("protected" . PROTECTED)
|
||||
("public" . PUBLIC)
|
||||
("return" . RETURN)
|
||||
("short" . SHORT)
|
||||
("static" . STATIC)
|
||||
("strictfp" . STRICTFP)
|
||||
("super" . SUPER)
|
||||
("switch" . SWITCH)
|
||||
("synchronized" . SYNCHRONIZED)
|
||||
("this" . THIS)
|
||||
("throw" . THROW)
|
||||
("throws" . THROWS)
|
||||
("transient" . TRANSIENT)
|
||||
("try" . TRY)
|
||||
("void" . VOID)
|
||||
("volatile" . VOLATILE)
|
||||
("while" . WHILE)
|
||||
("@author" . _AUTHOR)
|
||||
("@version" . _VERSION)
|
||||
("@param" . _PARAM)
|
||||
("@return" . _RETURN)
|
||||
("@exception" . _EXCEPTION)
|
||||
("@throws" . _THROWS)
|
||||
("@see" . _SEE)
|
||||
("@since" . _SINCE)
|
||||
("@serial" . _SERIAL)
|
||||
("@serialData" . _SERIALDATA)
|
||||
("@serialField" . _SERIALFIELD)
|
||||
("@deprecated" . _DEPRECATED))
|
||||
'(("@deprecated" javadoc
|
||||
(seq 12 usage
|
||||
(type function variable)
|
||||
opt t))
|
||||
("@serialField" javadoc
|
||||
(seq 11 usage
|
||||
(variable)
|
||||
opt t))
|
||||
("@serialData" javadoc
|
||||
(seq 10 usage
|
||||
(function)
|
||||
opt t))
|
||||
("@serial" javadoc
|
||||
(seq 9 usage
|
||||
(variable)
|
||||
opt t))
|
||||
("@since" javadoc
|
||||
(seq 8 usage
|
||||
(type function variable)
|
||||
opt t))
|
||||
("@see" javadoc
|
||||
(seq 7 usage
|
||||
(type function variable)
|
||||
opt t with-ref t))
|
||||
("@throws" javadoc
|
||||
(seq 6 usage
|
||||
(function)
|
||||
with-name t))
|
||||
("@exception" javadoc
|
||||
(seq 5 usage
|
||||
(function)
|
||||
with-name t))
|
||||
("@return" javadoc
|
||||
(seq 4 usage
|
||||
(function)))
|
||||
("@param" javadoc
|
||||
(seq 3 usage
|
||||
(function)
|
||||
with-name t))
|
||||
("@version" javadoc
|
||||
(seq 2 usage
|
||||
(type)))
|
||||
("@author" javadoc
|
||||
(seq 1 usage
|
||||
(type)))
|
||||
("while" summary "while (<expr>) <stmt> | do <stmt> while (<expr>);")
|
||||
("volatile" summary "Field declaration modifier: volatile <type> <name> ...")
|
||||
("void" summary "Method return type: void <name> ...")
|
||||
("try" summary "try {<stmts>} [catch(<parm>) {<stmts>} ...] [finally {<stmts>}]")
|
||||
("transient" summary "Field declaration modifier: transient <type> <name> ...")
|
||||
("throws" summary "Method|Constructor declaration: throws <classType>, ...")
|
||||
("throw" summary "throw <expr> ;")
|
||||
("synchronized" summary "synchronized (<expr>) ... | Method decl. modifier: synchronized <type> <name> ...")
|
||||
("switch" summary "switch(<expr>) {[case <const-expr>: <stmts> ...] [default: <stmts>]}")
|
||||
("strictfp" summary "Declaration modifier: strictfp {class|interface|<type>} <name> ...")
|
||||
("static" summary "Declaration modifier: static {class|interface|<type>} <name> ...")
|
||||
("short" summary "Integral primitive type (-32768 to 32767)")
|
||||
("return" summary "return [<expr>] ;")
|
||||
("public" summary "Access level modifier: public {class|interface|<type>} <name> ...")
|
||||
("protected" summary "Access level modifier: protected {class|interface|<type>} <name> ...")
|
||||
("private" summary "Access level modifier: private {class|interface|<type>} <name> ...")
|
||||
("package" summary "Package declaration: package <name>")
|
||||
("native" summary "Method declaration modifier: native <type> <name> ...")
|
||||
("long" summary "Integral primitive type (-9223372036854775808 to 9223372036854775807)")
|
||||
("interface" summary "Interface declaration: interface <name>")
|
||||
("int" summary "Integral primitive type (-2147483648 to 2147483647)")
|
||||
("import" summary "Import package declarations: import <package>")
|
||||
("implements" summary "Class SuperInterfaces declaration: implements <name> [, ...]")
|
||||
("if" summary "if (<expr>) <stmt> [else <stmt>]")
|
||||
("goto" summary "Unused reserved word")
|
||||
("for" summary "for ([<init-expr>]; [<expr>]; [<update-expr>]) <stmt>")
|
||||
("float" summary "Primitive floating-point type (single-precision 32-bit IEEE 754)")
|
||||
("finally" summary "try {<stmts>} ... finally {<stmts>}")
|
||||
("final" summary "Class|Member declaration modifier: final {class|<type>} <name> ...")
|
||||
("extends" summary "SuperClass|SuperInterfaces declaration: extends <name> [, ...]")
|
||||
("else" summary "if (<expr>) <stmt> else <stmt>")
|
||||
("double" summary "Primitive floating-point type (double-precision 64-bit IEEE 754)")
|
||||
("do" summary "do <stmt> while (<expr>);")
|
||||
("default" summary "switch(<expr>) { ... default: <stmts>}")
|
||||
("continue" summary "continue [<label>] ;")
|
||||
("const" summary "Unused reserved word")
|
||||
("class" summary "Class declaration: class <name>")
|
||||
("char" summary "Integral primitive type (0 to 65535)")
|
||||
("catch" summary "try {<stmts>} catch(<parm>) {<stmts>} ... ")
|
||||
("case" summary "switch(<expr>) {case <const-expr>: <stmts> ... }")
|
||||
("byte" summary "Integral primitive type (-128 to 127)")
|
||||
("break" summary "break [<label>] ;")
|
||||
("boolean" summary "Primitive logical quantity type (true or false)")
|
||||
("abstract" summary "Class|Method declaration modifier: abstract {class|<type>} <name> ...")))
|
||||
"Table of language keywords.")
|
||||
|
||||
(defconst wisent-java-tags-wy--token-table
|
||||
(semantic-lex-make-type-table
|
||||
'(("unicode"
|
||||
(unicodecharacter))
|
||||
("number"
|
||||
(NUMBER_LITERAL))
|
||||
("string"
|
||||
(STRING_LITERAL))
|
||||
("symbol"
|
||||
(IDENTIFIER))
|
||||
("punctuation"
|
||||
(COMP . "~")
|
||||
(OROR . "||")
|
||||
(OREQ . "|=")
|
||||
(OR . "|")
|
||||
(XOREQ . "^=")
|
||||
(XOR . "^")
|
||||
(QUESTION . "?")
|
||||
(URSHIFTEQ . ">>>=")
|
||||
(URSHIFT . ">>>")
|
||||
(RSHIFTEQ . ">>=")
|
||||
(RSHIFT . ">>")
|
||||
(GTEQ . ">=")
|
||||
(GT . ">")
|
||||
(EQEQ . "==")
|
||||
(EQ . "=")
|
||||
(LTEQ . "<=")
|
||||
(LSHIFTEQ . "<<=")
|
||||
(LSHIFT . "<<")
|
||||
(LT . "<")
|
||||
(SEMICOLON . ";")
|
||||
(COLON . ":")
|
||||
(DIVEQ . "/=")
|
||||
(DIV . "/")
|
||||
(DOT . ".")
|
||||
(MINUSEQ . "-=")
|
||||
(MINUSMINUS . "--")
|
||||
(MINUS . "-")
|
||||
(COMMA . ",")
|
||||
(PLUSEQ . "+=")
|
||||
(PLUSPLUS . "++")
|
||||
(PLUS . "+")
|
||||
(MULTEQ . "*=")
|
||||
(MULT . "*")
|
||||
(ANDEQ . "&=")
|
||||
(ANDAND . "&&")
|
||||
(AND . "&")
|
||||
(MODEQ . "%=")
|
||||
(MOD . "%")
|
||||
(NOTEQ . "!=")
|
||||
(NOT . "!"))
|
||||
("close-paren"
|
||||
(RBRACK . "]")
|
||||
(RBRACE . "}")
|
||||
(RPAREN . ")"))
|
||||
("open-paren"
|
||||
(LBRACK . "[")
|
||||
(LBRACE . "{")
|
||||
(LPAREN . "("))
|
||||
("block"
|
||||
(BRACK_BLOCK . "(LBRACK RBRACK)")
|
||||
(BRACE_BLOCK . "(LBRACE RBRACE)")
|
||||
(PAREN_BLOCK . "(LPAREN RPAREN)")))
|
||||
'(("keyword" :declared t)
|
||||
("unicode" syntax "\\\\u[0-9a-f][0-9a-f][0-9a-f][0-9a-f]")
|
||||
("unicode" :declared t)
|
||||
("number" :declared t)
|
||||
("string" :declared t)
|
||||
("symbol" :declared t)
|
||||
("punctuation" :declared t)
|
||||
("block" :declared t)))
|
||||
"Table of lexical tokens.")
|
||||
|
||||
(defconst wisent-java-tags-wy--parse-table
|
||||
(progn
|
||||
(eval-when-compile
|
||||
(require 'semantic/wisent/comp))
|
||||
(wisent-compile-grammar
|
||||
'((PAREN_BLOCK BRACE_BLOCK BRACK_BLOCK LPAREN RPAREN LBRACE RBRACE LBRACK RBRACK NOT NOTEQ MOD MODEQ AND ANDAND ANDEQ MULT MULTEQ PLUS PLUSPLUS PLUSEQ COMMA MINUS MINUSMINUS MINUSEQ DOT DIV DIVEQ COLON SEMICOLON LT LSHIFT LSHIFTEQ LTEQ EQ EQEQ GT GTEQ RSHIFT RSHIFTEQ URSHIFT URSHIFTEQ QUESTION XOR XOREQ OR OREQ OROR COMP IDENTIFIER STRING_LITERAL NUMBER_LITERAL unicodecharacter ABSTRACT BOOLEAN BREAK BYTE CASE CATCH CHAR CLASS CONST CONTINUE DEFAULT DO DOUBLE ELSE EXTENDS FINAL FINALLY FLOAT FOR GOTO IF IMPLEMENTS IMPORT INSTANCEOF INT INTERFACE LONG NATIVE NEW PACKAGE PRIVATE PROTECTED PUBLIC RETURN SHORT STATIC STRICTFP SUPER SWITCH SYNCHRONIZED THIS THROW THROWS TRANSIENT TRY VOID VOLATILE WHILE _AUTHOR _VERSION _PARAM _RETURN _EXCEPTION _THROWS _SEE _SINCE _SERIAL _SERIALDATA _SERIALFIELD _DEPRECATED)
|
||||
nil
|
||||
(compilation_unit
|
||||
((package_declaration))
|
||||
((import_declaration))
|
||||
((type_declaration)))
|
||||
(package_declaration
|
||||
((PACKAGE qualified_name SEMICOLON)
|
||||
(wisent-raw-tag
|
||||
(semantic-tag-new-package $2 nil))))
|
||||
(import_declaration
|
||||
((IMPORT qualified_name SEMICOLON)
|
||||
(wisent-raw-tag
|
||||
(semantic-tag-new-include $2 nil)))
|
||||
((IMPORT qualified_name DOT MULT SEMICOLON)
|
||||
(wisent-raw-tag
|
||||
(semantic-tag-new-include
|
||||
(concat $2 $3 $4)
|
||||
nil))))
|
||||
(type_declaration
|
||||
((SEMICOLON)
|
||||
nil)
|
||||
((class_declaration))
|
||||
((interface_declaration)))
|
||||
(class_declaration
|
||||
((modifiers_opt CLASS qualified_name superc_opt interfaces_opt class_body)
|
||||
(wisent-raw-tag
|
||||
(semantic-tag-new-type $3 $2 $6
|
||||
(if
|
||||
(or $4 $5)
|
||||
(cons $4 $5))
|
||||
:typemodifiers $1))))
|
||||
(superc_opt
|
||||
(nil)
|
||||
((EXTENDS qualified_name)
|
||||
(identity $2)))
|
||||
(interfaces_opt
|
||||
(nil)
|
||||
((IMPLEMENTS qualified_name_list)
|
||||
(nreverse $2)))
|
||||
(class_body
|
||||
((BRACE_BLOCK)
|
||||
(semantic-parse-region
|
||||
(car $region1)
|
||||
(cdr $region1)
|
||||
'class_member_declaration 1)))
|
||||
(class_member_declaration
|
||||
((LBRACE)
|
||||
nil)
|
||||
((RBRACE)
|
||||
nil)
|
||||
((block)
|
||||
nil)
|
||||
((static_initializer)
|
||||
nil)
|
||||
((constructor_declaration))
|
||||
((interface_declaration))
|
||||
((class_declaration))
|
||||
((method_declaration))
|
||||
((field_declaration)))
|
||||
(interface_declaration
|
||||
((modifiers_opt INTERFACE qualified_name extends_interfaces_opt interface_body)
|
||||
(wisent-raw-tag
|
||||
(semantic-tag-new-type $3 $2 $5
|
||||
(if $4
|
||||
(cons nil $4))
|
||||
:typemodifiers $1))))
|
||||
(extends_interfaces_opt
|
||||
(nil)
|
||||
((EXTENDS qualified_name_list)
|
||||
(identity $2)))
|
||||
(interface_body
|
||||
((BRACE_BLOCK)
|
||||
(semantic-parse-region
|
||||
(car $region1)
|
||||
(cdr $region1)
|
||||
'interface_member_declaration 1)))
|
||||
(interface_member_declaration
|
||||
((LBRACE)
|
||||
nil)
|
||||
((RBRACE)
|
||||
nil)
|
||||
((interface_declaration))
|
||||
((class_declaration))
|
||||
((method_declaration))
|
||||
((field_declaration)))
|
||||
(static_initializer
|
||||
((STATIC block)))
|
||||
(constructor_declaration
|
||||
((modifiers_opt constructor_declarator throwsc_opt constructor_body)
|
||||
(wisent-raw-tag
|
||||
(semantic-tag-new-function
|
||||
(car $2)
|
||||
nil
|
||||
(cdr $2)
|
||||
:typemodifiers $1 :throws $3 :constructor-flag t))))
|
||||
(constructor_declarator
|
||||
((IDENTIFIER formal_parameter_list)
|
||||
(cons $1 $2)))
|
||||
(constructor_body
|
||||
((block)))
|
||||
(method_declaration
|
||||
((modifiers_opt VOID method_declarator throwsc_opt method_body)
|
||||
(wisent-raw-tag
|
||||
(semantic-tag-new-function
|
||||
(car $3)
|
||||
$2
|
||||
(cdr $3)
|
||||
:typemodifiers $1 :throws $4)))
|
||||
((modifiers_opt type method_declarator throwsc_opt method_body)
|
||||
(wisent-raw-tag
|
||||
(semantic-tag-new-function
|
||||
(car $3)
|
||||
$2
|
||||
(cdr $3)
|
||||
:typemodifiers $1 :throws $4))))
|
||||
(method_declarator
|
||||
((IDENTIFIER formal_parameter_list dims_opt)
|
||||
(cons
|
||||
(concat $1 $3)
|
||||
$2)))
|
||||
(throwsc_opt
|
||||
(nil)
|
||||
((THROWS qualified_name_list)
|
||||
(nreverse $2)))
|
||||
(qualified_name_list
|
||||
((qualified_name_list COMMA qualified_name)
|
||||
(cons $3 $1))
|
||||
((qualified_name)
|
||||
(list $1)))
|
||||
(method_body
|
||||
((SEMICOLON))
|
||||
((block)))
|
||||
(block
|
||||
((BRACE_BLOCK)))
|
||||
(formal_parameter_list
|
||||
((PAREN_BLOCK)
|
||||
(semantic-parse-region
|
||||
(car $region1)
|
||||
(cdr $region1)
|
||||
'formal_parameters 1)))
|
||||
(formal_parameters
|
||||
((LPAREN)
|
||||
nil)
|
||||
((RPAREN)
|
||||
nil)
|
||||
((formal_parameter COMMA))
|
||||
((formal_parameter RPAREN)))
|
||||
(formal_parameter
|
||||
((formal_parameter_modifier_opt type opt_variable_declarator_id)
|
||||
(wisent-raw-tag
|
||||
(semantic-tag-new-variable $3 $2 nil :typemodifiers $1))))
|
||||
(formal_parameter_modifier_opt
|
||||
(nil)
|
||||
((FINAL)
|
||||
(list $1)))
|
||||
(field_declaration
|
||||
((modifiers_opt type variable_declarators SEMICOLON)
|
||||
(wisent-raw-tag
|
||||
(semantic-tag-new-variable $3 $2 nil :typemodifiers $1))))
|
||||
(variable_declarators
|
||||
((variable_declarators COMMA variable_declarator)
|
||||
(progn
|
||||
(setcdr
|
||||
(cdr
|
||||
(car $1))
|
||||
(cdr $region2))
|
||||
(cons $3 $1)))
|
||||
((variable_declarator)
|
||||
(list $1)))
|
||||
(variable_declarator
|
||||
((variable_declarator_id EQ variable_initializer)
|
||||
(cons $1 $region))
|
||||
((variable_declarator_id)
|
||||
(cons $1 $region)))
|
||||
(opt_variable_declarator_id
|
||||
(nil
|
||||
(identity ""))
|
||||
((variable_declarator_id)
|
||||
(identity $1)))
|
||||
(variable_declarator_id
|
||||
((IDENTIFIER dims_opt)
|
||||
(concat $1 $2)))
|
||||
(variable_initializer
|
||||
((expression)))
|
||||
(expression
|
||||
((expression term))
|
||||
((term)))
|
||||
(term
|
||||
((literal))
|
||||
((operator))
|
||||
((primitive_type))
|
||||
((IDENTIFIER))
|
||||
((BRACK_BLOCK))
|
||||
((PAREN_BLOCK))
|
||||
((BRACE_BLOCK))
|
||||
((NEW))
|
||||
((CLASS))
|
||||
((THIS))
|
||||
((SUPER)))
|
||||
(literal
|
||||
((STRING_LITERAL))
|
||||
((NUMBER_LITERAL)))
|
||||
(operator
|
||||
((NOT))
|
||||
((PLUS))
|
||||
((PLUSPLUS))
|
||||
((MINUS))
|
||||
((MINUSMINUS))
|
||||
((NOTEQ))
|
||||
((MOD))
|
||||
((MODEQ))
|
||||
((AND))
|
||||
((ANDAND))
|
||||
((ANDEQ))
|
||||
((MULT))
|
||||
((MULTEQ))
|
||||
((PLUSEQ))
|
||||
((MINUSEQ))
|
||||
((DOT))
|
||||
((DIV))
|
||||
((DIVEQ))
|
||||
((COLON))
|
||||
((LT))
|
||||
((LSHIFT))
|
||||
((LSHIFTEQ))
|
||||
((LTEQ))
|
||||
((EQ))
|
||||
((EQEQ))
|
||||
((GT))
|
||||
((GTEQ))
|
||||
((RSHIFT))
|
||||
((RSHIFTEQ))
|
||||
((URSHIFT))
|
||||
((URSHIFTEQ))
|
||||
((QUESTION))
|
||||
((XOR))
|
||||
((XOREQ))
|
||||
((OR))
|
||||
((OREQ))
|
||||
((OROR))
|
||||
((COMP))
|
||||
((INSTANCEOF)))
|
||||
(primitive_type
|
||||
((BOOLEAN))
|
||||
((CHAR))
|
||||
((LONG))
|
||||
((INT))
|
||||
((SHORT))
|
||||
((BYTE))
|
||||
((DOUBLE))
|
||||
((FLOAT)))
|
||||
(modifiers_opt
|
||||
(nil)
|
||||
((modifiers)
|
||||
(nreverse $1)))
|
||||
(modifiers
|
||||
((modifiers modifier)
|
||||
(cons $2 $1))
|
||||
((modifier)
|
||||
(list $1)))
|
||||
(modifier
|
||||
((STRICTFP))
|
||||
((VOLATILE))
|
||||
((TRANSIENT))
|
||||
((SYNCHRONIZED))
|
||||
((NATIVE))
|
||||
((FINAL))
|
||||
((ABSTRACT))
|
||||
((STATIC))
|
||||
((PRIVATE))
|
||||
((PROTECTED))
|
||||
((PUBLIC)))
|
||||
(type
|
||||
((qualified_name dims_opt)
|
||||
(concat $1 $2))
|
||||
((primitive_type dims_opt)
|
||||
(concat $1 $2)))
|
||||
(qualified_name
|
||||
((qualified_name DOT IDENTIFIER)
|
||||
(concat $1 $2 $3))
|
||||
((IDENTIFIER)))
|
||||
(dims_opt
|
||||
(nil
|
||||
(identity ""))
|
||||
((dims)))
|
||||
(dims
|
||||
((dims BRACK_BLOCK)
|
||||
(concat $1 "[]"))
|
||||
((BRACK_BLOCK)
|
||||
(identity "[]"))))
|
||||
'(compilation_unit package_declaration import_declaration class_declaration field_declaration method_declaration formal_parameter constructor_declaration interface_declaration class_member_declaration interface_member_declaration formal_parameters)))
|
||||
"Parser table.")
|
||||
|
||||
(defun wisent-java-tags-wy--install-parser ()
|
||||
"Setup the Semantic Parser."
|
||||
(semantic-install-function-overrides
|
||||
'((parse-stream . wisent-parse-stream)))
|
||||
(setq semantic-parser-name "LALR"
|
||||
semantic--parse-table wisent-java-tags-wy--parse-table
|
||||
semantic-debug-parser-source "java-tags.wy"
|
||||
semantic-flex-keywords-obarray wisent-java-tags-wy--keyword-table
|
||||
semantic-lex-types-obarray wisent-java-tags-wy--token-table)
|
||||
;; Collect unmatched syntax lexical tokens
|
||||
(semantic-make-local-hook 'wisent-discarding-token-functions)
|
||||
(add-hook 'wisent-discarding-token-functions
|
||||
'wisent-collect-unmatched-syntax nil t))
|
||||
|
||||
|
||||
;;; Analyzers
|
||||
;;
|
||||
(define-lex-block-type-analyzer wisent-java-tags-wy--<block>-block-analyzer
|
||||
"block analyzer for <block> tokens."
|
||||
"\\s(\\|\\s)"
|
||||
'((("(" LPAREN PAREN_BLOCK)
|
||||
("{" LBRACE BRACE_BLOCK)
|
||||
("[" LBRACK BRACK_BLOCK))
|
||||
(")" RPAREN)
|
||||
("}" RBRACE)
|
||||
("]" RBRACK))
|
||||
)
|
||||
|
||||
(define-lex-string-type-analyzer wisent-java-tags-wy--<punctuation>-string-analyzer
|
||||
"string analyzer for <punctuation> tokens."
|
||||
"\\(\\s.\\|\\s$\\|\\s'\\)+"
|
||||
'((COMP . "~")
|
||||
(OROR . "||")
|
||||
(OREQ . "|=")
|
||||
(OR . "|")
|
||||
(XOREQ . "^=")
|
||||
(XOR . "^")
|
||||
(QUESTION . "?")
|
||||
(URSHIFTEQ . ">>>=")
|
||||
(URSHIFT . ">>>")
|
||||
(RSHIFTEQ . ">>=")
|
||||
(RSHIFT . ">>")
|
||||
(GTEQ . ">=")
|
||||
(GT . ">")
|
||||
(EQEQ . "==")
|
||||
(EQ . "=")
|
||||
(LTEQ . "<=")
|
||||
(LSHIFTEQ . "<<=")
|
||||
(LSHIFT . "<<")
|
||||
(LT . "<")
|
||||
(SEMICOLON . ";")
|
||||
(COLON . ":")
|
||||
(DIVEQ . "/=")
|
||||
(DIV . "/")
|
||||
(DOT . ".")
|
||||
(MINUSEQ . "-=")
|
||||
(MINUSMINUS . "--")
|
||||
(MINUS . "-")
|
||||
(COMMA . ",")
|
||||
(PLUSEQ . "+=")
|
||||
(PLUSPLUS . "++")
|
||||
(PLUS . "+")
|
||||
(MULTEQ . "*=")
|
||||
(MULT . "*")
|
||||
(ANDEQ . "&=")
|
||||
(ANDAND . "&&")
|
||||
(AND . "&")
|
||||
(MODEQ . "%=")
|
||||
(MOD . "%")
|
||||
(NOTEQ . "!=")
|
||||
(NOT . "!"))
|
||||
'punctuation)
|
||||
|
||||
(define-lex-regex-type-analyzer wisent-java-tags-wy--<symbol>-regexp-analyzer
|
||||
"regexp analyzer for <symbol> tokens."
|
||||
"\\(\\sw\\|\\s_\\)+"
|
||||
nil
|
||||
'IDENTIFIER)
|
||||
|
||||
(define-lex-regex-type-analyzer wisent-java-tags-wy--<unicode>-regexp-analyzer
|
||||
"regexp analyzer for <unicode> tokens."
|
||||
"\\\\u[0-9a-f][0-9a-f][0-9a-f][0-9a-f]"
|
||||
nil
|
||||
'unicodecharacter)
|
||||
|
||||
(define-lex-regex-type-analyzer wisent-java-tags-wy--<number>-regexp-analyzer
|
||||
"regexp analyzer for <number> tokens."
|
||||
semantic-lex-number-expression
|
||||
nil
|
||||
'NUMBER_LITERAL)
|
||||
|
||||
(define-lex-sexp-type-analyzer wisent-java-tags-wy--<string>-sexp-analyzer
|
||||
"sexp analyzer for <string> tokens."
|
||||
"\\s\""
|
||||
'STRING_LITERAL)
|
||||
|
||||
(define-lex-keyword-type-analyzer wisent-java-tags-wy--<keyword>-keyword-analyzer
|
||||
"keyword analyzer for <keyword> tokens."
|
||||
"\\(\\sw\\|\\s_\\)+")
|
||||
|
||||
|
||||
;;; Epilogue
|
||||
;;
|
||||
;; Define the lexer for this grammar
|
||||
(define-lex wisent-java-tags-lexer
|
||||
"Lexical analyzer that handles Java buffers.
|
||||
It ignores whitespaces, newlines and comments."
|
||||
semantic-lex-ignore-whitespace
|
||||
semantic-lex-ignore-newline
|
||||
semantic-lex-ignore-comments
|
||||
;;;; Auto-generated analyzers.
|
||||
wisent-java-tags-wy--<number>-regexp-analyzer
|
||||
wisent-java-tags-wy--<string>-sexp-analyzer
|
||||
;; Must detect keywords before other symbols
|
||||
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.
|
||||
wisent-java-tags-wy--<unicode>-regexp-analyzer
|
||||
;;;;
|
||||
semantic-lex-default-action)
|
||||
|
||||
(provide 'semantic/wisent/javat-wy)
|
||||
|
||||
;;; semantic/wisent/javat-wy.el ends here
|
@ -1,530 +0,0 @@
|
||||
;;; semantic/wisent/js-wy.el --- Generated parser support file
|
||||
|
||||
;; Copyright (C) 2005, 2009-2013 Free Software Foundation, Inc.
|
||||
;; Copyright (C) 1998-2011 Ecma International.
|
||||
|
||||
;; 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:
|
||||
;;
|
||||
;; This file was generated from admin/grammars/js.wy.
|
||||
|
||||
;; It is derived from the grammar in 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.
|
||||
|
||||
;;; Code:
|
||||
|
||||
(require 'semantic/lex)
|
||||
(eval-when-compile (require 'semantic/bovine))
|
||||
|
||||
;;; Prologue
|
||||
;;
|
||||
(declare-function semantic-parse-region "semantic"
|
||||
(start end &optional nonterminal depth returnonerror))
|
||||
|
||||
;;; Declarations
|
||||
;;
|
||||
(defconst wisent-javascript-jv-wy--keyword-table
|
||||
(semantic-lex-make-keyword-table
|
||||
'(("if" . IF)
|
||||
("break" . BREAK)
|
||||
("continue" . CONTINUE)
|
||||
("else" . ELSE)
|
||||
("for" . FOR)
|
||||
("function" . FUNCTION)
|
||||
("this" . THIS)
|
||||
("return" . RETURN)
|
||||
("while" . WHILE)
|
||||
("void" . VOID_SYMBOL)
|
||||
("new" . NEW)
|
||||
("delete" . DELETE)
|
||||
("var" . VAR)
|
||||
("with" . WITH)
|
||||
("typeof" . TYPEOF)
|
||||
("in" . IN))
|
||||
'(("in" summary "in something")
|
||||
("typeof" summary "typeof ")
|
||||
("with" summary "with ")
|
||||
("var" summary "var <variablename> [= value];")
|
||||
("delete" summary "delete(<objectreference>) - Deletes the object.")
|
||||
("new" summary "new <objecttype> - Creates a new object.")
|
||||
("void" summary "Method return type: void <name> ...")
|
||||
("while" summary "while (<expr>) <stmt> | do <stmt> while (<expr>);")
|
||||
("return" summary "return [<expr>] ;")
|
||||
("this" summary "this")
|
||||
("function" summary "function declaration blah blah")
|
||||
("for" summary "for ([<init-expr>]; [<expr>]; [<update-expr>]) <stmt>")
|
||||
("else" summary "if (<expr>) <stmt> else <stmt>")
|
||||
("continue" summary "continue [<label>] ;")
|
||||
("break" summary "break [<label>] ;")
|
||||
("if" summary "if (<expr>) <stmt> [else <stmt>] (jv)")))
|
||||
"Table of language keywords.")
|
||||
|
||||
(defconst wisent-javascript-jv-wy--token-table
|
||||
(semantic-lex-make-type-table
|
||||
'(("<no-type>"
|
||||
(NULL_TOKEN)
|
||||
(QUERY)
|
||||
(TRUE)
|
||||
(FALSE))
|
||||
("number"
|
||||
(NUMBER))
|
||||
("string"
|
||||
(STRING))
|
||||
("symbol"
|
||||
(VARIABLE))
|
||||
("close-paren"
|
||||
(CLOSE_SQ_BRACKETS . "]")
|
||||
(END_BLOCK . "}")
|
||||
(CLOSE_PARENTHESIS . ")"))
|
||||
("open-paren"
|
||||
(OPEN_SQ_BRACKETS . "[")
|
||||
(START_BLOCK . "{")
|
||||
(OPEN_PARENTHESIS . "("))
|
||||
("block"
|
||||
(BRACK_BLOCK . "(OPEN_SQ_BRACKETS CLOSE_SQ_BRACKETS)")
|
||||
(BRACE_BLOCK . "(START_BLOCK END_BLOCK)")
|
||||
(PAREN_BLOCK . "(OPEN_PARENTHESIS CLOSE_PARENTHESIS)"))
|
||||
("punctuation"
|
||||
(ONES_COMPLIMENT . "~")
|
||||
(SEMICOLON . ";")
|
||||
(LINE_TERMINATOR . "\n")
|
||||
(LESS_THAN . "<")
|
||||
(DOT . ".")
|
||||
(COMMA . ",")
|
||||
(COLON . ":")
|
||||
(DIV . "/")
|
||||
(DECREMENT . "--")
|
||||
(INCREMENT . "++")
|
||||
(PLUS_EQUALS . "+=")
|
||||
(PLUS . "+")
|
||||
(MULTIPLY_EQUALS . "*=")
|
||||
(MULTIPLY . "*")
|
||||
(MOD_EQUALS . "%=")
|
||||
(MOD . "%")
|
||||
(MINUS_EQUALS . "-=")
|
||||
(MINUS . "-")
|
||||
(LS_EQUAL . "<=")
|
||||
(LOGICAL_NOT . "!!")
|
||||
(LOGICAL_OR . "||")
|
||||
(LOGICAL_AND . "&&")
|
||||
(GT_EQUAL . ">=")
|
||||
(GREATER_THAN . ">")
|
||||
(EQUALS . "==")
|
||||
(DIV_EQUALS . "/=")
|
||||
(NOT_EQUAL . "!=")
|
||||
(BITWISE_SHIFT_RIGHT_ZERO_FILL_EQUALS . ">>>=")
|
||||
(BITWISE_SHIFT_RIGHT_ZERO_FILL . ">>>")
|
||||
(BITWISE_SHIFT_RIGHT_EQUALS . ">>=")
|
||||
(BITWISE_SHIFT_RIGHT . ">>")
|
||||
(BITWISE_SHIFT_LEFT_EQUALS . "<<=")
|
||||
(BITWISE_SHIFT_LEFT . "<<")
|
||||
(BITWISE_OR_EQUALS . "|=")
|
||||
(BITWISE_OR . "|")
|
||||
(BITWISE_EXCLUSIVE_OR_EQUALS . "^=")
|
||||
(BITWISE_EXCLUSIVE_OR . "^")
|
||||
(BITWISE_AND_EQUALS . "&=")
|
||||
(BITWISE_AND . "&")
|
||||
(ASSIGN_SYMBOL . "=")))
|
||||
'(("number" :declared t)
|
||||
("string" :declared t)
|
||||
("symbol" :declared t)
|
||||
("keyword" :declared t)
|
||||
("block" :declared t)
|
||||
("punctuation" :declared t)))
|
||||
"Table of lexical tokens.")
|
||||
|
||||
(defconst wisent-javascript-jv-wy--parse-table
|
||||
(progn
|
||||
(eval-when-compile
|
||||
(require 'semantic/wisent/comp))
|
||||
(wisent-compile-grammar
|
||||
'((ASSIGN_SYMBOL BITWISE_AND BITWISE_AND_EQUALS BITWISE_EXCLUSIVE_OR BITWISE_EXCLUSIVE_OR_EQUALS BITWISE_OR BITWISE_OR_EQUALS BITWISE_SHIFT_LEFT BITWISE_SHIFT_LEFT_EQUALS BITWISE_SHIFT_RIGHT BITWISE_SHIFT_RIGHT_EQUALS BITWISE_SHIFT_RIGHT_ZERO_FILL BITWISE_SHIFT_RIGHT_ZERO_FILL_EQUALS NOT_EQUAL DIV_EQUALS EQUALS GREATER_THAN GT_EQUAL LOGICAL_AND LOGICAL_OR LOGICAL_NOT LS_EQUAL MINUS MINUS_EQUALS MOD MOD_EQUALS MULTIPLY MULTIPLY_EQUALS PLUS PLUS_EQUALS INCREMENT DECREMENT DIV COLON COMMA DOT LESS_THAN LINE_TERMINATOR SEMICOLON ONES_COMPLIMENT PAREN_BLOCK BRACE_BLOCK BRACK_BLOCK OPEN_PARENTHESIS CLOSE_PARENTHESIS START_BLOCK END_BLOCK OPEN_SQ_BRACKETS CLOSE_SQ_BRACKETS IF BREAK CONTINUE ELSE FOR FUNCTION THIS RETURN WHILE VOID_SYMBOL NEW DELETE VAR WITH TYPEOF IN VARIABLE STRING NUMBER FALSE TRUE QUERY NULL_TOKEN)
|
||||
((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)
|
||||
(wisent-raw-tag
|
||||
(semantic-tag-new-function $2 nil $3))))
|
||||
(FormalParameterListBlock
|
||||
((PAREN_BLOCK)
|
||||
(semantic-parse-region
|
||||
(car $region1)
|
||||
(cdr $region1)
|
||||
'FormalParameterList 1)))
|
||||
(FormalParameterList
|
||||
((OPEN_PARENTHESIS)
|
||||
nil)
|
||||
((VARIABLE)
|
||||
(wisent-raw-tag
|
||||
(semantic-tag-new-variable $1 nil nil)))
|
||||
((CLOSE_PARENTHESIS)
|
||||
nil)
|
||||
((COMMA)
|
||||
nil))
|
||||
(StatementList
|
||||
((Statement))
|
||||
((StatementList Statement)))
|
||||
(Block
|
||||
((BRACE_BLOCK)))
|
||||
(BlockExpand
|
||||
((START_BLOCK StatementList END_BLOCK))
|
||||
((START_BLOCK END_BLOCK)))
|
||||
(VariableStatement
|
||||
((VAR VariableDeclarationList SEMICOLON)
|
||||
(wisent-raw-tag
|
||||
(semantic-tag-new-variable $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)
|
||||
[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)
|
||||
[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)))
|
||||
(BreakStatement
|
||||
((BREAK SEMICOLON)))
|
||||
(ReturnStatement
|
||||
((RETURN Expression SEMICOLON))
|
||||
((RETURN SEMICOLON)))
|
||||
(WithStatement
|
||||
((WITH OPEN_PARENTHESIS Expression CLOSE_PARENTHESIS Statement)))
|
||||
(OptionalInitializer
|
||||
((Initializer))
|
||||
(nil))
|
||||
(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)
|
||||
[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))
|
||||
(nil)))
|
||||
'(Program FormalParameterList)))
|
||||
"Parser table.")
|
||||
|
||||
(defun wisent-javascript-jv-wy--install-parser ()
|
||||
"Setup the Semantic Parser."
|
||||
(semantic-install-function-overrides
|
||||
'((parse-stream . wisent-parse-stream)))
|
||||
(setq semantic-parser-name "LALR"
|
||||
semantic--parse-table wisent-javascript-jv-wy--parse-table
|
||||
semantic-debug-parser-source "js.wy"
|
||||
semantic-flex-keywords-obarray wisent-javascript-jv-wy--keyword-table
|
||||
semantic-lex-types-obarray wisent-javascript-jv-wy--token-table)
|
||||
;; Collect unmatched syntax lexical tokens
|
||||
(semantic-make-local-hook 'wisent-discarding-token-functions)
|
||||
(add-hook 'wisent-discarding-token-functions
|
||||
'wisent-collect-unmatched-syntax nil t))
|
||||
|
||||
|
||||
;;; Analyzers
|
||||
;;
|
||||
(define-lex-block-type-analyzer wisent-javascript-jv-wy--<block>-block-analyzer
|
||||
"block analyzer for <block> tokens."
|
||||
"\\s(\\|\\s)"
|
||||
'((("(" OPEN_PARENTHESIS PAREN_BLOCK)
|
||||
("{" START_BLOCK BRACE_BLOCK)
|
||||
("[" OPEN_SQ_BRACKETS BRACK_BLOCK))
|
||||
(")" CLOSE_PARENTHESIS)
|
||||
("}" END_BLOCK)
|
||||
("]" CLOSE_SQ_BRACKETS))
|
||||
)
|
||||
|
||||
(define-lex-regex-type-analyzer wisent-javascript-jv-wy--<symbol>-regexp-analyzer
|
||||
"regexp analyzer for <symbol> tokens."
|
||||
"\\(\\sw\\|\\s_\\)+"
|
||||
nil
|
||||
'VARIABLE)
|
||||
|
||||
(define-lex-regex-type-analyzer wisent-javascript-jv-wy--<number>-regexp-analyzer
|
||||
"regexp analyzer for <number> tokens."
|
||||
semantic-lex-number-expression
|
||||
nil
|
||||
'NUMBER)
|
||||
|
||||
(define-lex-string-type-analyzer wisent-javascript-jv-wy--<punctuation>-string-analyzer
|
||||
"string analyzer for <punctuation> tokens."
|
||||
"\\(\\s.\\|\\s$\\|\\s'\\)+"
|
||||
'((ONES_COMPLIMENT . "~")
|
||||
(SEMICOLON . ";")
|
||||
(LINE_TERMINATOR . "\n")
|
||||
(LESS_THAN . "<")
|
||||
(DOT . ".")
|
||||
(COMMA . ",")
|
||||
(COLON . ":")
|
||||
(DIV . "/")
|
||||
(DECREMENT . "--")
|
||||
(INCREMENT . "++")
|
||||
(PLUS_EQUALS . "+=")
|
||||
(PLUS . "+")
|
||||
(MULTIPLY_EQUALS . "*=")
|
||||
(MULTIPLY . "*")
|
||||
(MOD_EQUALS . "%=")
|
||||
(MOD . "%")
|
||||
(MINUS_EQUALS . "-=")
|
||||
(MINUS . "-")
|
||||
(LS_EQUAL . "<=")
|
||||
(LOGICAL_NOT . "!!")
|
||||
(LOGICAL_OR . "||")
|
||||
(LOGICAL_AND . "&&")
|
||||
(GT_EQUAL . ">=")
|
||||
(GREATER_THAN . ">")
|
||||
(EQUALS . "==")
|
||||
(DIV_EQUALS . "/=")
|
||||
(NOT_EQUAL . "!=")
|
||||
(BITWISE_SHIFT_RIGHT_ZERO_FILL_EQUALS . ">>>=")
|
||||
(BITWISE_SHIFT_RIGHT_ZERO_FILL . ">>>")
|
||||
(BITWISE_SHIFT_RIGHT_EQUALS . ">>=")
|
||||
(BITWISE_SHIFT_RIGHT . ">>")
|
||||
(BITWISE_SHIFT_LEFT_EQUALS . "<<=")
|
||||
(BITWISE_SHIFT_LEFT . "<<")
|
||||
(BITWISE_OR_EQUALS . "|=")
|
||||
(BITWISE_OR . "|")
|
||||
(BITWISE_EXCLUSIVE_OR_EQUALS . "^=")
|
||||
(BITWISE_EXCLUSIVE_OR . "^")
|
||||
(BITWISE_AND_EQUALS . "&=")
|
||||
(BITWISE_AND . "&")
|
||||
(ASSIGN_SYMBOL . "="))
|
||||
'punctuation)
|
||||
|
||||
(define-lex-sexp-type-analyzer wisent-javascript-jv-wy--<string>-sexp-analyzer
|
||||
"sexp analyzer for <string> tokens."
|
||||
"\\s\""
|
||||
'STRING)
|
||||
|
||||
(define-lex-keyword-type-analyzer wisent-javascript-jv-wy--<keyword>-keyword-analyzer
|
||||
"keyword analyzer for <keyword> tokens."
|
||||
"\\(\\sw\\|\\s_\\)+")
|
||||
|
||||
|
||||
;;; Epilogue
|
||||
;;
|
||||
;;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
|
||||
)
|
||||
|
||||
(provide 'semantic/wisent/js-wy)
|
||||
|
||||
;;; semantic/wisent/js-wy.el ends here
|
@ -1,847 +0,0 @@
|
||||
;;; semantic/wisent/python-wy.el --- Generated parser support file
|
||||
|
||||
;; Copyright (C) 2002-2013 Free Software Foundation, Inc.
|
||||
;; Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
|
||||
;; 2009, 2010 Python Software Foundation; All Rights Reserved
|
||||
|
||||
;; 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:
|
||||
;;
|
||||
;; This file was generated from admin/grammars/python.wy.
|
||||
;; It is derived in part from the Python grammar, used under the
|
||||
;; following license:
|
||||
;;
|
||||
;; PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2
|
||||
;; --------------------------------------------
|
||||
;; 1. This LICENSE AGREEMENT is between the Python Software Foundation
|
||||
;; ("PSF"), and the Individual or Organization ("Licensee") accessing
|
||||
;; and otherwise using this software ("Python") in source or binary
|
||||
;; form and its associated documentation.
|
||||
;;
|
||||
;; 2. Subject to the terms and conditions of this License Agreement,
|
||||
;; PSF hereby grants Licensee a nonexclusive, royalty-free, world-wide
|
||||
;; license to reproduce, analyze, test, perform and/or display
|
||||
;; publicly, prepare derivative works, distribute, and otherwise use
|
||||
;; Python alone or in any derivative version, provided, however, that
|
||||
;; PSF's License Agreement and PSF's notice of copyright, i.e.,
|
||||
;; "Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
|
||||
;; 2009, 2010 Python Software Foundation; All Rights Reserved" are
|
||||
;; retained in Python alone or in any derivative version prepared by
|
||||
;; Licensee.
|
||||
;;
|
||||
;; 3. In the event Licensee prepares a derivative work that is based
|
||||
;; on or incorporates Python or any part thereof, and wants to make
|
||||
;; the derivative work available to others as provided herein, then
|
||||
;; Licensee hereby agrees to include in any such work a brief summary
|
||||
;; of the changes made to Python.
|
||||
;;
|
||||
;; 4. PSF is making Python available to Licensee on an "AS IS"
|
||||
;; basis. PSF MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR
|
||||
;; IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, PSF MAKES NO AND
|
||||
;; DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS
|
||||
;; FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF PYTHON WILL NOT
|
||||
;; INFRINGE ANY THIRD PARTY RIGHTS.
|
||||
;;
|
||||
;; 5. PSF SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON
|
||||
;; FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS A
|
||||
;; RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON, OR
|
||||
;; ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.
|
||||
;;
|
||||
;; 6. This License Agreement will automatically terminate upon a
|
||||
;; material breach of its terms and conditions.
|
||||
;;
|
||||
;; 7. Nothing in this License Agreement shall be deemed to create any
|
||||
;; relationship of agency, partnership, or joint venture between PSF
|
||||
;; and Licensee. This License Agreement does not grant permission to
|
||||
;; use PSF trademarks or trade name in a trademark sense to endorse or
|
||||
;; promote products or services of Licensee, or any third party.
|
||||
;;
|
||||
;; 8. By copying, installing or otherwise using Python, Licensee
|
||||
;; agrees to be bound by the terms and conditions of this License
|
||||
;; Agreement.
|
||||
|
||||
;;; Code:
|
||||
|
||||
(require 'semantic/lex)
|
||||
(eval-when-compile (require 'semantic/bovine))
|
||||
|
||||
;;; Prologue
|
||||
;;
|
||||
(declare-function wisent-python-reconstitute-function-tag
|
||||
"semantic/wisent/python" (tag suite))
|
||||
(declare-function wisent-python-reconstitute-class-tag "semantic/wisent/python"
|
||||
(tag))
|
||||
(declare-function semantic-parse-region "semantic"
|
||||
(start end &optional nonterminal depth returnonerror))
|
||||
|
||||
;;; Declarations
|
||||
;;
|
||||
(defconst wisent-python-wy--keyword-table
|
||||
(semantic-lex-make-keyword-table
|
||||
'(("and" . AND)
|
||||
("as" . AS)
|
||||
("assert" . ASSERT)
|
||||
("break" . BREAK)
|
||||
("class" . CLASS)
|
||||
("continue" . CONTINUE)
|
||||
("def" . DEF)
|
||||
("del" . DEL)
|
||||
("elif" . ELIF)
|
||||
("else" . ELSE)
|
||||
("except" . EXCEPT)
|
||||
("exec" . EXEC)
|
||||
("finally" . FINALLY)
|
||||
("for" . FOR)
|
||||
("from" . FROM)
|
||||
("global" . GLOBAL)
|
||||
("if" . IF)
|
||||
("import" . IMPORT)
|
||||
("in" . IN)
|
||||
("is" . IS)
|
||||
("lambda" . LAMBDA)
|
||||
("not" . NOT)
|
||||
("or" . OR)
|
||||
("pass" . PASS)
|
||||
("print" . PRINT)
|
||||
("raise" . RAISE)
|
||||
("return" . RETURN)
|
||||
("try" . TRY)
|
||||
("while" . WHILE)
|
||||
("with" . WITH)
|
||||
("yield" . YIELD))
|
||||
'(("yield" summary "Create a generator function")
|
||||
("with" summary "Start statement with an associated context object")
|
||||
("while" summary "Start a 'while' loop")
|
||||
("try" summary "Start of statements protected by exception handlers")
|
||||
("return" summary "Return from a function")
|
||||
("raise" summary "Raise an exception")
|
||||
("print" summary "Print each argument to standard output")
|
||||
("pass" summary "Statement that does nothing")
|
||||
("or" summary "Binary logical 'or' operator")
|
||||
("not" summary "Unary boolean negation operator")
|
||||
("lambda" summary "Create anonymous function")
|
||||
("is" summary "Binary operator that tests for object equality")
|
||||
("in" summary "Part of 'for' statement ")
|
||||
("import" summary "Load specified modules")
|
||||
("if" summary "Start 'if' conditional statement")
|
||||
("global" summary "Declare one or more symbols as global symbols")
|
||||
("from" summary "Modify behavior of 'import' statement")
|
||||
("for" summary "Start a 'for' loop")
|
||||
("finally" summary "Specify code to be executed after 'try' statements whether or not an exception occurred")
|
||||
("exec" summary "Dynamically execute Python code")
|
||||
("except" summary "Specify exception handlers along with 'try' keyword")
|
||||
("else" summary "Start the 'else' clause following an 'if' statement")
|
||||
("elif" summary "Shorthand for 'else if' following an 'if' statement")
|
||||
("del" summary "Delete specified objects, i.e., undo what assignment did")
|
||||
("def" summary "Define a new function")
|
||||
("continue" summary "Skip to the next iteration of enclosing 'for' or 'while' loop")
|
||||
("class" summary "Define a new class")
|
||||
("break" summary "Terminate 'for' or 'while' loop")
|
||||
("assert" summary "Raise AssertionError exception if <expr> is false")
|
||||
("as" summary "EXPR as NAME makes value of EXPR available as variable NAME")
|
||||
("and" summary "Logical AND binary operator ... ")))
|
||||
"Table of language keywords.")
|
||||
|
||||
(defconst wisent-python-wy--token-table
|
||||
(semantic-lex-make-type-table
|
||||
'(("symbol"
|
||||
(NAME))
|
||||
("number"
|
||||
(NUMBER_LITERAL))
|
||||
("string"
|
||||
(STRING_LITERAL))
|
||||
("punctuation"
|
||||
(AT . "@")
|
||||
(BACKQUOTE . "`")
|
||||
(ASSIGN . "=")
|
||||
(COMMA . ",")
|
||||
(SEMICOLON . ";")
|
||||
(COLON . ":")
|
||||
(BAR . "|")
|
||||
(TILDE . "~")
|
||||
(PERIOD . ".")
|
||||
(MINUS . "-")
|
||||
(PLUS . "+")
|
||||
(MOD . "%")
|
||||
(DIV . "/")
|
||||
(MULT . "*")
|
||||
(AMP . "&")
|
||||
(GT . ">")
|
||||
(LT . "<")
|
||||
(HAT . "^")
|
||||
(NE . "!=")
|
||||
(LTGT . "<>")
|
||||
(HATEQ . "^=")
|
||||
(OREQ . "|=")
|
||||
(AMPEQ . "&=")
|
||||
(MODEQ . "%=")
|
||||
(DIVEQ . "/=")
|
||||
(MULTEQ . "*=")
|
||||
(MINUSEQ . "-=")
|
||||
(PLUSEQ . "+=")
|
||||
(LE . "<=")
|
||||
(GE . ">=")
|
||||
(EQ . "==")
|
||||
(EXPONENT . "**")
|
||||
(GTGT . ">>")
|
||||
(LTLT . "<<")
|
||||
(DIVDIV . "//")
|
||||
(DIVDIVEQ . "//=")
|
||||
(EXPEQ . "**=")
|
||||
(GTGTEQ . ">>=")
|
||||
(LTLTEQ . "<<="))
|
||||
("close-paren"
|
||||
(RBRACK . "]")
|
||||
(RBRACE . "}")
|
||||
(RPAREN . ")"))
|
||||
("open-paren"
|
||||
(LBRACK . "[")
|
||||
(LBRACE . "{")
|
||||
(LPAREN . "("))
|
||||
("block"
|
||||
(BRACK_BLOCK . "(LBRACK RBRACK)")
|
||||
(BRACE_BLOCK . "(LBRACE RBRACE)")
|
||||
(PAREN_BLOCK . "(LPAREN RPAREN)"))
|
||||
("indentation"
|
||||
(INDENT_BLOCK . "(INDENT DEDENT)")
|
||||
(DEDENT . "[^:INDENT:]")
|
||||
(INDENT . "^\\s-+"))
|
||||
("newline"
|
||||
(NEWLINE . "\n"))
|
||||
("charquote"
|
||||
(BACKSLASH . "\\")))
|
||||
'(("keyword" :declared t)
|
||||
("symbol" :declared t)
|
||||
("number" :declared t)
|
||||
("punctuation" :declared t)
|
||||
("block" :declared t)))
|
||||
"Table of lexical tokens.")
|
||||
|
||||
(defconst wisent-python-wy--parse-table
|
||||
(progn
|
||||
(eval-when-compile
|
||||
(require 'semantic/wisent/comp))
|
||||
(wisent-compile-grammar
|
||||
'((BACKSLASH NEWLINE INDENT DEDENT INDENT_BLOCK PAREN_BLOCK BRACE_BLOCK BRACK_BLOCK LPAREN RPAREN LBRACE RBRACE LBRACK RBRACK LTLTEQ GTGTEQ EXPEQ DIVDIVEQ DIVDIV LTLT GTGT EXPONENT EQ GE LE PLUSEQ MINUSEQ MULTEQ DIVEQ MODEQ AMPEQ OREQ HATEQ LTGT NE HAT LT GT AMP MULT DIV MOD PLUS MINUS PERIOD TILDE BAR COLON SEMICOLON COMMA ASSIGN BACKQUOTE AT STRING_LITERAL NUMBER_LITERAL NAME AND AS ASSERT BREAK CLASS CONTINUE DEF DEL ELIF ELSE EXCEPT EXEC FINALLY FOR FROM GLOBAL IF IMPORT IN IS LAMBDA NOT OR PASS PRINT RAISE RETURN TRY WHILE WITH YIELD)
|
||||
nil
|
||||
(goal
|
||||
((NEWLINE))
|
||||
((simple_stmt))
|
||||
((compound_stmt)))
|
||||
(simple_stmt
|
||||
((small_stmt_list semicolon_opt NEWLINE)))
|
||||
(small_stmt_list
|
||||
((small_stmt))
|
||||
((small_stmt_list SEMICOLON small_stmt)))
|
||||
(small_stmt
|
||||
((expr_stmt))
|
||||
((print_stmt))
|
||||
((del_stmt))
|
||||
((pass_stmt))
|
||||
((flow_stmt))
|
||||
((import_stmt))
|
||||
((global_stmt))
|
||||
((exec_stmt))
|
||||
((assert_stmt)))
|
||||
(print_stmt
|
||||
((PRINT print_stmt_trailer)
|
||||
(wisent-raw-tag
|
||||
(semantic-tag-new-code $1 nil))))
|
||||
(print_stmt_trailer
|
||||
((test_list_opt)
|
||||
nil)
|
||||
((GTGT test trailing_test_list_with_opt_comma_opt)
|
||||
nil))
|
||||
(trailing_test_list_with_opt_comma_opt
|
||||
(nil)
|
||||
((trailing_test_list comma_opt)
|
||||
nil))
|
||||
(trailing_test_list
|
||||
((COMMA test)
|
||||
nil)
|
||||
((trailing_test_list COMMA test)
|
||||
nil))
|
||||
(expr_stmt
|
||||
((testlist expr_stmt_trailer)
|
||||
(if
|
||||
(and $2
|
||||
(stringp $1)
|
||||
(string-match "^\\(\\sw\\|\\s_\\)+$" $1))
|
||||
(wisent-raw-tag
|
||||
(semantic-tag-new-variable $1 nil nil))
|
||||
(wisent-raw-tag
|
||||
(semantic-tag-new-code $1 nil)))))
|
||||
(expr_stmt_trailer
|
||||
((augassign testlist))
|
||||
((eq_testlist_zom)))
|
||||
(eq_testlist_zom
|
||||
(nil)
|
||||
((eq_testlist_zom ASSIGN testlist)
|
||||
(identity $3)))
|
||||
(augassign
|
||||
((PLUSEQ))
|
||||
((MINUSEQ))
|
||||
((MULTEQ))
|
||||
((DIVEQ))
|
||||
((MODEQ))
|
||||
((AMPEQ))
|
||||
((OREQ))
|
||||
((HATEQ))
|
||||
((LTLTEQ))
|
||||
((GTGTEQ))
|
||||
((EXPEQ))
|
||||
((DIVDIVEQ)))
|
||||
(del_stmt
|
||||
((DEL exprlist)
|
||||
(wisent-raw-tag
|
||||
(semantic-tag-new-code $1 nil))))
|
||||
(exprlist
|
||||
((expr_list comma_opt)
|
||||
nil))
|
||||
(expr_list
|
||||
((expr)
|
||||
nil)
|
||||
((expr_list COMMA expr)
|
||||
nil))
|
||||
(pass_stmt
|
||||
((PASS)
|
||||
(wisent-raw-tag
|
||||
(semantic-tag-new-code $1 nil))))
|
||||
(flow_stmt
|
||||
((break_stmt))
|
||||
((continue_stmt))
|
||||
((return_stmt))
|
||||
((raise_stmt))
|
||||
((yield_stmt)))
|
||||
(break_stmt
|
||||
((BREAK)
|
||||
(wisent-raw-tag
|
||||
(semantic-tag-new-code $1 nil))))
|
||||
(continue_stmt
|
||||
((CONTINUE)
|
||||
(wisent-raw-tag
|
||||
(semantic-tag-new-code $1 nil))))
|
||||
(return_stmt
|
||||
((RETURN testlist_opt)
|
||||
(wisent-raw-tag
|
||||
(semantic-tag-new-code $1 nil))))
|
||||
(testlist_opt
|
||||
(nil)
|
||||
((testlist)
|
||||
nil))
|
||||
(yield_stmt
|
||||
((YIELD)
|
||||
(wisent-raw-tag
|
||||
(semantic-tag-new-code $1 nil)))
|
||||
((YIELD testlist)
|
||||
(wisent-raw-tag
|
||||
(semantic-tag-new-code $1 nil))))
|
||||
(raise_stmt
|
||||
((RAISE zero_one_two_or_three_tests)
|
||||
(wisent-raw-tag
|
||||
(semantic-tag-new-code $1 nil))))
|
||||
(zero_one_two_or_three_tests
|
||||
(nil)
|
||||
((test zero_one_or_two_tests)
|
||||
nil))
|
||||
(zero_one_or_two_tests
|
||||
(nil)
|
||||
((COMMA test zero_or_one_comma_test)
|
||||
nil))
|
||||
(zero_or_one_comma_test
|
||||
(nil)
|
||||
((COMMA test)
|
||||
nil))
|
||||
(import_stmt
|
||||
((IMPORT dotted_as_name_list)
|
||||
(wisent-raw-tag
|
||||
(semantic-tag-new-include $2 nil)))
|
||||
((FROM dotted_name IMPORT star_or_import_as_name_list)
|
||||
(wisent-raw-tag
|
||||
(semantic-tag-new-include $2 nil))))
|
||||
(dotted_as_name_list
|
||||
((dotted_as_name_list COMMA dotted_as_name)
|
||||
(cons $3 $1))
|
||||
((dotted_as_name)
|
||||
(list $1)))
|
||||
(star_or_import_as_name_list
|
||||
((MULT)
|
||||
nil)
|
||||
((import_as_name_list)
|
||||
nil))
|
||||
(import_as_name_list
|
||||
((import_as_name)
|
||||
nil)
|
||||
((import_as_name_list COMMA import_as_name)
|
||||
nil))
|
||||
(import_as_name
|
||||
((NAME as_name_opt)
|
||||
nil))
|
||||
(dotted_as_name
|
||||
((dotted_name as_name_opt)))
|
||||
(as_name_opt
|
||||
(nil)
|
||||
((AS NAME)
|
||||
(identity $2)))
|
||||
(dotted_name
|
||||
((NAME))
|
||||
((dotted_name PERIOD NAME)
|
||||
(format "%s.%s" $1 $3)))
|
||||
(global_stmt
|
||||
((GLOBAL comma_sep_name_list)
|
||||
(wisent-raw-tag
|
||||
(semantic-tag-new-code $1 nil))))
|
||||
(comma_sep_name_list
|
||||
((NAME))
|
||||
((comma_sep_name_list COMMA NAME)))
|
||||
(exec_stmt
|
||||
((EXEC expr exec_trailer)
|
||||
(wisent-raw-tag
|
||||
(semantic-tag-new-code $1 nil))))
|
||||
(exec_trailer
|
||||
(nil)
|
||||
((IN test comma_test_opt)
|
||||
nil))
|
||||
(comma_test_opt
|
||||
(nil)
|
||||
((COMMA test)
|
||||
nil))
|
||||
(assert_stmt
|
||||
((ASSERT test comma_test_opt)
|
||||
(wisent-raw-tag
|
||||
(semantic-tag-new-code $1 nil))))
|
||||
(compound_stmt
|
||||
((if_stmt))
|
||||
((while_stmt))
|
||||
((for_stmt))
|
||||
((try_stmt))
|
||||
((with_stmt))
|
||||
((funcdef))
|
||||
((class_declaration)))
|
||||
(if_stmt
|
||||
((IF test COLON suite elif_suite_pair_list else_suite_pair_opt)
|
||||
(wisent-raw-tag
|
||||
(semantic-tag-new-code $1 nil))))
|
||||
(elif_suite_pair_list
|
||||
(nil)
|
||||
((elif_suite_pair_list ELIF test COLON suite)
|
||||
nil))
|
||||
(else_suite_pair_opt
|
||||
(nil)
|
||||
((ELSE COLON suite)
|
||||
nil))
|
||||
(suite
|
||||
((simple_stmt)
|
||||
(list $1))
|
||||
((NEWLINE indented_block)
|
||||
(progn $2)))
|
||||
(indented_block
|
||||
((INDENT_BLOCK)
|
||||
(semantic-parse-region
|
||||
(car $region1)
|
||||
(cdr $region1)
|
||||
'indented_block_body 1)))
|
||||
(indented_block_body
|
||||
((INDENT)
|
||||
nil)
|
||||
((DEDENT)
|
||||
nil)
|
||||
((simple_stmt))
|
||||
((compound_stmt)))
|
||||
(while_stmt
|
||||
((WHILE test COLON suite else_suite_pair_opt)
|
||||
(wisent-raw-tag
|
||||
(semantic-tag-new-code $1 nil))))
|
||||
(for_stmt
|
||||
((FOR exprlist IN testlist COLON suite else_suite_pair_opt)
|
||||
(wisent-raw-tag
|
||||
(semantic-tag-new-code $1 nil))))
|
||||
(try_stmt
|
||||
((TRY COLON suite except_clause_suite_pair_list else_suite_pair_opt)
|
||||
(wisent-raw-tag
|
||||
(semantic-tag-new-code $1 nil)))
|
||||
((TRY COLON suite FINALLY COLON suite)
|
||||
(wisent-raw-tag
|
||||
(semantic-tag-new-code $1 nil))))
|
||||
(except_clause_suite_pair_list
|
||||
((except_clause COLON suite)
|
||||
nil)
|
||||
((except_clause_suite_pair_list except_clause COLON suite)
|
||||
nil))
|
||||
(except_clause
|
||||
((EXCEPT zero_one_or_two_test)
|
||||
nil))
|
||||
(zero_one_or_two_test
|
||||
(nil)
|
||||
((test zero_or_one_comma_test)
|
||||
nil))
|
||||
(with_stmt
|
||||
((WITH test COLON suite)
|
||||
(wisent-raw-tag
|
||||
(semantic-tag-new-code $1 nil)))
|
||||
((WITH test with_var COLON suite)
|
||||
(wisent-raw-tag
|
||||
(semantic-tag-new-code $1 nil))))
|
||||
(with_var
|
||||
((AS expr)
|
||||
nil))
|
||||
(decorator
|
||||
((AT dotted_name varargslist_opt NEWLINE)
|
||||
(wisent-raw-tag
|
||||
(semantic-tag-new-function $2 "decorator" $3))))
|
||||
(decorators
|
||||
((decorator)
|
||||
(list $1))
|
||||
((decorator decorators)
|
||||
(cons $1 $2)))
|
||||
(funcdef
|
||||
((DEF NAME function_parameter_list COLON suite)
|
||||
(wisent-python-reconstitute-function-tag
|
||||
(wisent-raw-tag
|
||||
(semantic-tag-new-function $2 nil $3))
|
||||
$5))
|
||||
((decorators DEF NAME function_parameter_list COLON suite)
|
||||
(wisent-python-reconstitute-function-tag
|
||||
(wisent-raw-tag
|
||||
(semantic-tag-new-function $3 nil $4 :decorators $1))
|
||||
$6)))
|
||||
(function_parameter_list
|
||||
((PAREN_BLOCK)
|
||||
(let
|
||||
((wisent-python-EXPANDING-block t))
|
||||
(semantic-parse-region
|
||||
(car $region1)
|
||||
(cdr $region1)
|
||||
'function_parameters 1))))
|
||||
(function_parameters
|
||||
((LPAREN)
|
||||
nil)
|
||||
((RPAREN)
|
||||
nil)
|
||||
((function_parameter COMMA))
|
||||
((function_parameter RPAREN)))
|
||||
(function_parameter
|
||||
((fpdef_opt_test))
|
||||
((MULT NAME)
|
||||
(wisent-raw-tag
|
||||
(semantic-tag-new-variable $2 nil nil)))
|
||||
((EXPONENT NAME)
|
||||
(wisent-raw-tag
|
||||
(semantic-tag-new-variable $2 nil nil))))
|
||||
(class_declaration
|
||||
((CLASS NAME paren_class_list_opt COLON suite)
|
||||
(wisent-python-reconstitute-class-tag
|
||||
(wisent-raw-tag
|
||||
(semantic-tag-new-type $2 $1 $5
|
||||
(cons $3 nil))))))
|
||||
(paren_class_list_opt
|
||||
(nil)
|
||||
((paren_class_list)))
|
||||
(paren_class_list
|
||||
((PAREN_BLOCK)
|
||||
(let
|
||||
((wisent-python-EXPANDING-block t))
|
||||
(mapcar 'semantic-tag-name
|
||||
(semantic-parse-region
|
||||
(car $region1)
|
||||
(cdr $region1)
|
||||
'paren_classes 1)))))
|
||||
(paren_classes
|
||||
((LPAREN)
|
||||
nil)
|
||||
((RPAREN)
|
||||
nil)
|
||||
((paren_class COMMA)
|
||||
(wisent-raw-tag
|
||||
(semantic-tag-new-variable $1 nil nil)))
|
||||
((paren_class RPAREN)
|
||||
(wisent-raw-tag
|
||||
(semantic-tag-new-variable $1 nil nil))))
|
||||
(paren_class
|
||||
((dotted_name)))
|
||||
(test
|
||||
((test_test))
|
||||
((lambdef)))
|
||||
(test_test
|
||||
((and_test))
|
||||
((test_test OR and_test)
|
||||
nil))
|
||||
(and_test
|
||||
((not_test))
|
||||
((and_test AND not_test)
|
||||
nil))
|
||||
(not_test
|
||||
((NOT not_test)
|
||||
nil)
|
||||
((comparison)))
|
||||
(comparison
|
||||
((expr))
|
||||
((comparison comp_op expr)
|
||||
nil))
|
||||
(comp_op
|
||||
((LT))
|
||||
((GT))
|
||||
((EQ))
|
||||
((GE))
|
||||
((LE))
|
||||
((LTGT))
|
||||
((NE))
|
||||
((IN))
|
||||
((NOT IN))
|
||||
((IS))
|
||||
((IS NOT)))
|
||||
(expr
|
||||
((xor_expr))
|
||||
((expr BAR xor_expr)
|
||||
nil))
|
||||
(xor_expr
|
||||
((and_expr))
|
||||
((xor_expr HAT and_expr)
|
||||
nil))
|
||||
(and_expr
|
||||
((shift_expr))
|
||||
((and_expr AMP shift_expr)
|
||||
nil))
|
||||
(shift_expr
|
||||
((arith_expr))
|
||||
((shift_expr shift_expr_operators arith_expr)
|
||||
nil))
|
||||
(shift_expr_operators
|
||||
((LTLT))
|
||||
((GTGT)))
|
||||
(arith_expr
|
||||
((term))
|
||||
((arith_expr plus_or_minus term)
|
||||
nil))
|
||||
(plus_or_minus
|
||||
((PLUS))
|
||||
((MINUS)))
|
||||
(term
|
||||
((factor))
|
||||
((term term_operator factor)
|
||||
nil))
|
||||
(term_operator
|
||||
((MULT))
|
||||
((DIV))
|
||||
((MOD))
|
||||
((DIVDIV)))
|
||||
(factor
|
||||
((prefix_operators factor)
|
||||
nil)
|
||||
((power)))
|
||||
(prefix_operators
|
||||
((PLUS))
|
||||
((MINUS))
|
||||
((TILDE)))
|
||||
(power
|
||||
((atom trailer_zom exponent_zom)
|
||||
(concat $1
|
||||
(if $2
|
||||
(concat " " $2 " ")
|
||||
"")
|
||||
(if $3
|
||||
(concat " " $3)
|
||||
""))))
|
||||
(trailer_zom
|
||||
(nil)
|
||||
((trailer_zom trailer)
|
||||
nil))
|
||||
(exponent_zom
|
||||
(nil)
|
||||
((exponent_zom EXPONENT factor)
|
||||
nil))
|
||||
(trailer
|
||||
((PAREN_BLOCK)
|
||||
nil)
|
||||
((BRACK_BLOCK)
|
||||
nil)
|
||||
((PERIOD NAME)
|
||||
nil))
|
||||
(atom
|
||||
((PAREN_BLOCK)
|
||||
nil)
|
||||
((BRACK_BLOCK)
|
||||
nil)
|
||||
((BRACE_BLOCK)
|
||||
nil)
|
||||
((BACKQUOTE testlist BACKQUOTE)
|
||||
nil)
|
||||
((NAME))
|
||||
((NUMBER_LITERAL))
|
||||
((one_or_more_string)))
|
||||
(test_list_opt
|
||||
(nil)
|
||||
((testlist)
|
||||
nil))
|
||||
(testlist
|
||||
((comma_sep_test_list comma_opt)))
|
||||
(comma_sep_test_list
|
||||
((test))
|
||||
((comma_sep_test_list COMMA test)
|
||||
(format "%s, %s" $1 $3)))
|
||||
(one_or_more_string
|
||||
((STRING_LITERAL))
|
||||
((one_or_more_string STRING_LITERAL)
|
||||
(concat $1 $2)))
|
||||
(lambdef
|
||||
((LAMBDA varargslist_opt COLON test)
|
||||
(format "%s %s" $1
|
||||
(or $2 ""))))
|
||||
(varargslist_opt
|
||||
(nil)
|
||||
((varargslist)))
|
||||
(varargslist
|
||||
((fpdef_opt_test_list_comma_zom rest_args)
|
||||
(nconc $2 $1))
|
||||
((fpdef_opt_test_list comma_opt)))
|
||||
(rest_args
|
||||
((MULT NAME multmult_name_opt)
|
||||
nil)
|
||||
((EXPONENT NAME)
|
||||
nil))
|
||||
(multmult_name_opt
|
||||
(nil)
|
||||
((COMMA EXPONENT NAME)
|
||||
(wisent-raw-tag
|
||||
(semantic-tag-new-variable $3 nil nil))))
|
||||
(fpdef_opt_test_list_comma_zom
|
||||
(nil)
|
||||
((fpdef_opt_test_list_comma_zom fpdef_opt_test COMMA)
|
||||
(nconc $2 $1)))
|
||||
(fpdef_opt_test_list
|
||||
((fpdef_opt_test))
|
||||
((fpdef_opt_test_list COMMA fpdef_opt_test)
|
||||
(nconc $3 $1)))
|
||||
(fpdef_opt_test
|
||||
((fpdef eq_test_opt)))
|
||||
(fpdef
|
||||
((NAME)
|
||||
(wisent-raw-tag
|
||||
(semantic-tag-new-variable $1 nil nil))))
|
||||
(fplist
|
||||
((fpdef_list comma_opt)))
|
||||
(fpdef_list
|
||||
((fpdef))
|
||||
((fpdef_list COMMA fpdef)))
|
||||
(eq_test_opt
|
||||
(nil)
|
||||
((ASSIGN test)
|
||||
nil))
|
||||
(comma_opt
|
||||
(nil)
|
||||
((COMMA)))
|
||||
(semicolon_opt
|
||||
(nil)
|
||||
((SEMICOLON))))
|
||||
'(goal function_parameter paren_class indented_block function_parameters paren_classes indented_block_body)))
|
||||
"Parser table.")
|
||||
|
||||
(defun wisent-python-wy--install-parser ()
|
||||
"Setup the Semantic Parser."
|
||||
(semantic-install-function-overrides
|
||||
'((parse-stream . wisent-parse-stream)))
|
||||
(setq semantic-parser-name "LALR"
|
||||
semantic--parse-table wisent-python-wy--parse-table
|
||||
semantic-debug-parser-source "python.wy"
|
||||
semantic-flex-keywords-obarray wisent-python-wy--keyword-table
|
||||
semantic-lex-types-obarray wisent-python-wy--token-table)
|
||||
;; Collect unmatched syntax lexical tokens
|
||||
(semantic-make-local-hook 'wisent-discarding-token-functions)
|
||||
(add-hook 'wisent-discarding-token-functions
|
||||
'wisent-collect-unmatched-syntax nil t))
|
||||
|
||||
|
||||
;;; Analyzers
|
||||
;;
|
||||
(define-lex-block-type-analyzer wisent-python-wy--<block>-block-analyzer
|
||||
"block analyzer for <block> tokens."
|
||||
"\\s(\\|\\s)"
|
||||
'((("(" LPAREN PAREN_BLOCK)
|
||||
("{" LBRACE BRACE_BLOCK)
|
||||
("[" LBRACK BRACK_BLOCK))
|
||||
(")" RPAREN)
|
||||
("}" RBRACE)
|
||||
("]" RBRACK))
|
||||
)
|
||||
|
||||
(define-lex-regex-type-analyzer wisent-python-wy--<symbol>-regexp-analyzer
|
||||
"regexp analyzer for <symbol> tokens."
|
||||
"\\(\\sw\\|\\s_\\)+"
|
||||
nil
|
||||
'NAME)
|
||||
|
||||
(define-lex-regex-type-analyzer wisent-python-wy--<number>-regexp-analyzer
|
||||
"regexp analyzer for <number> tokens."
|
||||
semantic-lex-number-expression
|
||||
nil
|
||||
'NUMBER_LITERAL)
|
||||
|
||||
(define-lex-string-type-analyzer wisent-python-wy--<punctuation>-string-analyzer
|
||||
"string analyzer for <punctuation> tokens."
|
||||
"\\(\\s.\\|\\s$\\|\\s'\\)+"
|
||||
'((AT . "@")
|
||||
(BACKQUOTE . "`")
|
||||
(ASSIGN . "=")
|
||||
(COMMA . ",")
|
||||
(SEMICOLON . ";")
|
||||
(COLON . ":")
|
||||
(BAR . "|")
|
||||
(TILDE . "~")
|
||||
(PERIOD . ".")
|
||||
(MINUS . "-")
|
||||
(PLUS . "+")
|
||||
(MOD . "%")
|
||||
(DIV . "/")
|
||||
(MULT . "*")
|
||||
(AMP . "&")
|
||||
(GT . ">")
|
||||
(LT . "<")
|
||||
(HAT . "^")
|
||||
(NE . "!=")
|
||||
(LTGT . "<>")
|
||||
(HATEQ . "^=")
|
||||
(OREQ . "|=")
|
||||
(AMPEQ . "&=")
|
||||
(MODEQ . "%=")
|
||||
(DIVEQ . "/=")
|
||||
(MULTEQ . "*=")
|
||||
(MINUSEQ . "-=")
|
||||
(PLUSEQ . "+=")
|
||||
(LE . "<=")
|
||||
(GE . ">=")
|
||||
(EQ . "==")
|
||||
(EXPONENT . "**")
|
||||
(GTGT . ">>")
|
||||
(LTLT . "<<")
|
||||
(DIVDIV . "//")
|
||||
(DIVDIVEQ . "//=")
|
||||
(EXPEQ . "**=")
|
||||
(GTGTEQ . ">>=")
|
||||
(LTLTEQ . "<<="))
|
||||
'punctuation)
|
||||
|
||||
(define-lex-keyword-type-analyzer wisent-python-wy--<keyword>-keyword-analyzer
|
||||
"keyword analyzer for <keyword> tokens."
|
||||
"\\(\\sw\\|\\s_\\)+")
|
||||
|
||||
|
||||
;;; Epilogue
|
||||
;;
|
||||
|
||||
(provide 'semantic/wisent/python-wy)
|
||||
|
||||
;;; semantic/wisent/python-wy.el ends here
|
@ -1,306 +0,0 @@
|
||||
;;; srecode/srt-wy.el --- Generated parser support file
|
||||
|
||||
;; Copyright (C) 2005, 2007-2013 Free Software Foundation, Inc.
|
||||
|
||||
;; 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:
|
||||
;;
|
||||
;; This file was generated from admin/grammars/srecode-template.wy.
|
||||
|
||||
;;; Code:
|
||||
|
||||
(require 'semantic/lex)
|
||||
(eval-when-compile (require 'semantic/bovine))
|
||||
|
||||
;;; Prologue
|
||||
;;
|
||||
|
||||
;;; Declarations
|
||||
;;
|
||||
(defconst srecode-template-wy--keyword-table
|
||||
(semantic-lex-make-keyword-table
|
||||
'(("set" . SET)
|
||||
("show" . SHOW)
|
||||
("macro" . MACRO)
|
||||
("context" . CONTEXT)
|
||||
("template" . TEMPLATE)
|
||||
("sectiondictionary" . SECTIONDICTIONARY)
|
||||
("section" . SECTION)
|
||||
("end" . END)
|
||||
("prompt" . PROMPT)
|
||||
("default" . DEFAULT)
|
||||
("defaultmacro" . DEFAULTMACRO)
|
||||
("read" . READ)
|
||||
("bind" . BIND))
|
||||
'(("bind" summary "bind \"<letter>\"")
|
||||
("read" summary "prompt <symbol> \"Describe Symbol: \" [default[macro] <lispsym>|\"valuetext\"] [read <lispsym>]")
|
||||
("defaultmacro" summary "prompt <symbol> \"Describe Symbol: \" [default[macro] <lispsym>|\"valuetext\"] [read <lispsym>]")
|
||||
("default" summary "prompt <symbol> \"Describe Symbol: \" [default[macro] <lispsym>|\"valuetext\"] [read <lispsym>]")
|
||||
("prompt" summary "prompt <symbol> \"Describe Symbol: \" [default[macro] <lispsym>|\"valuetext\"] [read <lispsym>]")
|
||||
("end" summary "section ... end")
|
||||
("section" summary "section <name>\\n <dictionary entries>\\n end")
|
||||
("sectiondictionary" summary "sectiondictionary <name>\\n <dictionary entries>")
|
||||
("template" summary "template <name>\\n <template definition>")
|
||||
("context" summary "context <name>")
|
||||
("macro" summary "... macro \"string\" ...")
|
||||
("show" summary "show <name> ; to show a section")
|
||||
("set" summary "set <name> <value>")))
|
||||
"Table of language keywords.")
|
||||
|
||||
(defconst srecode-template-wy--token-table
|
||||
(semantic-lex-make-type-table
|
||||
'(("number"
|
||||
(number))
|
||||
("string"
|
||||
(string))
|
||||
("symbol"
|
||||
(symbol))
|
||||
("property"
|
||||
(property))
|
||||
("separator"
|
||||
(TEMPLATE_BLOCK . "^----"))
|
||||
("newline"
|
||||
(newline)))
|
||||
'(("number" :declared t)
|
||||
("string" :declared t)
|
||||
("symbol" :declared t)
|
||||
("property" syntax ":\\(\\w\\|\\s_\\)*")
|
||||
("property" :declared t)
|
||||
("newline" :declared t)
|
||||
("punctuation" syntax "\\s.+")
|
||||
("punctuation" :declared t)
|
||||
("keyword" :declared t)))
|
||||
"Table of lexical tokens.")
|
||||
|
||||
(defconst srecode-template-wy--parse-table
|
||||
(progn
|
||||
(eval-when-compile
|
||||
(require 'semantic/wisent/comp))
|
||||
(wisent-compile-grammar
|
||||
'((SET SHOW MACRO CONTEXT TEMPLATE SECTIONDICTIONARY SECTION END PROMPT DEFAULT DEFAULTMACRO READ BIND newline TEMPLATE_BLOCK property symbol string number)
|
||||
nil
|
||||
(template_file
|
||||
((newline)
|
||||
nil)
|
||||
((context))
|
||||
((prompt))
|
||||
((variable))
|
||||
((template)))
|
||||
(context
|
||||
((CONTEXT symbol newline)
|
||||
(wisent-raw-tag
|
||||
(semantic-tag $2 'context))))
|
||||
(prompt
|
||||
((PROMPT symbol string opt-default-fcn opt-read-fcn newline)
|
||||
(wisent-raw-tag
|
||||
(semantic-tag $2 'prompt :text
|
||||
(read $3)
|
||||
:default $4 :read $5))))
|
||||
(opt-default-fcn
|
||||
((DEFAULT symbol)
|
||||
(progn
|
||||
(read $2)))
|
||||
((DEFAULT string)
|
||||
(progn
|
||||
(read $2)))
|
||||
((DEFAULTMACRO string)
|
||||
(progn
|
||||
(cons 'macro
|
||||
(read $2))))
|
||||
(nil nil))
|
||||
(opt-read-fcn
|
||||
((READ symbol)
|
||||
(progn
|
||||
(read $2)))
|
||||
(nil nil))
|
||||
(variable
|
||||
((SET symbol insertable-string-list newline)
|
||||
(wisent-raw-tag
|
||||
(semantic-tag-new-variable $2 nil $3)))
|
||||
((SET symbol number newline)
|
||||
(wisent-raw-tag
|
||||
(semantic-tag-new-variable $2 nil
|
||||
(list $3))))
|
||||
((SHOW symbol newline)
|
||||
(wisent-raw-tag
|
||||
(semantic-tag-new-variable $2 nil t))))
|
||||
(insertable-string-list
|
||||
((insertable-string)
|
||||
(list $1))
|
||||
((insertable-string-list insertable-string)
|
||||
(append $1
|
||||
(list $2))))
|
||||
(insertable-string
|
||||
((string)
|
||||
(read $1))
|
||||
((MACRO string)
|
||||
(cons 'macro
|
||||
(read $2))))
|
||||
(template
|
||||
((TEMPLATE templatename opt-dynamic-arguments newline opt-string section-dictionary-list TEMPLATE_BLOCK newline opt-bind)
|
||||
(wisent-raw-tag
|
||||
(semantic-tag-new-function $2 nil $3 :documentation $5 :code $7 :dictionaries $6 :binding $9))))
|
||||
(templatename
|
||||
((symbol))
|
||||
((PROMPT))
|
||||
((CONTEXT))
|
||||
((TEMPLATE))
|
||||
((DEFAULT))
|
||||
((MACRO))
|
||||
((DEFAULTMACRO))
|
||||
((READ))
|
||||
((SET)))
|
||||
(opt-dynamic-arguments
|
||||
((property opt-dynamic-arguments)
|
||||
(cons $1 $2))
|
||||
(nil nil))
|
||||
(opt-string
|
||||
((string newline)
|
||||
(read $1))
|
||||
(nil nil))
|
||||
(section-dictionary-list
|
||||
(nil nil)
|
||||
((section-dictionary-list flat-section-dictionary)
|
||||
(append $1
|
||||
(list $2)))
|
||||
((section-dictionary-list section-dictionary)
|
||||
(append $1
|
||||
(list $2))))
|
||||
(flat-section-dictionary
|
||||
((SECTIONDICTIONARY string newline flat-dictionary-entry-list)
|
||||
(cons
|
||||
(read $2)
|
||||
$4)))
|
||||
(flat-dictionary-entry-list
|
||||
(nil nil)
|
||||
((flat-dictionary-entry-list flat-dictionary-entry)
|
||||
(append $1 $2)))
|
||||
(flat-dictionary-entry
|
||||
((variable)
|
||||
(wisent-cook-tag $1)))
|
||||
(section-dictionary
|
||||
((SECTION string newline dictionary-entry-list END newline)
|
||||
(cons
|
||||
(read $2)
|
||||
$4)))
|
||||
(dictionary-entry-list
|
||||
(nil nil)
|
||||
((dictionary-entry-list dictionary-entry)
|
||||
(append $1 $2)))
|
||||
(dictionary-entry
|
||||
((variable)
|
||||
(wisent-cook-tag $1))
|
||||
((section-dictionary)
|
||||
(list $1)))
|
||||
(opt-bind
|
||||
((BIND string newline)
|
||||
(read $2))
|
||||
(nil nil)))
|
||||
'(template_file)))
|
||||
"Parser table.")
|
||||
|
||||
(defun srecode-template-wy--install-parser ()
|
||||
"Setup the Semantic Parser."
|
||||
(semantic-install-function-overrides
|
||||
'((parse-stream . wisent-parse-stream)))
|
||||
(setq semantic-parser-name "LALR"
|
||||
semantic--parse-table srecode-template-wy--parse-table
|
||||
semantic-debug-parser-source "srecode-template.wy"
|
||||
semantic-flex-keywords-obarray srecode-template-wy--keyword-table
|
||||
semantic-lex-types-obarray srecode-template-wy--token-table)
|
||||
;; Collect unmatched syntax lexical tokens
|
||||
(semantic-make-local-hook 'wisent-discarding-token-functions)
|
||||
(add-hook 'wisent-discarding-token-functions
|
||||
'wisent-collect-unmatched-syntax nil t))
|
||||
|
||||
|
||||
;;; Analyzers
|
||||
;;
|
||||
(define-lex-regex-type-analyzer srecode-template-wy--<property>-regexp-analyzer
|
||||
"regexp analyzer for <property> tokens."
|
||||
":\\(\\w\\|\\s_\\)*"
|
||||
nil
|
||||
'property)
|
||||
|
||||
(define-lex-regex-type-analyzer srecode-template-wy--<symbol>-regexp-analyzer
|
||||
"regexp analyzer for <symbol> tokens."
|
||||
"\\(\\sw\\|\\s_\\)+"
|
||||
nil
|
||||
'symbol)
|
||||
|
||||
(define-lex-regex-type-analyzer srecode-template-wy--<number>-regexp-analyzer
|
||||
"regexp analyzer for <number> tokens."
|
||||
semantic-lex-number-expression
|
||||
nil
|
||||
'number)
|
||||
|
||||
(define-lex-string-type-analyzer srecode-template-wy--<punctuation>-string-analyzer
|
||||
"string analyzer for <punctuation> tokens."
|
||||
"\\s.+"
|
||||
nil
|
||||
'punctuation)
|
||||
|
||||
(define-lex-sexp-type-analyzer srecode-template-wy--<string>-sexp-analyzer
|
||||
"sexp analyzer for <string> tokens."
|
||||
"\\s\""
|
||||
'string)
|
||||
|
||||
(define-lex-keyword-type-analyzer srecode-template-wy--<keyword>-keyword-analyzer
|
||||
"keyword analyzer for <keyword> tokens."
|
||||
"\\(\\sw\\|\\s_\\)+")
|
||||
|
||||
|
||||
;;; Epilogue
|
||||
;;
|
||||
(define-lex-simple-regex-analyzer srecode-template-property-analyzer
|
||||
"Detect and create a dynamic argument properties."
|
||||
":\\(\\w\\|\\s_\\)*" 'property 0)
|
||||
|
||||
(define-lex-regex-analyzer srecode-template-separator-block
|
||||
"Detect and create a template quote block."
|
||||
"^----\n"
|
||||
(semantic-lex-push-token
|
||||
(semantic-lex-token
|
||||
'TEMPLATE_BLOCK
|
||||
(match-end 0)
|
||||
(semantic-lex-unterminated-syntax-protection 'TEMPLATE_BLOCK
|
||||
(goto-char (match-end 0))
|
||||
(re-search-forward "^----$")
|
||||
(match-beginning 0))))
|
||||
(setq semantic-lex-end-point (point)))
|
||||
|
||||
|
||||
(define-lex wisent-srecode-template-lexer
|
||||
"Lexical analyzer that handles SRecode Template buffers.
|
||||
It ignores whitespace, newlines and comments."
|
||||
semantic-lex-newline
|
||||
semantic-lex-ignore-whitespace
|
||||
semantic-lex-ignore-newline
|
||||
semantic-lex-ignore-comments
|
||||
srecode-template-separator-block
|
||||
srecode-template-wy--<keyword>-keyword-analyzer
|
||||
srecode-template-property-analyzer
|
||||
srecode-template-wy--<number>-regexp-analyzer
|
||||
srecode-template-wy--<symbol>-regexp-analyzer
|
||||
srecode-template-wy--<string>-sexp-analyzer
|
||||
srecode-template-wy--<punctuation>-string-analyzer
|
||||
semantic-lex-default-action
|
||||
)
|
||||
|
||||
(provide 'srecode/srt-wy)
|
||||
|
||||
;;; srecode/srt-wy.el ends here
|
Loading…
Reference in New Issue
Block a user