Function: antlr-superclasses-glibs

antlr-superclasses-glibs is a byte-compiled function defined in antlr-mode.el.gz.

Signature

(antlr-superclasses-glibs SUPERS CLASSES)

Documentation

Compute the grammar lib option for the super grammars SUPERS.

Look in CLASSES for the right grammar lib files for SUPERS. SUPERS is part SUPER in the result of antlr-file-dependencies. CLASSES is the part (CLASS-SPEC ...) in the result of antlr-directory-dependencies.

The result looks like (OPTION WITH-UNKNOWN GLIB ...). OPTION is the complete "-glib" option. WITH-UNKNOWN is t if there is none or more than one grammar file for at least one super grammar.

Each GLIB looks like (GRAMMAR-FILE . EVOCAB). GRAMMAR-FILE is a file in which a super-grammar is defined. EVOCAB is the value of the export vocabulary of the super-grammar or nil if it is not needed.

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/antlr-mode.el.gz
;;;===========================================================================
;;;  Compilation: run ANTLR tool
;;;===========================================================================

(defun antlr-superclasses-glibs (supers classes)
  "Compute the grammar lib option for the super grammars SUPERS.
Look in CLASSES for the right grammar lib files for SUPERS.  SUPERS is
part SUPER in the result of `antlr-file-dependencies'.  CLASSES is the
part \(CLASS-SPEC ...) in the result of `antlr-directory-dependencies'.

The result looks like \(OPTION WITH-UNKNOWN GLIB ...).  OPTION is the
complete \"-glib\" option.  WITH-UNKNOWN is t if there is none or more
than one grammar file for at least one super grammar.

Each GLIB looks like \(GRAMMAR-FILE . EVOCAB).  GRAMMAR-FILE is a file
in which a super-grammar is defined.  EVOCAB is the value of the export
vocabulary of the super-grammar or nil if it is not needed."
  ;; If the superclass is defined in the same file, that file will be included
  ;; with -glib again.  This will lead to a redefinition.  But defining a
  ;; analyzer of the same class twice in a file will lead to an error anyway...
  (let (glibs unknown)
    (while supers
      (let* ((super (pop supers))
	     (sup-files (cdr (assoc (car super) classes)))
	     (file (and sup-files (null (cdr sup-files)) (car sup-files))))
	(or file (setq unknown t))	; not exactly one file
	(push (cons (or (car file)
			(format (car antlr-unknown-file-formats)
				(car super)))
		    (and (cdr super)
			 (or (cdr file)
			     (format (cadr antlr-unknown-file-formats)
				     (car super)))))
	      glibs)))
    (cons (if glibs (concat " -glib " (mapconcat 'car glibs ";")) "")
	  (cons unknown glibs))))