[CEDET-devel] Some code cleanup for Semantic 2.0
Brought to you by:
zappo
From: David P. <dav...@wa...> - 2003-09-02 11:24:00
|
Hi Eric, In the process of releasing soon the first beta of Semantic 2.0, I made some code cleanup. Here is the change log. The patch is at end. 2003-09-02 David Ponce <da...@dp...> =09* semantic/semantic-util.el =09(semantic-equivalent-major-modes): Doc fix. =09 =09* semantic/semantic.el =09(semantic-toplevel-bovine-table): Doc fix. =09(semantic-toplevel-bovine-table-source): Remove. No more used. =09(semantic-lambda): Move to bovine/semantic-bovine.el. =09(semantic-bovinate-region-until-error) =09(semantic-bovinate-from-nonterminal-full): Make obsolete. =09* semantic/bovine/bovine-grammar.el =09(bovine-grammar-parsetable-builder): Doc fix. =09* semantic/bovine/semantic-bovine.el =09(semantic-lambda): Move here from semantic/semantic.el. =09(semantic-bovinate-nonterminal-db-nt): Doc fix. If you agree with those changes I will commit them. David Index: semantic/semantic-util.el =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvsroot/cedet/cedet/semantic/semantic-util.el,v retrieving revision 1.123 diff -c -r1.123 semantic-util.el *** semantic/semantic-util.el=0929 Aug 2003 16:14:02 -0000=091.123 --- semantic/semantic-util.el=092 Sep 2003 11:19:33 -0000 *************** *** 54,61 **** (defvar semantic-equivalent-major-modes nil "List of major modes which are considered equivalent. Equivalent modes share a parser, and a set of override methods. ! Setup from the BNF code generator. A value of nil means that ! the current major mode is the only one.") (make-variable-buffer-local 'semantic-equivalent-major-modes) =20 ;; These semanticdb calls will throw warnings in the byte compiler. --- 54,60 ---- (defvar semantic-equivalent-major-modes nil "List of major modes which are considered equivalent. Equivalent modes share a parser, and a set of override methods. ! A value of nil means that the current major mode is the only one.") (make-variable-buffer-local 'semantic-equivalent-major-modes) =20 ;; These semanticdb calls will throw warnings in the byte compiler. Index: semantic/semantic.el =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvsroot/cedet/cedet/semantic/semantic.el,v retrieving revision 1.172 diff -c -r1.172 semantic.el *** semantic/semantic.el=091 Apr 2003 20:08:24 -0000=091.172 --- semantic/semantic.el=092 Sep 2003 11:19:33 -0000 *************** *** 74,127 **** ;;; Variables and Configuration ;; (defvar semantic-toplevel-bovine-table nil ! "Variable that defines how to bovinate top level items in a buffer. ! Set this in your major mode to return function and variable semantic ! types. !=20 ! The format of a BOVINE-TABLE is: !=20 ! ( ( NONTERMINAL-SYMBOL1 MATCH-LIST1 ) ! ( NONTERMINAL-SYMBOL2 MATCH-LIST2 ) ! ... ! ( NONTERMINAL-SYMBOLn MATCH-LISTn ) ! =20 ! Where each NONTERMINAL-SYMBOL is an artificial symbol which can appear ! in any child state. As a starting place, one of the NONTERMINAL-SYMBOLS ! must be `bovine-toplevel'. !=20 ! A MATCH-LIST is a list of possible matches of the form: !=20 ! ( STATE-LIST1 ! STATE-LIST2 ! ... ! STATE-LISTN ) !=20 ! where STATE-LIST is of the form: ! ( TYPE1 [ \"VALUE1\" ] TYPE2 [ \"VALUE2\" ] ... LAMBDA ) !=20 ! where TYPE is one of the returned types of the token stream. ! VALUE is a value, or range of values to match against. For ! example, a SYMBOL might need to match \"foo\". Some TYPES will not ! have matching criteria. !=20 ! LAMBDA is a lambda expression which is evaled with the text of the ! type when it is found. It is passed the list of all buffer text ! elements found since the last lambda expression. It should return a ! semantic element (see below.) !=20 ! You can easily avoid learning the format of this variable by ! writing a BNF file. See notes in `semantic-bnf.el' or the ! \"BNF conversion\" section in the semantic texinfo manual. !=20 ! For consistency between languages, try to use common return values ! from your parser. Please reference the \"Semantic Token Style Guide\" ! section in the semantic texinfo manual.") (make-variable-buffer-local 'semantic-toplevel-bovine-table) =20 - (defvar semantic-toplevel-bovine-table-source nil - "The .bnf source file the current table was created from.") - (make-variable-buffer-local 'semantic-toplevel-bovine-table-source) -=20 (defvar semantic-symbol->name-assoc-list '((type . "Types") (variable . "Variables") --- 74,84 ---- ;;; Variables and Configuration ;; (defvar semantic-toplevel-bovine-table nil ! "Variable that defines how to parse top level items in a buffer. ! This variable is for internal use only, and its content depends on the ! external parser used.") (make-variable-buffer-local 'semantic-toplevel-bovine-table) =20 (defvar semantic-symbol->name-assoc-list '((type . "Types") (variable . "Variables") *************** *** 677,699 **** =09 (working-dynamic-status)))) result)) =0C ! ;;; Parser action helper functions ! ;; ! ;; These are functions that can be called from within a bovine table. ! ;; Most of these have code auto-generated from other construct in the ! ;; BNF. ! (defmacro semantic-lambda (&rest return-val) ! "Create a lambda expression to return a list including RETURN-VAL. ! The return list is a lambda expression to be used in a bovine table." ! `(lambda (vals start end) ! (append ,@return-val (list start end)))) ! =0C ! ;;; Backwards Compatible API functions ;; ! ;; Semantic 1.x functions used by some parsers. ! ;; ! ;; Please move away from these functions, and try using ! ;; semantic 2.x interfaces instead. ;; (defsubst semantic-bovinate-region-until-error (start end nonterm &optional depth) --- 634,644 ---- =09 (working-dynamic-status)))) result)) =0C ! ;;; Compatibility: ;; ! ;; Semantic 1.x parser action helper functions, used by some parsers. ! ;; Please move away from these functions, and try using semantic 2.x ! ;; interfaces instead. ;; (defsubst semantic-bovinate-region-until-error (start end nonterm &optional depth) *************** *** 707,712 **** --- 652,659 ---- code blocks in methods. If `bovine-inner-scope' can also support commands, use `semantic-bovinate-from-nonterminal-full'." (semantic-parse-region start end nonterm depth t)) + (make-obsolete 'semantic-bovinate-region-until-error + 'semantic-parse-region) =20 (defsubst semantic-bovinate-from-nonterminal (start end nonterm =09=09=09=09=09=09 &optional depth length) *************** *** 722,728 **** =20 (defsubst semantic-bovinate-from-nonterminal-full (start end nonterm =09=09=09=09=09=09 &optional depth) ! "Bovinate from within a nonterminal lambda from START to END. Iterates until all the space between START and END is exhausted. Argument NONTERM is the nonterminal symbol to start with. If NONTERM is nil, use `bovine-block-toplevel'. --- 669,677 ---- =20 (defsubst semantic-bovinate-from-nonterminal-full (start end nonterm =09=09=09=09=09=09 &optional depth) ! "NOTE: Use `semantic-parse-region' instead. !=20 ! Bovinate from within a nonterminal lambda from START to END. Iterates until all the space between START and END is exhausted. Argument NONTERM is the nonterminal symbol to start with. If NONTERM is nil, use `bovine-block-toplevel'. *************** *** 730,735 **** --- 679,686 ---- When used in a `lambda' of a MATCH-LIST, there is no need to include a START and END part." (semantic-parse-region start end nonterm (or depth 1))) + (make-obsolete 'semantic-bovinate-from-nonterminal-full + 'semantic-parse-region) =20 (provide 'semantic) =20 Index: semantic/bovine/bovine-grammar.el =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvsroot/cedet/cedet/semantic/bovine/bovine-grammar.el,v retrieving revision 1.14 diff -c -r1.14 bovine-grammar.el *** semantic/bovine/bovine-grammar.el=0911 Aug 2003 06:36:33 -0000=091.14 --- semantic/bovine/bovine-grammar.el=092 Sep 2003 11:19:33 -0000 *************** *** 181,187 **** (insert ")\n")))) =20 (defun bovine-grammar-parsetable-builder () ! "Return the parser table expression as a string value." (let* ((start (semantic-grammar-start)) (scopestart (semantic-grammar-scopestart)) (quotemode (semantic-grammar-quotemode)) --- 181,222 ---- (insert ")\n")))) =20 (defun bovine-grammar-parsetable-builder () ! "Return the parser table expression as a string value. ! The format of a bovine parser table is: !=20 ! ( ( NONTERMINAL-SYMBOL1 MATCH-LIST1 ) ! ( NONTERMINAL-SYMBOL2 MATCH-LIST2 ) ! ... ! ( NONTERMINAL-SYMBOLn MATCH-LISTn ) ! =20 ! Where each NONTERMINAL-SYMBOL is an artificial symbol which can appear ! in any child state. As a starting place, one of the NONTERMINAL-SYMBOLS ! must be `bovine-toplevel'. !=20 ! A MATCH-LIST is a list of possible matches of the form: !=20 ! ( STATE-LIST1 ! STATE-LIST2 ! ... ! STATE-LISTN ) !=20 ! where STATE-LIST is of the form: ! ( TYPE1 [ \"VALUE1\" ] TYPE2 [ \"VALUE2\" ] ... LAMBDA ) !=20 ! where TYPE is one of the returned types of the token stream. ! VALUE is a value, or range of values to match against. For ! example, a SYMBOL might need to match \"foo\". Some TYPES will not ! have matching criteria. !=20 ! LAMBDA is a lambda expression which is evaled with the text of the ! type when it is found. It is passed the list of all buffer text ! elements found since the last lambda expression. It should return a ! semantic element (see below.) !=20 ! For consistency between languages, try to use common return values ! from your parser. Please reference the chapter \"Writing Parsers\" in ! the \"Language Support Developer's Guide -\" in the semantic texinfo ! manual." (let* ((start (semantic-grammar-start)) (scopestart (semantic-grammar-scopestart)) (quotemode (semantic-grammar-quotemode)) Index: semantic/bovine/semantic-bovine.el =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvsroot/cedet/cedet/semantic/bovine/semantic-bovine.el,v retrieving revision 1.7 diff -c -r1.7 semantic-bovine.el *** semantic/bovine/semantic-bovine.el=0917 Mar 2003 01:22:14 -0000=091.7 --- semantic/bovine/semantic-bovine.el=092 Sep 2003 11:19:33 -0000 *************** *** 35,40 **** --- 35,49 ---- (require 'semantic) =20 =0C + ;; These are functions that can be called from within a bovine table. + ;; Most of these have code auto-generated from other construct in the + ;; bovine input grammar. + (defmacro semantic-lambda (&rest return-val) + "Create a lambda expression to return a list including RETURN-VAL. + The return list is a lambda expression to be used in a bovine table." + `(lambda (vals start end) + (append ,@return-val (list start end)))) +=20 ;;; Semantic Bovination ;; ;; Take a semantic token stream, and convert it using the bovinator. *************** *** 48,55 **** =20 (defmacro semantic-bovinate-nonterminal-db-nt () "Return the current nonterminal symbol. ! Part of the BNF source debugger. Depends on the existing environment ! of `semantic-bovinate-stream'." `(if nt-stack (car (aref (car nt-stack) 2)) nonterminal)) --- 57,64 ---- =20 (defmacro semantic-bovinate-nonterminal-db-nt () "Return the current nonterminal symbol. ! Part of the grammar source debugger. Depends on the existing ! environment of `semantic-bovinate-stream'." `(if nt-stack (car (aref (car nt-stack) 2)) nonterminal)) *************** *** 131,137 **** (not (byte-code-function-p (car lte))) (not (listp (car lte)))) =20 ! ;; BNF SOURCE DEBUGGING! (if semantic-debug-enabled (let* ((db-nt (semantic-bovinate-nonterminal-db-n= t)) (db-ml (cdr (assq db-nt table))) --- 140,146 ---- (not (byte-code-function-p (car lte))) (not (listp (car lte)))) =20 ! ;; GRAMMAR SOURCE DEBUGGING! (if semantic-debug-enabled (let* ((db-nt (semantic-bovinate-nonterminal-db-n= t)) (db-ml (cdr (assq db-nt table))) *************** *** 149,155 **** =09=09=09 ;; support more commands here. =20 =09=09=09 ))) ! ;; END BNF SOURCE DEBUGGING! =20 (cond ;; We have a nonterminal symbol. Recurse inline. --- 158,164 ---- =09=09=09 ;; support more commands here. =20 =09=09=09 ))) ! ;; END GRAMMAR SOURCE DEBUGGING! =20 (cond ;; We have a nonterminal symbol. Recurse inline. |