123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198 |
- (require 'semantic)
- (require 'ede/proj)
- (require 'ede/pmake)
- (require 'ede/pconf)
- (require 'ede/proj-elisp)
- (require 'semantic/grammar)
- (defclass semantic-ede-proj-target-grammar (ede-proj-target-makefile)
- ((menu :initform nil)
- (keybindings :initform nil)
- (phony :initform t)
- (sourcetype :initform
- (semantic-ede-source-grammar-wisent
- semantic-ede-source-grammar-bovine
- ))
- (availablecompilers :initform
- (semantic-ede-grammar-compiler-wisent
- semantic-ede-grammar-compiler-bovine
- ))
- )
- "This target consists of a group of grammar files.
- A grammar target consists of grammar files that build Emacs Lisp programs for
- parsing different languages.")
- (defvar semantic-ede-source-grammar-wisent
- (ede-sourcecode "semantic-ede-grammar-source-wisent"
- :name "Wisent Grammar"
- :sourcepattern "\\.wy$"
- )
- "Semantic Grammar source code definition for wisent.")
- (defclass semantic-ede-grammar-compiler-class (ede-compiler)
- nil
- "Specialized compiler for semantic grammars.")
- (defvar semantic-ede-grammar-compiler-wisent
- (semantic-ede-grammar-compiler-class
- "ede-emacs-wisent-compiler"
- :name "emacs"
- :variables '(("EMACS" . "emacs"))
- :commands
- '(
- "@echo \"(add-to-list 'load-path nil)\" > grammar-make-script"
- "@for loadpath in . ${LOADPATH}; do \\"
- " echo \"(add-to-list 'load-path \\\"$$loadpath\\\")\" >> grammar-make-script; \\"
- "done;"
- "@echo \"(require 'semantic/load)\" >> grammar-make-script"
- "@echo \"(require 'semantic/grammar)\" >> grammar-make-script"
-
- "\"$(EMACS)\" -batch --no-site-file -l grammar-make-script -f semantic-grammar-batch-build-packages $^"
- )
-
- :sourcetype '(semantic-ede-source-grammar-wisent)
- :objectextention "-wy.elc"
- )
- "Compile Emacs Lisp programs.")
- (defvar semantic-ede-source-grammar-bovine
- (ede-sourcecode "semantic-ede-grammar-source-bovine"
- :name "Bovine Grammar"
- :sourcepattern "\\.by$"
- )
- "Semantic Grammar source code definition for the bovinator.")
- (defvar semantic-ede-grammar-compiler-bovine
- (semantic-ede-grammar-compiler-class
- "ede-emacs-wisent-compiler"
- :name "emacs"
- :variables '(("EMACS" . "emacs"))
- :commands
- '(
- "@echo \"(add-to-list 'load-path nil)\" > grammar-make-script"
- "@for loadpath in . ${LOADPATH}; do \\"
- " echo \"(add-to-list 'load-path \\\"$$loadpath\\\")\" >> grammar-make-script; \\"
- "done;"
- "@echo \"(require 'semantic/load)\" >> grammar-make-script"
- "@echo \"(require 'semantic/grammar)\" >> grammar-make-script"
-
- "\"$(EMACS)\" -batch --no-site-file -l grammar-make-script -f semantic-grammar-batch-build-packages $^"
- )
-
- :sourcetype '(semantic-ede-source-grammar-bovine)
- :objectextention "-by.elc"
- )
- "Compile Emacs Lisp programs.")
- (defmethod ede-buffer-mine ((this semantic-ede-proj-target-grammar) buffer)
- "Return t if object THIS lays claim to the file in BUFFER.
- Lays claim to all -by.el, and -wy.el files."
-
-
- (if (string-match "-[bw]y\\.elc?$" (buffer-file-name buffer))
- t
- (call-next-method)
- ))
- (defmethod project-compile-target ((obj semantic-ede-proj-target-grammar))
- "Compile all sources in a Lisp target OBJ."
- (let* ((cb (current-buffer))
- (proj (ede-target-parent obj))
- (default-directory (oref proj directory)))
- (mapc (lambda (src)
- (with-current-buffer (find-file-noselect src)
- (save-excursion
- (semantic-grammar-create-package))
- (save-buffer)
- (byte-recompile-file (concat (semantic-grammar-package) ".el") nil 0)))
- (oref obj source)))
- (message "All Semantic Grammar sources are up to date in %s" (object-name obj)))
- (defmethod ede-proj-makefile-sourcevar ((this semantic-ede-proj-target-grammar))
- "Return the variable name for THIS's sources."
- (cond ((ede-proj-automake-p)
- (error "No Automake support for Semantic Grammars"))
- (t (concat (ede-pmake-varname this) "_SEMANTIC_GRAMMAR"))))
- (defmethod ede-proj-makefile-insert-variables :AFTER ((this semantic-ede-proj-target-grammar))
- "Insert variables needed by target THIS."
- (ede-proj-makefile-insert-loadpath-items
- (ede-proj-elisp-packages-to-loadpath
- (list "eieio" "semantic" "inversion" "ede")))
-
-
-
-
- (ede-pmake-insert-variable-shared
- (concat (ede-pmake-varname this) "_SEMANTIC_GRAMMAR_EL")
- (insert
- (mapconcat (lambda (src)
- (with-current-buffer (find-file-noselect src)
- (concat (semantic-grammar-package) ".el")))
- (oref this source)
- " ")))
- )
- (defmethod ede-proj-makefile-insert-rules ((this semantic-ede-proj-target-grammar))
- "Insert rules needed by THIS target."
-
-
- (call-next-method)
- )
- (defmethod ede-proj-makefile-insert-dist-dependencies ((this semantic-ede-proj-target-grammar))
- "Insert dist dependencies, or intermediate targets.
- This makes sure that all grammar lisp files are created before the dist
- runs, so they are always up to date.
- Argument THIS is the target that should insert stuff."
- (call-next-method)
- (insert " $(" (ede-pmake-varname this) "_SEMANTIC_GRAMMAR_EL)")
- )
- (ede-proj-register-target "semantic grammar"
- semantic-ede-proj-target-grammar)
- (provide 'semantic/ede-grammar)
|