Skip to content

Commit

Permalink
Rename deftype macro and check-type function as they conflict with ne…
Browse files Browse the repository at this point in the history
…w emacs

builtins.

Run emacs with -Q to prevent any surprise el file loads.

Replace use of removed YYLEX macro with direct call to yylex.
  • Loading branch information
David Gay committed May 10, 2014
1 parent 90641e4 commit da4a548
Show file tree
Hide file tree
Showing 6 changed files with 167 additions and 169 deletions.
2 changes: 1 addition & 1 deletion src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ EXTRA_DIST = \

BISON = bison
FLEX = flex
EMACS = emacs
EMACS = emacs -Q
M4 = m4
GPERF = gperf

Expand Down
50 changes: 24 additions & 26 deletions src/build-basics.el
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
(defmacro deffield (field-name c-type attributes)
`(deffield* ',field-name ',c-type ',attributes))

(defmacro deftype (type-name super-type fields documentation)
`(deftype* ',type-name ',super-type ',fields ',documentation))
(defmacro defntype (type-name super-type fields documentation)
`(defntype* ',type-name ',super-type ',fields ',documentation))

(defmacro defnode (node-name type-name documentation)
`(defnode* ',node-name ',type-name ',documentation))
Expand All @@ -45,59 +45,57 @@
(defun deffield* (field-name c-type attributes)
(setq attributes (attributes-ok field-name attributes))
(if (assoc field-name fields)
(message (format "Field %s already defined" field-name))
(error "Field %s already defined" field-name)
(setq fields (cons (list field-name c-type attributes) fields))))

(defun deftype* (type-name super-type fields documentation)
(if (or (assoc type-name types) (assoc type-name nodes))
(message (format "Name %s already used for a type or node" type-name))
(defun defntype* (type-name super-type fields documentation)
(if (or (assoc type-name types) (assoc type-name nodes))
(error "Name %s already used for a type or node" type-name)
(setq types (cons (list type-name super-type fields documentation) types))))


(defun defnode* (node-name type-name documentation)
(if (or (assoc node-name types) (assoc node-name nodes))
(message (format "Name %s already used for a type or node" node-name))
(if (or (assoc node-name types) (assoc node-name nodes))
(error "Name %s already used for a type or node" node-name)
(setq nodes (cons (list node-name type-name documentation) nodes))))


(setq legal-attributes '(init tree nodump noprint default dump-special print-special format))

(defun attributes-ok (field-name attrs)
(mapcar '(lambda (attr)
(let* ((realattr (if (listp attr) attr (list attr)))
(aname (car realattr)))
(if (not (member aname legal-attributes))
(message (format "Unknown attribute %s in field %s"
aname field-name)))
realattr)) attrs))
(mapcar #'(lambda (attr)
(let* ((realattr (if (listp attr) attr (list attr)))
(aname (car realattr)))
(if (not (member aname legal-attributes))
(error "Unknown attribute %s in field %s" aname field-name))
realattr)) attrs))

(defun check-defs ()
(setq types (reverse types))
(setq nodes (reverse nodes))
(check-types)
(check-ntypes)
(check-nodes))

(defun check-types ()
(mapcar #'check-type types))
(defun check-ntypes ()
(mapcar #'check-ntype types))

(defun check-type (type)
(mapcar '(lambda (field-name)
(if (not (assoc field-name fields))
(message (format "Unknown field %s in %s" field-name (car type)))))
(defun check-ntype (type)
(mapcar #'(lambda (field-name)
(if (not (assoc field-name fields))
(error "Unknown field %s in %s" field-name (car type))))
(type-fields type))
(if (and (type-super-type type)
(not (assoc (type-super-type type) types)))
(message (format "Unknown super-type %s in %s"
(type-super-type type) (type-name type)))))
(error "Unknown super-type %s in %s"
(type-super-type type) (type-name type))))


(defun check-nodes ()
(mapcar #'check-node nodes))

(defun check-node (node)
(if (not (assoc (node-type node) types))
(message (format "Unknown type %s in node %s"
(node-type node) (node-name node)))))
(error "Unknown type %s in node %s" (node-type node) (node-name node))))

(defun build-file (name)
(setq name (concat basename "_" name))
Expand Down
60 changes: 30 additions & 30 deletions src/build-types.el
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
; This file is part of the nesC compiler.
;
; This file is derived from the RC Compiler. It is thus
; Copyright (C) 2000-2001 The Regents of the University of California.
; Changes for nesC are
; Copyright (C) 2002 Intel Corporation
;
; The attached "nesC" software is provided to you under the terms and
; conditions of the GNU General Public License Version 2 as published by the
; Free Software Foundation.
;
; nesC 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 nesC; see the file COPYING. If not, write to
; the Free Software Foundation, 59 Temple Place - Suite 330,
; Boston, MA 02111-1307, USA.
; This file is part of the nesC compiler.
;
; This file is derived from the RC Compiler. It is thus
; Copyright (C) 2000-2001 The Regents of the University of California.
; Changes for nesC are
; Copyright (C) 2002 Intel Corporation
;
; The attached "nesC" software is provided to you under the terms and
; conditions of the GNU General Public License Version 2 as published by the
; Free Software Foundation.
;
; nesC 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 nesC; see the file COPYING. If not, write to
; the Free Software Foundation, 59 Temple Place - Suite 330,
; Boston, MA 02111-1307, USA.

(load-file "build-basics.el")

Expand Down Expand Up @@ -132,16 +132,16 @@
(if (type-super-type type)
(write-fields (assoc (type-super-type type) types))
(ins " %s kind;\n" kind_type))
(mapc '(lambda (field-name)
(let ((field (assoc field-name fields)))
(insert " "
(if (assoc 'format (field-attributes field))
(format (field-c-type field) field-name)
(format "%s %s%s" (field-c-type field)
(if (assoc 'tree (field-attributes field))
"sameregion " "")
field-name))
";\n")))
(mapc #'(lambda (field-name)
(let ((field (assoc field-name fields)))
(insert " "
(if (assoc 'format (field-attributes field))
(format (field-c-type field) field-name)
(format "%s %s%s" (field-c-type field)
(if (assoc 'tree (field-attributes field))
"sameregion " "")
field-name))
";\n")))
(type-fields type)))

(defun write-creator (name type)
Expand Down
4 changes: 2 additions & 2 deletions src/c-parse.y
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Boston, MA 02111-1307, USA. */
/* To whomever it may concern: I have heard that such a thing was once
written by AT&T, but I have never seen it. */

%pure_parser
%pure-parser
%expect 12

%{
Expand Down Expand Up @@ -1159,7 +1159,7 @@ primary:
IDENTIFIER
{
if (yychar == YYEMPTY)
yychar = YYLEX;
yychar = yylex(&yylval);
$$ = make_identifier($1.location, $1.id, yychar == '(');
}
| CONSTANT { $$ = CAST(expression, $1); }
Expand Down
18 changes: 9 additions & 9 deletions src/nesc-dspec.def
Original file line number Diff line number Diff line change
Expand Up @@ -28,33 +28,33 @@
(deffield info "void *" ())
(deffield filter_index int ())

(deftype nd_option nil (name args count)
(defntype nd_option nil (name args count)
"the dump option NAME(ARGS).
ARGS may be NULL
COUNT is the number of elements in ARGS")

(deftype nd_arg nil (next)
(defntype nd_arg nil (next)
"supertype for arguments")

(deftype nd_int nd_arg (val)
(defntype nd_int nd_arg (val)
"an integer argument VAL")

(deftype nd_token nd_arg (str)
(defntype nd_token nd_arg (str)
"some token argument STR")

(deftype nd_filter nd_arg ()
(defntype nd_filter nd_arg ()
"a filter")

(deftype ndf_and nd_filter (filter1 filter2)
(defntype ndf_and nd_filter (filter1 filter2)
"FILTER1 & FILTER2")

(deftype ndf_or nd_filter (filter1 filter2)
(defntype ndf_or nd_filter (filter1 filter2)
"FILTER1 | FILTER2")

(deftype ndf_not nd_filter (filter1)
(defntype ndf_not nd_filter (filter1)
"!FILTER1")

(deftype ndf_op nd_filter (name args count info filter_index)
(defntype ndf_op nd_filter (name args count info filter_index)
"the basic filter NAME(ARGS).
COUNT is the number of elements in ARGS (>= 1)
INFO can be used to save extra information (e.g., compiled regexp info)")
Loading

1 comment on commit da4a548

@fossterer
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Woww! That's real quick! Thanks for the fix

Please sign in to comment.