Commit 469d2149 authored by Chong Yidong's avatar Chong Yidong

Add Semantic grammar files to etc/grammars

parent 096a6052
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 --no-site-file \
-l semantic/bovine -l semantic/wisent -l semantic/grammar \
-l semantic/lex -l bovine-grammar.el \
-f semantic-mode -f semantic-grammar-batch-build-packages *.by
emacs -batch --no-site-file \
-l semantic/bovine -l semantic/wisent -l semantic/grammar \
-l semantic/lex -l wisent-grammar.el \
-f semantic-mode -f semantic-grammar-batch-build-packages *.wy
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.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
;;; semantic/bovine/make.by -- BY notation for Makefiles.
;;
;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2008 Eric M. Ludlam
;;
;; Author: Eric M. Ludlam <zappo@gnu.org>
;;
;; This program 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 2, or (at your option)
;; any later version.
;;
;; This software 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; see the file COPYING. If not, write to the
;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
;; Boston, MA 02110-1301, USA.
;;
%package make-by
%languagemode makefile-mode
%start Makefile
;; This was always a test case.
%quotemode backquote
%token IF "if"
%token IFDEF "ifdef"
%token IFNDEF "ifndef"
%token IFEQ "ifeq"
%token IFNEQ "ifneq"
%token ELSE "else"
%token ENDIF "endif"
%token INCLUDE "include"
%put { IF ELSE ENDIF } summary "Conditional: if (expression) ... else ... endif"
%put IFDEF summary "Conditional: ifdef (expression) ... else ... endif"
%put IFNDEF summary "Conditional: ifndef (expression) ... else ... endif"
%put IFEQ summary "Conditional: ifeq (expression) ... else ... endif"
%put IFNEQ summary "Conditional: ifneq (expression) ... else ... endif"
%put INCLUDE summary "Macro: include filename1 filename2 ..."
%token <punctuation> COLON "\\`[:]\\'"
%token <punctuation> PLUS "\\`[+]\\'"
%token <punctuation> EQUAL "\\`[=]\\'"
%token <punctuation> DOLLAR "\\`[$]\\'"
%token <punctuation> BACKSLASH "\\`[\\]\\'"
%%
Makefile : bol newline (nil)
| bol variable
( ,@$2 )
| bol rule
( ,@$2 )
| bol conditional
( ,@$2 )
| bol include
( ,@$2 )
| whitespace ( nil )
| newline ( nil )
;
variable: symbol opt-whitespace equals opt-whitespace element-list
(VARIABLE-TAG ,$1 nil ,$5)
;
rule: targets opt-whitespace colons opt-whitespace element-list commands
(FUNCTION-TAG ,$1 nil ,$5)
;
targets: target opt-whitespace targets
( (car ,$1) (car ,@$3) )
| target
( (car ,$1) )
;
target: sub-target target
( (concat (car ,$1) (car ,@$3) ) )
| sub-target
( (car ,$1) )
;
sub-target: symbol
| string
| varref
;
conditional: IF some-whitespace symbol newline
( nil )
| IFDEF some-whitespace symbol newline
( nil )
| IFNDEF some-whitespace symbol newline
( nil )
| IFEQ some-whitespace expression newline
( nil )
| IFNEQ some-whitespace expression newline
( nil )
| ELSE newline
( nil )
| ENDIF newline
( nil )
;
expression : semantic-list
;
include: INCLUDE some-whitespace element-list
(INCLUDE-TAG ,$3 nil)
;
equals: COLON EQUAL ()
| PLUS EQUAL ()
| EQUAL ()
;
colons: COLON COLON ()
| COLON ()
;
element-list: elements newline
( ,@$1 )
;
elements: element some-whitespace elements
( ,@$1 ,@$3 )
| element
( ,@$1 )
| ;;EMPTY
;
element: sub-element element
( (concat (car ,$1) (car ,$2)) )
| ;;EMPTY
;
sub-element: symbol
| string
| punctuation
| semantic-list
( (buffer-substring-no-properties
(identity start) (identity end)) )
;
varref: DOLLAR semantic-list
( (buffer-substring-no-properties (identity start) (identity end)) )
;
commands: bol shell-command newline commands
( ,$1 ,@$2 )
| ;;EMPTY
( )
;
opt-whitespace : some-whitespace ( nil )
| ;;EMPTY
;
some-whitespace : whitespace some-whitespace (nil)
| whitespace (nil)
;
;;; semantic/bovine/make.by ends here
This diff is collapsed.
;;; semantic/bovine/scheme.by -- Scheme BNF language specification
;;
;; Copyright (C) 2001, 2003, 2009 Eric M. Ludlam
;;
;; Author: Eric M. Ludlam <zappo@gnu.org>
;;
;; This 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 2, or (at your option)
;; any later version.
;;
;; This software 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; see the file COPYING. If not, write to the
;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
;; Boston, MA 02110-1301, USA.
%package scm-by
%languagemode scheme-mode
%start scheme
%token DEFINE "define"
%token DEFINE-MODULE "define-module"
%token LOAD "load"
%put DEFINE summary "Function: (define symbol expression)"
%put DEFINE-MODULE summary "Function: (define-module (name arg1 ...)) "
%put LOAD summary "Function: (load \"filename\")"
%token <open-paren> OPENPAREN "("
%token <close-paren> CLOSEPAREN ")"
%%
scheme : semantic-list
(EXPAND $1 scheme-list)
;
scheme-list : OPENPAREN scheme-in-list CLOSEPAREN
( ,$2 )
;
scheme-in-list: DEFINE symbol expression
(VARIABLE-TAG $2 nil $3 )
| DEFINE name-args opt-doc sequence
(FUNCTION-TAG (car ,$2) nil (cdr ,$2) )
| DEFINE-MODULE name-args
(PACKAGE-TAG (nth (length $2) $2 ) nil)
| LOAD string
(INCLUDE-TAG (file-name-nondirectory (read $2)) (read $2) )
| symbol
(CODE-TAG $1 nil)
;
name-args: semantic-list
(EXPAND $1 name-arg-expand)
;
name-arg-expand : open-paren name-arg-expand
( ,$2 )
| symbol name-arg-expand
( ,(cons $1 ,$2) )
| ;; EMPTY
( )
;
opt-doc : string
| ;; EMPTY
;
sequence : expression sequence
| expression
;
expression : symbol
| semantic-list
| string
| number
;
;;; semantic/bovine/scheme.by ends here
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment