Mercurial > emacs
annotate lisp/cedet/semantic/lex.el @ 106837:855f55740303
Fix typos in comments.
author | Juanma Barranquero <lekktu@gmail.com> |
---|---|
date | Thu, 14 Jan 2010 19:37:23 +0100 |
parents | 1d1d5d9bd884 |
children | 93141d34a175 376148b31b5e |
rev | line source |
---|---|
105260
bbd7017a25d9
CEDET (development tools) package merged.
Chong Yidong <cyd@stupidchicken.com>
parents:
104513
diff
changeset
|
1 ;;; semantic/lex.el --- Lexical Analyzer builder |
104413
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2 |
105340 | 3 ;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, |
106815 | 4 ;; 2008, 2009, 2010 Free Software Foundation, Inc. |
104413
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
5 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
6 ;; Author: Eric M. Ludlam <zappo@gnu.org> |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
7 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
8 ;; This file is part of GNU Emacs. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
9 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
10 ;; GNU Emacs is free software: you can redistribute it and/or modify |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
11 ;; it under the terms of the GNU General Public License as published by |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
12 ;; the Free Software Foundation, either version 3 of the License, or |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
13 ;; (at your option) any later version. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
14 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
15 ;; GNU Emacs is distributed in the hope that it will be useful, |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
18 ;; GNU General Public License for more details. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
19 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
20 ;; You should have received a copy of the GNU General Public License |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
21 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
22 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
23 ;;; Commentary: |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
24 ;; |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
25 ;; This file handles the creation of lexical analyzers for different |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
26 ;; languages in Emacs Lisp. The purpose of a lexical analyzer is to |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
27 ;; convert a buffer into a list of lexical tokens. Each token |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
28 ;; contains the token class (such as 'number, 'symbol, 'IF, etc) and |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
29 ;; the location in the buffer it was found. Optionally, a token also |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
30 ;; contains a string representing what is at the designated buffer |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
31 ;; location. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
32 ;; |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
33 ;; Tokens are pushed onto a token stream, which is basically a list of |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
34 ;; all the lexical tokens from the analyzed region. The token stream |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
35 ;; is then handed to the grammar which parsers the file. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
36 ;; |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
37 ;;; How it works |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
38 ;; |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
39 ;; Each analyzer specifies a condition and forms. These conditions |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
40 ;; and forms are assembled into a function by `define-lex' that does |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
41 ;; the lexical analysis. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
42 ;; |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
43 ;; In the lexical analyzer created with `define-lex', each condition |
105340 | 44 ;; is tested for a given point. When the condition is true, the forms |
104413
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
45 ;; run. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
46 ;; |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
47 ;; The forms can push a lexical token onto the token stream. The |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
48 ;; analyzer forms also must move the current analyzer point. If the |
105340 | 49 ;; analyzer point is moved without pushing a token, then the matched |
104413
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
50 ;; syntax is effectively ignored, or skipped. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
51 ;; |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
52 ;; Thus, starting at the beginning of a region to be analyzed, each |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
53 ;; condition is tested. One will match, and a lexical token might be |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
54 ;; pushed, and the point is moved to the end of the lexical token |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
55 ;; identified. At the new position, the process occurs again until |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
56 ;; the end of the specified region is reached. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
57 ;; |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
58 ;;; How to use semantic-lex |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
59 ;; |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
60 ;; To create a lexer for a language, use the `define-lex' macro. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
61 ;; |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
62 ;; The `define-lex' macro accepts a list of lexical analyzers. Each |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
63 ;; analyzer is created with `define-lex-analyzer', or one of the |
105340 | 64 ;; derivative macros. A single analyzer defines a regular expression |
104413
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
65 ;; to match text in a buffer, and a short segment of code to create |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
66 ;; one lexical token. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
67 ;; |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
68 ;; Each analyzer has a NAME, DOC, a CONDITION, and possibly some |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
69 ;; FORMS. The NAME is the name used in `define-lex'. The DOC |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
70 ;; describes what the analyzer should do. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
71 ;; |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
72 ;; The CONDITION evaluates the text at the current point in the |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
73 ;; current buffer. If CONDITION is true, then the FORMS will be |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
74 ;; executed. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
75 ;; |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
76 ;; The purpose of the FORMS is to push new lexical tokens onto the |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
77 ;; list of tokens for the current buffer, and to move point after the |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
78 ;; matched text. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
79 ;; |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
80 ;; Some macros for creating one analyzer are: |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
81 ;; |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
82 ;; define-lex-analyzer - A generic analyzer associating any style of |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
83 ;; condition to forms. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
84 ;; define-lex-regex-analyzer - Matches a regular expression. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
85 ;; define-lex-simple-regex-analyzer - Matches a regular expressions, |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
86 ;; and pushes the match. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
87 ;; define-lex-block-analyzer - Matches list syntax, and defines |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
88 ;; handles open/close delimiters. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
89 ;; |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
90 ;; These macros are used by the grammar compiler when lexical |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
91 ;; information is specified in a grammar: |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
92 ;; define-lex- * -type-analyzer - Matches syntax specified in |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
93 ;; a grammar, and pushes one token for it. The * would |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
94 ;; be `sexp' for things like lists or strings, and |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
95 ;; `string' for things that need to match some special |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
96 ;; string, such as "\\." where a literal match is needed. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
97 ;; |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
98 ;;; Lexical Tables |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
99 ;; |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
100 ;; There are tables of different symbols managed in semantic-lex.el. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
101 ;; They are: |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
102 ;; |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
103 ;; Lexical keyword table - A Table of symbols declared in a grammar |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
104 ;; file with the %keyword declaration. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
105 ;; Keywords are used by `semantic-lex-symbol-or-keyword' |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
106 ;; to create lexical tokens based on the keyword. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
107 ;; |
105340 | 108 ;; Lexical type table - A table of symbols declared in a grammar |
104413
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
109 ;; file with the %type declaration. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
110 ;; The grammar compiler uses the type table to create new |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
111 ;; lexical analyzers. These analyzers are then used to when |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
112 ;; a new lexical analyzer is made for a language. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
113 ;; |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
114 ;;; Lexical Types |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
115 ;; |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
116 ;; A lexical type defines a kind of lexical analyzer that will be |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
117 ;; automatically generated from a grammar file based on some |
105340 | 118 ;; predetermined attributes. For now these two attributes are |
104413
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
119 ;; recognized : |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
120 ;; |
105340 | 121 ;; * matchdatatype : define the kind of lexical analyzer. That is : |
104413
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
122 ;; |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
123 ;; - regexp : define a regexp analyzer (see |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
124 ;; `define-lex-regex-type-analyzer') |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
125 ;; |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
126 ;; - string : define a string analyzer (see |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
127 ;; `define-lex-string-type-analyzer') |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
128 ;; |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
129 ;; - block : define a block type analyzer (see |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
130 ;; `define-lex-block-type-analyzer') |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
131 ;; |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
132 ;; - sexp : define a sexp analyzer (see |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
133 ;; `define-lex-sexp-type-analyzer') |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
134 ;; |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
135 ;; - keyword : define a keyword analyzer (see |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
136 ;; `define-lex-keyword-type-analyzer') |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
137 ;; |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
138 ;; * syntax : define the syntax that matches a syntactic |
105340 | 139 ;; expression. When syntax is matched the corresponding type |
104413
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
140 ;; analyzer is entered and the resulting match data will be |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
141 ;; interpreted based on the kind of analyzer (see matchdatatype |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
142 ;; above). |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
143 ;; |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
144 ;; The following lexical types are predefined : |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
145 ;; |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
146 ;; +-------------+---------------+--------------------------------+ |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
147 ;; | type | matchdatatype | syntax | |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
148 ;; +-------------+---------------+--------------------------------+ |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
149 ;; | punctuation | string | "\\(\\s.\\|\\s$\\|\\s'\\)+" | |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
150 ;; | keyword | keyword | "\\(\\sw\\|\\s_\\)+" | |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
151 ;; | symbol | regexp | "\\(\\sw\\|\\s_\\)+" | |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
152 ;; | string | sexp | "\\s\"" | |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
153 ;; | number | regexp | semantic-lex-number-expression | |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
154 ;; | block | block | "\\s(\\|\\s)" | |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
155 ;; +-------------+---------------+--------------------------------+ |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
156 ;; |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
157 ;; In a grammar you must use a %type expression to automatically generate |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
158 ;; the corresponding analyzers of that type. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
159 ;; |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
160 ;; Here is an example to auto-generate punctuation analyzers |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
161 ;; with 'matchdatatype and 'syntax predefined (see table above) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
162 ;; |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
163 ;; %type <punctuation> ;; will auto-generate this kind of analyzers |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
164 ;; |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
165 ;; It is equivalent to write : |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
166 ;; |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
167 ;; %type <punctuation> syntax "\\(\\s.\\|\\s$\\|\\s'\\)+" matchdatatype string |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
168 ;; |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
169 ;; ;; Some punctuations based on the type defines above |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
170 ;; |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
171 ;; %token <punctuation> NOT "!" |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
172 ;; %token <punctuation> NOTEQ "!=" |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
173 ;; %token <punctuation> MOD "%" |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
174 ;; %token <punctuation> MODEQ "%=" |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
175 ;; |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
176 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
177 ;;; On the Semantic 1.x lexer |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
178 ;; |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
179 ;; In semantic 1.x, the lexical analyzer was an all purpose routine. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
180 ;; To boost efficiency, the analyzer is now a series of routines that |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
181 ;; are constructed at build time into a single routine. This will |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
182 ;; eliminate unneeded if statements to speed the lexer. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
183 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
184 (require 'semantic/fw) |
105260
bbd7017a25d9
CEDET (development tools) package merged.
Chong Yidong <cyd@stupidchicken.com>
parents:
104513
diff
changeset
|
185 |
104413
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
186 ;;; Code: |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
187 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
188 ;;; Semantic 2.x lexical analysis |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
189 ;; |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
190 (defun semantic-lex-map-symbols (fun table &optional property) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
191 "Call function FUN on every symbol in TABLE. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
192 If optional PROPERTY is non-nil, call FUN only on every symbol which |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
193 as a PROPERTY value. FUN receives a symbol as argument." |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
194 (if (arrayp table) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
195 (mapatoms |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
196 #'(lambda (symbol) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
197 (if (or (null property) (get symbol property)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
198 (funcall fun symbol))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
199 table))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
200 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
201 ;;; Lexical keyword table handling. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
202 ;; |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
203 ;; These keywords are keywords defined for using in a grammar with the |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
204 ;; %keyword declaration, and are not keywords used in Emacs Lisp. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
205 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
206 (defvar semantic-flex-keywords-obarray nil |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
207 "Buffer local keyword obarray for the lexical analyzer. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
208 These keywords are matched explicitly, and converted into special symbols.") |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
209 (make-variable-buffer-local 'semantic-flex-keywords-obarray) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
210 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
211 (defmacro semantic-lex-keyword-invalid (name) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
212 "Signal that NAME is an invalid keyword name." |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
213 `(signal 'wrong-type-argument '(semantic-lex-keyword-p ,name))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
214 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
215 (defsubst semantic-lex-keyword-symbol (name) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
216 "Return keyword symbol with NAME or nil if not found." |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
217 (and (arrayp semantic-flex-keywords-obarray) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
218 (stringp name) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
219 (intern-soft name semantic-flex-keywords-obarray))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
220 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
221 (defsubst semantic-lex-keyword-p (name) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
222 "Return non-nil if a keyword with NAME exists in the keyword table. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
223 Return nil otherwise." |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
224 (and (setq name (semantic-lex-keyword-symbol name)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
225 (symbol-value name))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
226 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
227 (defsubst semantic-lex-keyword-set (name value) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
228 "Set value of keyword with NAME to VALUE and return VALUE." |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
229 (set (intern name semantic-flex-keywords-obarray) value)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
230 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
231 (defsubst semantic-lex-keyword-value (name) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
232 "Return value of keyword with NAME. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
233 Signal an error if a keyword with NAME does not exist." |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
234 (let ((keyword (semantic-lex-keyword-symbol name))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
235 (if keyword |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
236 (symbol-value keyword) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
237 (semantic-lex-keyword-invalid name)))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
238 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
239 (defsubst semantic-lex-keyword-put (name property value) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
240 "For keyword with NAME, set its PROPERTY to VALUE." |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
241 (let ((keyword (semantic-lex-keyword-symbol name))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
242 (if keyword |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
243 (put keyword property value) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
244 (semantic-lex-keyword-invalid name)))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
245 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
246 (defsubst semantic-lex-keyword-get (name property) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
247 "For keyword with NAME, return its PROPERTY value." |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
248 (let ((keyword (semantic-lex-keyword-symbol name))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
249 (if keyword |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
250 (get keyword property) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
251 (semantic-lex-keyword-invalid name)))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
252 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
253 (defun semantic-lex-make-keyword-table (specs &optional propspecs) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
254 "Convert keyword SPECS into an obarray and return it. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
255 SPECS must be a list of (NAME . TOKSYM) elements, where: |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
256 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
257 NAME is the name of the keyword symbol to define. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
258 TOKSYM is the lexical token symbol of that keyword. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
259 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
260 If optional argument PROPSPECS is non nil, then interpret it, and |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
261 apply those properties. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
262 PROPSPECS must be a list of (NAME PROPERTY VALUE) elements." |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
263 ;; Create the symbol hash table |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
264 (let ((semantic-flex-keywords-obarray (make-vector 13 0)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
265 spec) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
266 ;; fill it with stuff |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
267 (while specs |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
268 (setq spec (car specs) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
269 specs (cdr specs)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
270 (semantic-lex-keyword-set (car spec) (cdr spec))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
271 ;; Apply all properties |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
272 (while propspecs |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
273 (setq spec (car propspecs) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
274 propspecs (cdr propspecs)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
275 (semantic-lex-keyword-put (car spec) (nth 1 spec) (nth 2 spec))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
276 semantic-flex-keywords-obarray)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
277 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
278 (defsubst semantic-lex-map-keywords (fun &optional property) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
279 "Call function FUN on every lexical keyword. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
280 If optional PROPERTY is non-nil, call FUN only on every keyword which |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
281 as a PROPERTY value. FUN receives a lexical keyword as argument." |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
282 (semantic-lex-map-symbols |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
283 fun semantic-flex-keywords-obarray property)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
284 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
285 (defun semantic-lex-keywords (&optional property) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
286 "Return a list of lexical keywords. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
287 If optional PROPERTY is non-nil, return only keywords which have a |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
288 PROPERTY set." |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
289 (let (keywords) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
290 (semantic-lex-map-keywords |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
291 #'(lambda (symbol) (setq keywords (cons symbol keywords))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
292 property) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
293 keywords)) |
104419
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
104416
diff
changeset
|
294 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
104416
diff
changeset
|
295 ;;; Inline functions: |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
104416
diff
changeset
|
296 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
104416
diff
changeset
|
297 (defvar semantic-lex-unterminated-syntax-end-function) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
104416
diff
changeset
|
298 (defvar semantic-lex-analysis-bounds) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
104416
diff
changeset
|
299 (defvar semantic-lex-end-point) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
104416
diff
changeset
|
300 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
104416
diff
changeset
|
301 (defsubst semantic-lex-token-bounds (token) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
104416
diff
changeset
|
302 "Fetch the start and end locations of the lexical token TOKEN. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
104416
diff
changeset
|
303 Return a pair (START . END)." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
104416
diff
changeset
|
304 (if (not (numberp (car (cdr token)))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
104416
diff
changeset
|
305 (cdr (cdr token)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
104416
diff
changeset
|
306 (cdr token))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
104416
diff
changeset
|
307 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
104416
diff
changeset
|
308 (defsubst semantic-lex-token-start (token) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
104416
diff
changeset
|
309 "Fetch the start position of the lexical token TOKEN. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
104416
diff
changeset
|
310 See also the function `semantic-lex-token'." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
104416
diff
changeset
|
311 (car (semantic-lex-token-bounds token))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
104416
diff
changeset
|
312 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
104416
diff
changeset
|
313 (defsubst semantic-lex-token-end (token) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
104416
diff
changeset
|
314 "Fetch the end position of the lexical token TOKEN. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
104416
diff
changeset
|
315 See also the function `semantic-lex-token'." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
104416
diff
changeset
|
316 (cdr (semantic-lex-token-bounds token))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
104416
diff
changeset
|
317 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
104416
diff
changeset
|
318 (defsubst semantic-lex-unterminated-syntax-detected (syntax) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
104416
diff
changeset
|
319 "Inside a lexical analyzer, use this when unterminated syntax was found. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
104416
diff
changeset
|
320 Argument SYNTAX indicates the type of syntax that is unterminated. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
104416
diff
changeset
|
321 The job of this function is to move (point) to a new logical location |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
104416
diff
changeset
|
322 so that analysis can continue, if possible." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
104416
diff
changeset
|
323 (goto-char |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
104416
diff
changeset
|
324 (funcall semantic-lex-unterminated-syntax-end-function |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
104416
diff
changeset
|
325 syntax |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
104416
diff
changeset
|
326 (car semantic-lex-analysis-bounds) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
104416
diff
changeset
|
327 (cdr semantic-lex-analysis-bounds) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
104416
diff
changeset
|
328 )) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
104416
diff
changeset
|
329 (setq semantic-lex-end-point (point))) |
104413
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
330 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
331 ;;; Type table handling. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
332 ;; |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
333 ;; The lexical type table manages types that occur in a grammar file |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
334 ;; with the %type declaration. Types represent different syntaxes. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
335 ;; See code for `semantic-lex-preset-default-types' for the classic |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
336 ;; types of syntax. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
337 (defvar semantic-lex-types-obarray nil |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
338 "Buffer local types obarray for the lexical analyzer.") |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
339 (make-variable-buffer-local 'semantic-lex-types-obarray) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
340 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
341 (defmacro semantic-lex-type-invalid (type) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
342 "Signal that TYPE is an invalid lexical type name." |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
343 `(signal 'wrong-type-argument '(semantic-lex-type-p ,type))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
344 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
345 (defsubst semantic-lex-type-symbol (type) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
346 "Return symbol with TYPE or nil if not found." |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
347 (and (arrayp semantic-lex-types-obarray) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
348 (stringp type) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
349 (intern-soft type semantic-lex-types-obarray))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
350 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
351 (defsubst semantic-lex-type-p (type) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
352 "Return non-nil if a symbol with TYPE name exists." |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
353 (and (setq type (semantic-lex-type-symbol type)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
354 (symbol-value type))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
355 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
356 (defsubst semantic-lex-type-set (type value) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
357 "Set value of symbol with TYPE name to VALUE and return VALUE." |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
358 (set (intern type semantic-lex-types-obarray) value)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
359 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
360 (defsubst semantic-lex-type-value (type &optional noerror) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
361 "Return value of symbol with TYPE name. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
362 If optional argument NOERROR is non-nil return nil if a symbol with |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
363 TYPE name does not exist. Otherwise signal an error." |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
364 (let ((sym (semantic-lex-type-symbol type))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
365 (if sym |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
366 (symbol-value sym) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
367 (unless noerror |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
368 (semantic-lex-type-invalid type))))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
369 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
370 (defsubst semantic-lex-type-put (type property value &optional add) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
371 "For symbol with TYPE name, set its PROPERTY to VALUE. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
372 If optional argument ADD is non-nil, create a new symbol with TYPE |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
373 name if it does not already exist. Otherwise signal an error." |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
374 (let ((sym (semantic-lex-type-symbol type))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
375 (unless sym |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
376 (or add (semantic-lex-type-invalid type)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
377 (semantic-lex-type-set type nil) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
378 (setq sym (semantic-lex-type-symbol type))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
379 (put sym property value))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
380 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
381 (defsubst semantic-lex-type-get (type property &optional noerror) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
382 "For symbol with TYPE name, return its PROPERTY value. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
383 If optional argument NOERROR is non-nil return nil if a symbol with |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
384 TYPE name does not exist. Otherwise signal an error." |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
385 (let ((sym (semantic-lex-type-symbol type))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
386 (if sym |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
387 (get sym property) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
388 (unless noerror |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
389 (semantic-lex-type-invalid type))))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
390 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
391 (defun semantic-lex-preset-default-types () |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
392 "Install useful default properties for well known types." |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
393 (semantic-lex-type-put "punctuation" 'matchdatatype 'string t) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
394 (semantic-lex-type-put "punctuation" 'syntax "\\(\\s.\\|\\s$\\|\\s'\\)+") |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
395 (semantic-lex-type-put "keyword" 'matchdatatype 'keyword t) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
396 (semantic-lex-type-put "keyword" 'syntax "\\(\\sw\\|\\s_\\)+") |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
397 (semantic-lex-type-put "symbol" 'matchdatatype 'regexp t) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
398 (semantic-lex-type-put "symbol" 'syntax "\\(\\sw\\|\\s_\\)+") |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
399 (semantic-lex-type-put "string" 'matchdatatype 'sexp t) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
400 (semantic-lex-type-put "string" 'syntax "\\s\"") |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
401 (semantic-lex-type-put "number" 'matchdatatype 'regexp t) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
402 (semantic-lex-type-put "number" 'syntax 'semantic-lex-number-expression) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
403 (semantic-lex-type-put "block" 'matchdatatype 'block t) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
404 (semantic-lex-type-put "block" 'syntax "\\s(\\|\\s)") |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
405 ) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
406 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
407 (defun semantic-lex-make-type-table (specs &optional propspecs) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
408 "Convert type SPECS into an obarray and return it. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
409 SPECS must be a list of (TYPE . TOKENS) elements, where: |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
410 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
411 TYPE is the name of the type symbol to define. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
412 TOKENS is an list of (TOKSYM . MATCHER) elements, where: |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
413 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
414 TOKSYM is any lexical token symbol. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
415 MATCHER is a string or regexp a text must match to be a such |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
416 lexical token. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
417 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
418 If optional argument PROPSPECS is non nil, then interpret it, and |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
419 apply those properties. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
420 PROPSPECS must be a list of (TYPE PROPERTY VALUE)." |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
421 ;; Create the symbol hash table |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
422 (let* ((semantic-lex-types-obarray (make-vector 13 0)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
423 spec type tokens token alist default) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
424 ;; fill it with stuff |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
425 (while specs |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
426 (setq spec (car specs) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
427 specs (cdr specs) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
428 type (car spec) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
429 tokens (cdr spec) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
430 default nil |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
431 alist nil) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
432 (while tokens |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
433 (setq token (car tokens) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
434 tokens (cdr tokens)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
435 (if (cdr token) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
436 (setq alist (cons token alist)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
437 (setq token (car token)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
438 (if default |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
439 (message |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
440 "*Warning* default value of <%s> tokens changed to %S, was %S" |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
441 type default token)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
442 (setq default token))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
443 ;; Ensure the default matching spec is the first one. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
444 (semantic-lex-type-set type (cons default (nreverse alist)))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
445 ;; Install useful default types & properties |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
446 (semantic-lex-preset-default-types) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
447 ;; Apply all properties |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
448 (while propspecs |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
449 (setq spec (car propspecs) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
450 propspecs (cdr propspecs)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
451 ;; Create the type if necessary. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
452 (semantic-lex-type-put (car spec) (nth 1 spec) (nth 2 spec) t)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
453 semantic-lex-types-obarray)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
454 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
455 (defsubst semantic-lex-map-types (fun &optional property) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
456 "Call function FUN on every lexical type. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
457 If optional PROPERTY is non-nil, call FUN only on every type symbol |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
458 which as a PROPERTY value. FUN receives a type symbol as argument." |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
459 (semantic-lex-map-symbols |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
460 fun semantic-lex-types-obarray property)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
461 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
462 (defun semantic-lex-types (&optional property) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
463 "Return a list of lexical type symbols. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
464 If optional PROPERTY is non-nil, return only type symbols which have |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
465 PROPERTY set." |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
466 (let (types) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
467 (semantic-lex-map-types |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
468 #'(lambda (symbol) (setq types (cons symbol types))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
469 property) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
470 types)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
471 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
472 ;;; Lexical Analyzer framework settings |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
473 ;; |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
474 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
475 (defvar semantic-lex-analyzer 'semantic-flex |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
476 "The lexical analyzer used for a given buffer. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
477 See `semantic-lex' for documentation. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
478 For compatibility with Semantic 1.x it defaults to `semantic-flex'.") |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
479 (make-variable-buffer-local 'semantic-lex-analyzer) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
480 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
481 (defvar semantic-lex-tokens |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
482 '( |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
483 (bol) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
484 (charquote) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
485 (close-paren) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
486 (comment) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
487 (newline) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
488 (open-paren) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
489 (punctuation) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
490 (semantic-list) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
491 (string) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
492 (symbol) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
493 (whitespace) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
494 ) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
495 "An alist of of semantic token types. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
496 As of December 2001 (semantic 1.4beta13), this variable is not used in |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
497 any code. The only use is to refer to the doc-string from elsewhere. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
498 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
499 The key to this alist is the symbol representing token type that |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
500 \\[semantic-flex] returns. These are |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
501 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
502 - bol: Empty string matching a beginning of line. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
503 This token is produced with |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
504 `semantic-lex-beginning-of-line'. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
505 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
506 - charquote: String sequences that match `\\s\\+' regexp. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
507 This token is produced with `semantic-lex-charquote'. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
508 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
509 - close-paren: Characters that match `\\s)' regexp. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
510 These are typically `)', `}', `]', etc. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
511 This token is produced with |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
512 `semantic-lex-close-paren'. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
513 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
514 - comment: A comment chunk. These token types are not |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
515 produced by default. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
516 This token is produced with `semantic-lex-comments'. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
517 Comments are ignored with `semantic-lex-ignore-comments'. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
518 Comments are treated as whitespace with |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
519 `semantic-lex-comments-as-whitespace'. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
520 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
521 - newline Characters matching `\\s-*\\(\n\\|\\s>\\)' regexp. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
522 This token is produced with `semantic-lex-newline'. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
523 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
524 - open-paren: Characters that match `\\s(' regexp. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
525 These are typically `(', `{', `[', etc. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
526 If `semantic-lex-paren-or-list' is used, |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
527 then `open-paren' is not usually generated unless |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
528 the `depth' argument to \\[semantic-lex] is |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
529 greater than 0. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
530 This token is always produced if the analyzer |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
531 `semantic-lex-open-paren' is used. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
532 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
533 - punctuation: Characters matching `{\\(\\s.\\|\\s$\\|\\s'\\)' |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
534 regexp. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
535 This token is produced with `semantic-lex-punctuation'. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
536 Always specify this analyzer after the comment |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
537 analyzer. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
538 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
539 - semantic-list: String delimited by matching parenthesis, braces, |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
540 etc. that the lexer skipped over, because the |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
541 `depth' parameter to \\[semantic-flex] was not high |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
542 enough. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
543 This token is produced with `semantic-lex-paren-or-list'. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
544 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
545 - string: Quoted strings, i.e., string sequences that start |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
546 and end with characters matching `\\s\"' |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
547 regexp. The lexer relies on @code{forward-sexp} to |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
548 find the matching end. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
549 This token is produced with `semantic-lex-string'. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
550 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
551 - symbol: String sequences that match `\\(\\sw\\|\\s_\\)+' |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
552 regexp. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
553 This token is produced with |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
554 `semantic-lex-symbol-or-keyword'. Always add this analyzer |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
555 after `semantic-lex-number', or other analyzers that |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
556 match its regular expression. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
557 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
558 - whitespace: Characters that match `\\s-+' regexp. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
559 This token is produced with `semantic-lex-whitespace'.") |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
560 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
561 (defvar semantic-lex-syntax-modifications nil |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
562 "Changes to the syntax table for this buffer. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
563 These changes are active only while the buffer is being flexed. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
564 This is a list where each element has the form: |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
565 (CHAR CLASS) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
566 CHAR is the char passed to `modify-syntax-entry', |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
567 and CLASS is the string also passed to `modify-syntax-entry' to define |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
568 what syntax class CHAR has.") |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
569 (make-variable-buffer-local 'semantic-lex-syntax-modifications) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
570 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
571 (defvar semantic-lex-syntax-table nil |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
572 "Syntax table used by lexical analysis. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
573 See also `semantic-lex-syntax-modifications'.") |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
574 (make-variable-buffer-local 'semantic-lex-syntax-table) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
575 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
576 (defvar semantic-lex-comment-regex nil |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
577 "Regular expression for identifying comment start during lexical analysis. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
578 This may be automatically set when semantic initializes in a mode, but |
105340 | 579 may need to be overridden for some special languages.") |
104413
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
580 (make-variable-buffer-local 'semantic-lex-comment-regex) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
581 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
582 (defvar semantic-lex-number-expression |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
583 ;; This expression was written by David Ponce for Java, and copied |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
584 ;; here for C and any other similar language. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
585 (eval-when-compile |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
586 (concat "\\(" |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
587 "\\<[0-9]+[.][0-9]+\\([eE][-+]?[0-9]+\\)?[fFdD]?\\>" |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
588 "\\|" |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
589 "\\<[0-9]+[.][eE][-+]?[0-9]+[fFdD]?\\>" |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
590 "\\|" |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
591 "\\<[0-9]+[.][fFdD]\\>" |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
592 "\\|" |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
593 "\\<[0-9]+[.]" |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
594 "\\|" |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
595 "[.][0-9]+\\([eE][-+]?[0-9]+\\)?[fFdD]?\\>" |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
596 "\\|" |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
597 "\\<[0-9]+[eE][-+]?[0-9]+[fFdD]?\\>" |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
598 "\\|" |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
599 "\\<0[xX][0-9a-fA-F]+[lL]?\\>" |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
600 "\\|" |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
601 "\\<[0-9]+[lLfFdD]?\\>" |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
602 "\\)" |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
603 )) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
604 "Regular expression for matching a number. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
605 If this value is nil, no number extraction is done during lex. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
606 This expression tries to match C and Java like numbers. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
607 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
608 DECIMAL_LITERAL: |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
609 [1-9][0-9]* |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
610 ; |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
611 HEX_LITERAL: |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
612 0[xX][0-9a-fA-F]+ |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
613 ; |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
614 OCTAL_LITERAL: |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
615 0[0-7]* |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
616 ; |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
617 INTEGER_LITERAL: |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
618 <DECIMAL_LITERAL>[lL]? |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
619 | <HEX_LITERAL>[lL]? |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
620 | <OCTAL_LITERAL>[lL]? |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
621 ; |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
622 EXPONENT: |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
623 [eE][+-]?[09]+ |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
624 ; |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
625 FLOATING_POINT_LITERAL: |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
626 [0-9]+[.][0-9]*<EXPONENT>?[fFdD]? |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
627 | [.][0-9]+<EXPONENT>?[fFdD]? |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
628 | [0-9]+<EXPONENT>[fFdD]? |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
629 | [0-9]+<EXPONENT>?[fFdD] |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
630 ;") |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
631 (make-variable-buffer-local 'semantic-lex-number-expression) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
632 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
633 (defvar semantic-lex-depth 0 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
634 "Default lexing depth. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
635 This specifies how many lists to create tokens in.") |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
636 (make-variable-buffer-local 'semantic-lex-depth) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
637 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
638 (defvar semantic-lex-unterminated-syntax-end-function |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
639 (lambda (syntax syntax-start lex-end) lex-end) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
640 "Function called when unterminated syntax is encountered. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
641 This should be set to one function. That function should take three |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
642 parameters. The SYNTAX, or type of syntax which is unterminated. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
643 SYNTAX-START where the broken syntax begins. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
644 LEX-END is where the lexical analysis was asked to end. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
645 This function can be used for languages that can intelligently fix up |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
646 broken syntax, or the exit lexical analysis via `throw' or `signal' |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
647 when finding unterminated syntax.") |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
648 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
649 ;;; Interactive testing commands |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
650 |
104446
df08b7ab0ba0
lisp/cedet/semantic/analyze.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents:
104419
diff
changeset
|
651 (declare-function semantic-elapsed-time "semantic") |
df08b7ab0ba0
lisp/cedet/semantic/analyze.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents:
104419
diff
changeset
|
652 |
104413
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
653 (defun semantic-lex-test (arg) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
654 "Test the semantic lexer in the current buffer. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
655 If universal argument ARG, then try the whole buffer." |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
656 (interactive "P") |
104446
df08b7ab0ba0
lisp/cedet/semantic/analyze.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents:
104419
diff
changeset
|
657 (require 'semantic) |
104413
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
658 (let* ((start (current-time)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
659 (result (semantic-lex |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
660 (if arg (point-min) (point)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
661 (point-max))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
662 (end (current-time))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
663 (message "Elapsed Time: %.2f seconds." |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
664 (semantic-elapsed-time start end)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
665 (pop-to-buffer "*Lexer Output*") |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
666 (require 'pp) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
667 (erase-buffer) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
668 (insert (pp-to-string result)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
669 (goto-char (point-min)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
670 )) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
671 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
672 (defvar semantic-lex-debug nil |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
673 "When non-nil, debug the local lexical analyzer.") |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
674 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
675 (defun semantic-lex-debug (arg) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
676 "Debug the semantic lexer in the current buffer. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
677 Argument ARG specifies of the analyze the whole buffer, or start at point. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
678 While engaged, each token identified by the lexer will be highlighted |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
679 in the target buffer A description of the current token will be |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
680 displayed in the minibuffer. Press SPC to move to the next lexical token." |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
681 (interactive "P") |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
682 (require 'semantic/debug) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
683 (let ((semantic-lex-debug t)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
684 (semantic-lex-test arg))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
685 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
686 (defun semantic-lex-highlight-token (token) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
687 "Highlight the lexical TOKEN. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
688 TOKEN is a lexical token with a START And END position. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
689 Return the overlay." |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
690 (let ((o (semantic-make-overlay (semantic-lex-token-start token) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
691 (semantic-lex-token-end token)))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
692 (semantic-overlay-put o 'face 'highlight) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
693 o)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
694 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
695 (defsubst semantic-lex-debug-break (token) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
696 "Break during lexical analysis at TOKEN." |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
697 (when semantic-lex-debug |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
698 (let ((o nil)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
699 (unwind-protect |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
700 (progn |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
701 (when token |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
702 (setq o (semantic-lex-highlight-token token))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
703 (semantic-read-event |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
704 (format "%S :: SPC - continue" token)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
705 ) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
706 (when o |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
707 (semantic-overlay-delete o)))))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
708 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
709 ;;; Lexical analyzer creation |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
710 ;; |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
711 ;; Code for creating a lex function from lists of analyzers. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
712 ;; |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
713 ;; A lexical analyzer is created from a list of individual analyzers. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
714 ;; Each individual analyzer specifies a single match, and code that |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
715 ;; goes with it. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
716 ;; |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
717 ;; Creation of an analyzer assembles these analyzers into a new function |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
718 ;; with the behaviors of all the individual analyzers. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
719 ;; |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
720 (defmacro semantic-lex-one-token (analyzers) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
721 "Calculate one token from the current buffer at point. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
722 Uses locally bound variables from `define-lex'. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
723 Argument ANALYZERS is the list of analyzers being used." |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
724 (cons 'cond (mapcar #'symbol-value analyzers))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
725 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
726 (defvar semantic-lex-end-point nil |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
727 "The end point as tracked through lexical functions.") |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
728 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
729 (defvar semantic-lex-current-depth nil |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
730 "The current depth as tracked through lexical functions.") |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
731 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
732 (defvar semantic-lex-maximum-depth nil |
105340 | 733 "The maximum depth of parenthesis as tracked through lexical functions.") |
104413
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
734 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
735 (defvar semantic-lex-token-stream nil |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
736 "The current token stream we are collecting.") |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
737 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
738 (defvar semantic-lex-analysis-bounds nil |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
739 "The bounds of the current analysis.") |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
740 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
741 (defvar semantic-lex-block-streams nil |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
742 "Streams of tokens inside collapsed blocks. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
743 This is an alist of (ANCHOR . STREAM) elements where ANCHOR is the |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
744 start position of the block, and STREAM is the list of tokens in that |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
745 block.") |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
746 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
747 (defvar semantic-lex-reset-hooks nil |
104513
a6a812dd2d88
* cedet/semantic/lex.el (semantic-lex-reset-hooks): Doc fix.
Chong Yidong <cyd@stupidchicken.com>
parents:
104493
diff
changeset
|
748 "Abnormal hook used by major-modes to reset lexical analyzers. |
a6a812dd2d88
* cedet/semantic/lex.el (semantic-lex-reset-hooks): Doc fix.
Chong Yidong <cyd@stupidchicken.com>
parents:
104493
diff
changeset
|
749 Hook functions are called with START and END values for the |
a6a812dd2d88
* cedet/semantic/lex.el (semantic-lex-reset-hooks): Doc fix.
Chong Yidong <cyd@stupidchicken.com>
parents:
104493
diff
changeset
|
750 current lexical pass. Should be set with `add-hook', specifying |
a6a812dd2d88
* cedet/semantic/lex.el (semantic-lex-reset-hooks): Doc fix.
Chong Yidong <cyd@stupidchicken.com>
parents:
104493
diff
changeset
|
751 a LOCAL option.") |
104413
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
752 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
753 ;; Stack of nested blocks. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
754 (defvar semantic-lex-block-stack nil) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
755 ;;(defvar semantic-lex-timeout 5 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
756 ;; "*Number of sections of lexing before giving up.") |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
757 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
758 (defmacro define-lex (name doc &rest analyzers) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
759 "Create a new lexical analyzer with NAME. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
760 DOC is a documentation string describing this analyzer. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
761 ANALYZERS are small code snippets of analyzers to use when |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
762 building the new NAMED analyzer. Only use analyzers which |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
763 are written to be used in `define-lex'. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
764 Each analyzer should be an analyzer created with `define-lex-analyzer'. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
765 Note: The order in which analyzers are listed is important. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
766 If two analyzers can match the same text, it is important to order the |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
767 analyzers so that the one you want to match first occurs first. For |
105340 | 768 example, it is good to put a number analyzer in front of a symbol |
104413
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
769 analyzer which might mistake a number for as a symbol." |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
770 `(defun ,name (start end &optional depth length) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
771 ,(concat doc "\nSee `semantic-lex' for more information.") |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
772 ;; Make sure the state of block parsing starts over. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
773 (setq semantic-lex-block-streams nil) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
774 ;; Allow specialty reset items. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
775 (run-hook-with-args 'semantic-lex-reset-hooks start end) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
776 ;; Lexing state. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
777 (let* (;(starttime (current-time)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
778 (starting-position (point)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
779 (semantic-lex-token-stream nil) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
780 (semantic-lex-block-stack nil) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
781 (tmp-start start) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
782 (semantic-lex-end-point start) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
783 (semantic-lex-current-depth 0) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
784 ;; Use the default depth when not specified. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
785 (semantic-lex-maximum-depth |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
786 (or depth semantic-lex-depth)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
787 ;; Bounds needed for unterminated syntax |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
788 (semantic-lex-analysis-bounds (cons start end)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
789 ;; This entry prevents text properties from |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
790 ;; confusing our lexical analysis. See Emacs 22 (CVS) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
791 ;; version of C++ mode with template hack text properties. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
792 (parse-sexp-lookup-properties nil) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
793 ) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
794 ;; Maybe REMOVE THIS LATER. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
795 ;; Trying to find incremental parser bug. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
796 (when (> end (point-max)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
797 (error ,(format "%s: end (%%d) > point-max (%%d)" name) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
798 end (point-max))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
799 (with-syntax-table semantic-lex-syntax-table |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
800 (goto-char start) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
801 (while (and (< (point) end) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
802 (or (not length) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
803 (<= (length semantic-lex-token-stream) length))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
804 (semantic-lex-one-token ,analyzers) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
805 (when (eq semantic-lex-end-point tmp-start) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
806 (error ,(format "%s: endless loop at %%d, after %%S" name) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
807 tmp-start (car semantic-lex-token-stream))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
808 (setq tmp-start semantic-lex-end-point) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
809 (goto-char semantic-lex-end-point) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
810 ;;(when (> (semantic-elapsed-time starttime (current-time)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
811 ;; semantic-lex-timeout) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
812 ;; (error "Timeout during lex at char %d" (point))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
813 (semantic-throw-on-input 'lex) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
814 (semantic-lex-debug-break (car semantic-lex-token-stream)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
815 )) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
816 ;; Check that there is no unterminated block. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
817 (when semantic-lex-block-stack |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
818 (let* ((last (pop semantic-lex-block-stack)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
819 (blk last)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
820 (while blk |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
821 (message |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
822 ,(format "%s: `%%s' block from %%S is unterminated" name) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
823 (car blk) (cadr blk)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
824 (setq blk (pop semantic-lex-block-stack))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
825 (semantic-lex-unterminated-syntax-detected (car last)))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
826 ;; Return to where we started. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
827 ;; Do not wrap in protective stuff so that if there is an error |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
828 ;; thrown, the user knows where. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
829 (goto-char starting-position) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
830 ;; Return the token stream |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
831 (nreverse semantic-lex-token-stream)))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
832 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
833 ;;; Collapsed block tokens delimited by any tokens. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
834 ;; |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
835 (defun semantic-lex-start-block (syntax) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
836 "Mark the last read token as the beginning of a SYNTAX block." |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
837 (if (or (not semantic-lex-maximum-depth) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
838 (< semantic-lex-current-depth semantic-lex-maximum-depth)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
839 (setq semantic-lex-current-depth (1+ semantic-lex-current-depth)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
840 (push (list syntax (car semantic-lex-token-stream)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
841 semantic-lex-block-stack))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
842 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
843 (defun semantic-lex-end-block (syntax) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
844 "Process the end of a previously marked SYNTAX block. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
845 That is, collapse the tokens inside that block, including the |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
846 beginning and end of block tokens, into a high level block token of |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
847 class SYNTAX. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
848 The token at beginning of block is the one marked by a previous call |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
849 to `semantic-lex-start-block'. The current token is the end of block. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
850 The collapsed tokens are saved in `semantic-lex-block-streams'." |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
851 (if (null semantic-lex-block-stack) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
852 (setq semantic-lex-current-depth (1- semantic-lex-current-depth)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
853 (let* ((stream semantic-lex-token-stream) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
854 (blk (pop semantic-lex-block-stack)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
855 (bstream (cdr blk)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
856 (first (car bstream)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
857 (last (pop stream)) ;; The current token mark the EOBLK |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
858 tok) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
859 (if (not (eq (car blk) syntax)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
860 ;; SYNTAX doesn't match the syntax of the current block in |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
861 ;; the stack. So we encountered the end of the SYNTAX block |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
862 ;; before the end of the current one in the stack which is |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
863 ;; signaled unterminated. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
864 (semantic-lex-unterminated-syntax-detected (car blk)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
865 ;; Move tokens found inside the block from the main stream |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
866 ;; into a separate block stream. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
867 (while (and stream (not (eq (setq tok (pop stream)) first))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
868 (push tok bstream)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
869 ;; The token marked as beginning of block was not encountered. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
870 ;; This should not happen! |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
871 (or (eq tok first) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
872 (error "Token %S not found at beginning of block `%s'" |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
873 first syntax)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
874 ;; Save the block stream for future reuse, to avoid to redo |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
875 ;; the lexical analysis of the block content! |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
876 ;; Anchor the block stream with its start position, so we can |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
877 ;; use: (cdr (assq start semantic-lex-block-streams)) to |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
878 ;; quickly retrieve the lexical stream associated to a block. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
879 (setcar blk (semantic-lex-token-start first)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
880 (setcdr blk (nreverse bstream)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
881 (push blk semantic-lex-block-streams) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
882 ;; In the main stream, replace the tokens inside the block by |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
883 ;; a high level block token of class SYNTAX. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
884 (setq semantic-lex-token-stream stream) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
885 (semantic-lex-push-token |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
886 (semantic-lex-token |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
887 syntax (car blk) (semantic-lex-token-end last))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
888 )))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
889 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
890 ;;; Lexical token API |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
891 ;; |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
892 ;; Functions for accessing parts of a token. Use these functions |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
893 ;; instead of accessing the list structure directly because the |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
894 ;; contents of the lexical may change. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
895 ;; |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
896 (defmacro semantic-lex-token (symbol start end &optional str) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
897 "Create a lexical token. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
898 SYMBOL is a symbol representing the class of syntax found. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
899 START and END define the bounds of the token in the current buffer. |
105423
309bc750556d
* files-x.el (modify-dir-local-variable)
Juanma Barranquero <lekktu@gmail.com>
parents:
105377
diff
changeset
|
900 Optional STR is the string for the token only if the bounds in |
309bc750556d
* files-x.el (modify-dir-local-variable)
Juanma Barranquero <lekktu@gmail.com>
parents:
105377
diff
changeset
|
901 the buffer do not cover the string they represent. (As from |
104413
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
902 macro expansion.)" |
106837
855f55740303
Fix typos in comments.
Juanma Barranquero <lekktu@gmail.com>
parents:
106815
diff
changeset
|
903 ;; This if statement checks the existence of a STR argument at |
104413
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
904 ;; compile time, where STR is some symbol or constant. If the |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
905 ;; variable STr (runtime) is nil, this will make an incorrect decision. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
906 ;; |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
907 ;; It is like this to maintain the original speed of the compiled |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
908 ;; code. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
909 (if str |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
910 `(cons ,symbol (cons ,str (cons ,start ,end))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
911 `(cons ,symbol (cons ,start ,end)))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
912 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
913 (defun semantic-lex-token-p (thing) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
914 "Return non-nil if THING is a semantic lex token. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
915 This is an exhaustively robust check." |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
916 (and (consp thing) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
917 (symbolp (car thing)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
918 (or (and (numberp (nth 1 thing)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
919 (numberp (nthcdr 2 thing))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
920 (and (stringp (nth 1 thing)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
921 (numberp (nth 2 thing)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
922 (numberp (nthcdr 3 thing))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
923 )) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
924 ) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
925 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
926 (defun semantic-lex-token-with-text-p (thing) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
927 "Return non-nil if THING is a semantic lex token. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
928 This is an exhaustively robust check." |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
929 (and (consp thing) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
930 (symbolp (car thing)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
931 (= (length thing) 4) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
932 (stringp (nth 1 thing)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
933 (numberp (nth 2 thing)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
934 (numberp (nth 3 thing))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
935 ) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
936 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
937 (defun semantic-lex-token-without-text-p (thing) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
938 "Return non-nil if THING is a semantic lex token. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
939 This is an exhaustively robust check." |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
940 (and (consp thing) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
941 (symbolp (car thing)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
942 (= (length thing) 3) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
943 (numberp (nth 1 thing)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
944 (numberp (nth 2 thing))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
945 ) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
946 |
104446
df08b7ab0ba0
lisp/cedet/semantic/analyze.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents:
104419
diff
changeset
|
947 (eval-and-compile |
df08b7ab0ba0
lisp/cedet/semantic/analyze.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents:
104419
diff
changeset
|
948 |
104413
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
949 (defun semantic-lex-expand-block-specs (specs) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
950 "Expand block specifications SPECS into a Lisp form. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
951 SPECS is a list of (BLOCK BEGIN END) elements where BLOCK, BEGIN, and |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
952 END are token class symbols that indicate to produce one collapsed |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
953 BLOCK token from tokens found between BEGIN and END ones. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
954 BLOCK must be a non-nil symbol, and at least one of the BEGIN or END |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
955 symbols must be non-nil too. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
956 When BEGIN is non-nil, generate a call to `semantic-lex-start-block' |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
957 when a BEGIN token class is encountered. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
958 When END is non-nil, generate a call to `semantic-lex-end-block' when |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
959 an END token class is encountered." |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
960 (let ((class (make-symbol "class")) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
961 (form nil)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
962 (dolist (spec specs) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
963 (when (car spec) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
964 (when (nth 1 spec) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
965 (push `((eq ',(nth 1 spec) ,class) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
966 (semantic-lex-start-block ',(car spec))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
967 form)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
968 (when (nth 2 spec) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
969 (push `((eq ',(nth 2 spec) ,class) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
970 (semantic-lex-end-block ',(car spec))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
971 form)))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
972 (when form |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
973 `((let ((,class (semantic-lex-token-class |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
974 (car semantic-lex-token-stream)))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
975 (cond ,@(nreverse form)))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
976 ))) |
104446
df08b7ab0ba0
lisp/cedet/semantic/analyze.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents:
104419
diff
changeset
|
977 ) |
104413
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
978 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
979 (defmacro semantic-lex-push-token (token &rest blockspecs) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
980 "Push TOKEN in the lexical analyzer token stream. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
981 Return the lexical analysis current end point. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
982 If optional arguments BLOCKSPECS is non-nil, it specifies to process |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
983 collapsed block tokens. See `semantic-lex-expand-block-specs' for |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
984 more details. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
985 This macro should only be called within the bounds of |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
986 `define-lex-analyzer'. It changes the values of the lexical analyzer |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
987 variables `token-stream' and `semantic-lex-end-point'. If you need to |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
988 move `semantic-lex-end-point' somewhere else, just modify this |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
989 variable after calling `semantic-lex-push-token'." |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
990 `(progn |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
991 (push ,token semantic-lex-token-stream) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
992 ,@(semantic-lex-expand-block-specs blockspecs) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
993 (setq semantic-lex-end-point |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
994 (semantic-lex-token-end (car semantic-lex-token-stream))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
995 )) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
996 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
997 (defsubst semantic-lex-token-class (token) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
998 "Fetch the class of the lexical token TOKEN. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
999 See also the function `semantic-lex-token'." |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1000 (car token)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1001 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1002 (defsubst semantic-lex-token-text (token) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1003 "Fetch the text associated with the lexical token TOKEN. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1004 See also the function `semantic-lex-token'." |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1005 (if (stringp (car (cdr token))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1006 (car (cdr token)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1007 (buffer-substring-no-properties |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1008 (semantic-lex-token-start token) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1009 (semantic-lex-token-end token)))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1010 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1011 (defun semantic-lex-init () |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1012 "Initialize any lexical state for this buffer." |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1013 (unless semantic-lex-comment-regex |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1014 (setq semantic-lex-comment-regex |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1015 (if comment-start-skip |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1016 (concat "\\(\\s<\\|" comment-start-skip "\\)") |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1017 "\\(\\s<\\)"))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1018 ;; Setup the lexer syntax-table |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1019 (setq semantic-lex-syntax-table (copy-syntax-table (syntax-table))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1020 (dolist (mod semantic-lex-syntax-modifications) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1021 (modify-syntax-entry |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1022 (car mod) (nth 1 mod) semantic-lex-syntax-table))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1023 |
104446
df08b7ab0ba0
lisp/cedet/semantic/analyze.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents:
104419
diff
changeset
|
1024 ;;;###autoload |
104413
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1025 (define-overloadable-function semantic-lex (start end &optional depth length) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1026 "Lexically analyze text in the current buffer between START and END. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1027 Optional argument DEPTH indicates at what level to scan over entire |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1028 lists. The last argument, LENGTH specifies that `semantic-lex' |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1029 should only return LENGTH tokens. The return value is a token stream. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1030 Each element is a list, such of the form |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1031 (symbol start-expression . end-expression) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1032 where SYMBOL denotes the token type. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1033 See `semantic-lex-tokens' variable for details on token types. END |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1034 does not mark the end of the text scanned, only the end of the |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1035 beginning of text scanned. Thus, if a string extends past END, the |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1036 end of the return token will be larger than END. To truly restrict |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1037 scanning, use `narrow-to-region'." |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1038 (funcall semantic-lex-analyzer start end depth length)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1039 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1040 (defsubst semantic-lex-buffer (&optional depth) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1041 "Lex the current buffer. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1042 Optional argument DEPTH is the depth to scan into lists." |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1043 (semantic-lex (point-min) (point-max) depth)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1044 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1045 (defsubst semantic-lex-list (semlist depth) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1046 "Lex the body of SEMLIST to DEPTH." |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1047 (semantic-lex (semantic-lex-token-start semlist) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1048 (semantic-lex-token-end semlist) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1049 depth)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1050 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1051 ;;; Analyzer creation macros |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1052 ;; |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1053 ;; An individual analyzer is a condition and code that goes with it. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1054 ;; |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1055 ;; Created analyzers become variables with the code associated with them |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1056 ;; as the symbol value. These analyzers are assembled into a lexer |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1057 ;; to create new lexical analyzers. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1058 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1059 (defcustom semantic-lex-debug-analyzers nil |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1060 "Non nil means to debug analyzers with syntax protection. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1061 Only in effect if `debug-on-error' is also non-nil." |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1062 :group 'semantic |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1063 :type 'boolean) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1064 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1065 (defmacro semantic-lex-unterminated-syntax-protection (syntax &rest forms) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1066 "For SYNTAX, execute FORMS with protection for unterminated syntax. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1067 If FORMS throws an error, treat this as a syntax problem, and |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1068 execute the unterminated syntax code. FORMS should return a position. |
105340 | 1069 Irregardless of an error, the cursor should be moved to the end of |
104413
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1070 the desired syntax, and a position returned. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1071 If `debug-on-error' is set, errors are not caught, so that you can |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1072 debug them. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1073 Avoid using a large FORMS since it is duplicated." |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1074 `(if (and debug-on-error semantic-lex-debug-analyzers) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1075 (progn ,@forms) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1076 (condition-case nil |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1077 (progn ,@forms) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1078 (error |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1079 (semantic-lex-unterminated-syntax-detected ,syntax))))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1080 (put 'semantic-lex-unterminated-syntax-protection |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1081 'lisp-indent-function 1) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1082 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1083 (defmacro define-lex-analyzer (name doc condition &rest forms) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1084 "Create a single lexical analyzer NAME with DOC. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1085 When an analyzer is called, the current buffer and point are |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1086 positioned in a buffer at the location to be analyzed. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1087 CONDITION is an expression which returns t if FORMS should be run. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1088 Within the bounds of CONDITION and FORMS, the use of backquote |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1089 can be used to evaluate expressions at compile time. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1090 While forms are running, the following variables will be locally bound: |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1091 `semantic-lex-analysis-bounds' - The bounds of the current analysis. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1092 of the form (START . END) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1093 `semantic-lex-maximum-depth' - The maximum depth of semantic-list |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1094 for the current analysis. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1095 `semantic-lex-current-depth' - The current depth of `semantic-list' that has |
105340 | 1096 been descended. |
104413
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1097 `semantic-lex-end-point' - End Point after match. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1098 Analyzers should set this to a buffer location if their |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1099 match string does not represent the end of the matched text. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1100 `semantic-lex-token-stream' - The token list being collected. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1101 Add new lexical tokens to this list. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1102 Proper action in FORMS is to move the value of `semantic-lex-end-point' to |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1103 after the location of the analyzed entry, and to add any discovered tokens |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1104 at the beginning of `semantic-lex-token-stream'. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1105 This can be done by using `semantic-lex-push-token'." |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1106 `(eval-and-compile |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1107 (defvar ,name nil ,doc) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1108 (defun ,name nil) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1109 ;; Do this part separately so that re-evaluation rebuilds this code. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1110 (setq ,name '(,condition ,@forms)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1111 ;; Build a single lexical analyzer function, so the doc for |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1112 ;; function help is automatically provided, and perhaps the |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1113 ;; function could be useful for testing and debugging one |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1114 ;; analyzer. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1115 (fset ',name (lambda () ,doc |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1116 (let ((semantic-lex-token-stream nil) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1117 (semantic-lex-end-point (point)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1118 (semantic-lex-analysis-bounds |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1119 (cons (point) (point-max))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1120 (semantic-lex-current-depth 0) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1121 (semantic-lex-maximum-depth |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1122 semantic-lex-depth) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1123 ) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1124 (when ,condition ,@forms) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1125 semantic-lex-token-stream))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1126 )) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1127 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1128 (defmacro define-lex-regex-analyzer (name doc regexp &rest forms) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1129 "Create a lexical analyzer with NAME and DOC that will match REGEXP. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1130 FORMS are evaluated upon a successful match. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1131 See `define-lex-analyzer' for more about analyzers." |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1132 `(define-lex-analyzer ,name |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1133 ,doc |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1134 (looking-at ,regexp) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1135 ,@forms |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1136 )) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1137 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1138 (defmacro define-lex-simple-regex-analyzer (name doc regexp toksym |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1139 &optional index |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1140 &rest forms) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1141 "Create a lexical analyzer with NAME and DOC that match REGEXP. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1142 TOKSYM is the symbol to use when creating a semantic lexical token. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1143 INDEX is the index into the match that defines the bounds of the token. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1144 Index should be a plain integer, and not specified in the macro as an |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1145 expression. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1146 FORMS are evaluated upon a successful match BEFORE the new token is |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1147 created. It is valid to ignore FORMS. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1148 See `define-lex-analyzer' for more about analyzers." |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1149 `(define-lex-analyzer ,name |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1150 ,doc |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1151 (looking-at ,regexp) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1152 ,@forms |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1153 (semantic-lex-push-token |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1154 (semantic-lex-token ,toksym |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1155 (match-beginning ,(or index 0)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1156 (match-end ,(or index 0)))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1157 )) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1158 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1159 (defmacro define-lex-block-analyzer (name doc spec1 &rest specs) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1160 "Create a lexical analyzer NAME for paired delimiters blocks. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1161 It detects a paired delimiters block or the corresponding open or |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1162 close delimiter depending on the value of the variable |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1163 `semantic-lex-current-depth'. DOC is the documentation string of the lexical |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1164 analyzer. SPEC1 and SPECS specify the token symbols and open, close |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1165 delimiters used. Each SPEC has the form: |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1166 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1167 \(BLOCK-SYM (OPEN-DELIM OPEN-SYM) (CLOSE-DELIM CLOSE-SYM)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1168 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1169 where BLOCK-SYM is the symbol returned in a block token. OPEN-DELIM |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1170 and CLOSE-DELIM are respectively the open and close delimiters |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1171 identifying a block. OPEN-SYM and CLOSE-SYM are respectively the |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1172 symbols returned in open and close tokens." |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1173 (let ((specs (cons spec1 specs)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1174 spec open olist clist) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1175 (while specs |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1176 (setq spec (car specs) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1177 specs (cdr specs) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1178 open (nth 1 spec) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1179 ;; build alist ((OPEN-DELIM OPEN-SYM BLOCK-SYM) ...) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1180 olist (cons (list (car open) (cadr open) (car spec)) olist) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1181 ;; build alist ((CLOSE-DELIM CLOSE-SYM) ...) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1182 clist (cons (nth 2 spec) clist))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1183 `(define-lex-analyzer ,name |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1184 ,doc |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1185 (and |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1186 (looking-at "\\(\\s(\\|\\s)\\)") |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1187 (let ((text (match-string 0)) match) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1188 (cond |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1189 ((setq match (assoc text ',olist)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1190 (if (or (not semantic-lex-maximum-depth) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1191 (< semantic-lex-current-depth semantic-lex-maximum-depth)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1192 (progn |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1193 (setq semantic-lex-current-depth (1+ semantic-lex-current-depth)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1194 (semantic-lex-push-token |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1195 (semantic-lex-token |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1196 (nth 1 match) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1197 (match-beginning 0) (match-end 0)))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1198 (semantic-lex-push-token |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1199 (semantic-lex-token |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1200 (nth 2 match) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1201 (match-beginning 0) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1202 (save-excursion |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1203 (semantic-lex-unterminated-syntax-protection (nth 2 match) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1204 (forward-list 1) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1205 (point))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1206 )) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1207 )) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1208 ((setq match (assoc text ',clist)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1209 (setq semantic-lex-current-depth (1- semantic-lex-current-depth)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1210 (semantic-lex-push-token |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1211 (semantic-lex-token |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1212 (nth 1 match) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1213 (match-beginning 0) (match-end 0))))))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1214 ))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1215 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1216 ;;; Analyzers |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1217 ;; |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1218 ;; Pre-defined common analyzers. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1219 ;; |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1220 (define-lex-analyzer semantic-lex-default-action |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1221 "The default action when no other lexical actions match text. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1222 This action will just throw an error." |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1223 t |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1224 (error "Unmatched Text during Lexical Analysis")) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1225 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1226 (define-lex-analyzer semantic-lex-beginning-of-line |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1227 "Detect and create a beginning of line token (BOL)." |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1228 (and (bolp) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1229 ;; Just insert a (bol N . N) token in the token stream, |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1230 ;; without moving the point. N is the point at the |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1231 ;; beginning of line. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1232 (semantic-lex-push-token (semantic-lex-token 'bol (point) (point))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1233 nil) ;; CONTINUE |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1234 ;; We identify and add the BOL token onto the stream, but since |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1235 ;; semantic-lex-end-point doesn't move, we always fail CONDITION, and have no |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1236 ;; FORMS body. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1237 nil) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1238 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1239 (define-lex-simple-regex-analyzer semantic-lex-newline |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1240 "Detect and create newline tokens." |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1241 "\\s-*\\(\n\\|\\s>\\)" 'newline 1) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1242 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1243 (define-lex-regex-analyzer semantic-lex-newline-as-whitespace |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1244 "Detect and create newline tokens. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1245 Use this ONLY if newlines are not whitespace characters (such as when |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1246 they are comment end characters) AND when you want whitespace tokens." |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1247 "\\s-*\\(\n\\|\\s>\\)" |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1248 ;; Language wants whitespaces. Create a token for it. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1249 (if (eq (semantic-lex-token-class (car semantic-lex-token-stream)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1250 'whitespace) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1251 ;; Merge whitespace tokens together if they are adjacent. Two |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1252 ;; whitespace tokens may be sperated by a comment which is not in |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1253 ;; the token stream. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1254 (setcdr (semantic-lex-token-bounds (car semantic-lex-token-stream)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1255 (match-end 0)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1256 (semantic-lex-push-token |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1257 (semantic-lex-token |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1258 'whitespace (match-beginning 0) (match-end 0))))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1259 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1260 (define-lex-regex-analyzer semantic-lex-ignore-newline |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1261 "Detect and ignore newline tokens. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1262 Use this ONLY if newlines are not whitespace characters (such as when |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1263 they are comment end characters)." |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1264 "\\s-*\\(\n\\|\\s>\\)" |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1265 (setq semantic-lex-end-point (match-end 0))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1266 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1267 (define-lex-regex-analyzer semantic-lex-whitespace |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1268 "Detect and create whitespace tokens." |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1269 ;; catch whitespace when needed |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1270 "\\s-+" |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1271 ;; Language wants whitespaces. Create a token for it. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1272 (if (eq (semantic-lex-token-class (car semantic-lex-token-stream)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1273 'whitespace) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1274 ;; Merge whitespace tokens together if they are adjacent. Two |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1275 ;; whitespace tokens may be sperated by a comment which is not in |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1276 ;; the token stream. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1277 (progn |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1278 (setq semantic-lex-end-point (match-end 0)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1279 (setcdr (semantic-lex-token-bounds (car semantic-lex-token-stream)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1280 semantic-lex-end-point)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1281 (semantic-lex-push-token |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1282 (semantic-lex-token |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1283 'whitespace (match-beginning 0) (match-end 0))))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1284 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1285 (define-lex-regex-analyzer semantic-lex-ignore-whitespace |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1286 "Detect and skip over whitespace tokens." |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1287 ;; catch whitespace when needed |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1288 "\\s-+" |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1289 ;; Skip over the detected whitespace, do not create a token for it. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1290 (setq semantic-lex-end-point (match-end 0))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1291 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1292 (define-lex-simple-regex-analyzer semantic-lex-number |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1293 "Detect and create number tokens. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1294 See `semantic-lex-number-expression' for details on matching numbers, |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1295 and number formats." |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1296 semantic-lex-number-expression 'number) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1297 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1298 (define-lex-regex-analyzer semantic-lex-symbol-or-keyword |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1299 "Detect and create symbol and keyword tokens." |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1300 "\\(\\sw\\|\\s_\\)+" |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1301 (semantic-lex-push-token |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1302 (semantic-lex-token |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1303 (or (semantic-lex-keyword-p (match-string 0)) 'symbol) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1304 (match-beginning 0) (match-end 0)))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1305 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1306 (define-lex-simple-regex-analyzer semantic-lex-charquote |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1307 "Detect and create charquote tokens." |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1308 ;; Character quoting characters (ie, \n as newline) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1309 "\\s\\+" 'charquote) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1310 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1311 (define-lex-simple-regex-analyzer semantic-lex-punctuation |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1312 "Detect and create punctuation tokens." |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1313 "\\(\\s.\\|\\s$\\|\\s'\\)" 'punctuation) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1314 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1315 (define-lex-analyzer semantic-lex-punctuation-type |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1316 "Detect and create a punctuation type token. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1317 Recognized punctuations are defined in the current table of lexical |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1318 types, as the value of the `punctuation' token type." |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1319 (and (looking-at "\\(\\s.\\|\\s$\\|\\s'\\)+") |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1320 (let* ((key (match-string 0)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1321 (pos (match-beginning 0)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1322 (end (match-end 0)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1323 (len (- end pos)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1324 (lst (semantic-lex-type-value "punctuation" t)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1325 (def (car lst)) ;; default lexical symbol or nil |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1326 (lst (cdr lst)) ;; alist of (LEX-SYM . PUNCT-STRING) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1327 (elt nil)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1328 (if lst |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1329 ;; Starting with the longest one, search if the |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1330 ;; punctuation string is defined for this language. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1331 (while (and (> len 0) (not (setq elt (rassoc key lst)))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1332 (setq len (1- len) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1333 key (substring key 0 len)))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1334 (if elt ;; Return the punctuation token found |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1335 (semantic-lex-push-token |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1336 (semantic-lex-token (car elt) pos (+ pos len))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1337 (if def ;; Return a default generic token |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1338 (semantic-lex-push-token |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1339 (semantic-lex-token def pos end)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1340 ;; Nothing match |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1341 ))))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1342 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1343 (define-lex-regex-analyzer semantic-lex-paren-or-list |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1344 "Detect open parenthesis. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1345 Return either a paren token or a semantic list token depending on |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1346 `semantic-lex-current-depth'." |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1347 "\\s(" |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1348 (if (or (not semantic-lex-maximum-depth) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1349 (< semantic-lex-current-depth semantic-lex-maximum-depth)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1350 (progn |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1351 (setq semantic-lex-current-depth (1+ semantic-lex-current-depth)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1352 (semantic-lex-push-token |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1353 (semantic-lex-token |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1354 'open-paren (match-beginning 0) (match-end 0)))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1355 (semantic-lex-push-token |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1356 (semantic-lex-token |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1357 'semantic-list (match-beginning 0) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1358 (save-excursion |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1359 (semantic-lex-unterminated-syntax-protection 'semantic-list |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1360 (forward-list 1) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1361 (point)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1362 ))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1363 )) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1364 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1365 (define-lex-simple-regex-analyzer semantic-lex-open-paren |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1366 "Detect and create an open parenthisis token." |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1367 "\\s(" 'open-paren 0 (setq semantic-lex-current-depth (1+ semantic-lex-current-depth))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1368 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1369 (define-lex-simple-regex-analyzer semantic-lex-close-paren |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1370 "Detect and create a close paren token." |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1371 "\\s)" 'close-paren 0 (setq semantic-lex-current-depth (1- semantic-lex-current-depth))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1372 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1373 (define-lex-regex-analyzer semantic-lex-string |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1374 "Detect and create a string token." |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1375 "\\s\"" |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1376 ;; Zing to the end of this string. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1377 (semantic-lex-push-token |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1378 (semantic-lex-token |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1379 'string (point) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1380 (save-excursion |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1381 (semantic-lex-unterminated-syntax-protection 'string |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1382 (forward-sexp 1) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1383 (point)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1384 )))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1385 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1386 (define-lex-regex-analyzer semantic-lex-comments |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1387 "Detect and create a comment token." |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1388 semantic-lex-comment-regex |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1389 (save-excursion |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1390 (forward-comment 1) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1391 ;; Generate newline token if enabled |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1392 (if (bolp) (backward-char 1)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1393 (setq semantic-lex-end-point (point)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1394 ;; Language wants comments or want them as whitespaces, |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1395 ;; link them together. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1396 (if (eq (semantic-lex-token-class (car semantic-lex-token-stream)) 'comment) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1397 (setcdr (semantic-lex-token-bounds (car semantic-lex-token-stream)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1398 semantic-lex-end-point) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1399 (semantic-lex-push-token |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1400 (semantic-lex-token |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1401 'comment (match-beginning 0) semantic-lex-end-point))))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1402 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1403 (define-lex-regex-analyzer semantic-lex-comments-as-whitespace |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1404 "Detect comments and create a whitespace token." |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1405 semantic-lex-comment-regex |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1406 (save-excursion |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1407 (forward-comment 1) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1408 ;; Generate newline token if enabled |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1409 (if (bolp) (backward-char 1)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1410 (setq semantic-lex-end-point (point)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1411 ;; Language wants comments or want them as whitespaces, |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1412 ;; link them together. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1413 (if (eq (semantic-lex-token-class (car semantic-lex-token-stream)) 'whitespace) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1414 (setcdr (semantic-lex-token-bounds (car semantic-lex-token-stream)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1415 semantic-lex-end-point) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1416 (semantic-lex-push-token |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1417 (semantic-lex-token |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1418 'whitespace (match-beginning 0) semantic-lex-end-point))))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1419 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1420 (define-lex-regex-analyzer semantic-lex-ignore-comments |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1421 "Detect and create a comment token." |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1422 semantic-lex-comment-regex |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1423 (let ((comment-start-point (point))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1424 (forward-comment 1) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1425 (if (eq (point) comment-start-point) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1426 ;; In this case our start-skip string failed |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1427 ;; to work properly. Lets try and move over |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1428 ;; whatever white space we matched to begin |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1429 ;; with. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1430 (skip-syntax-forward "-.'" |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1431 (save-excursion |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1432 (end-of-line) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1433 (point))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1434 ;; We may need to back up so newlines or whitespace is generated. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1435 (if (bolp) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1436 (backward-char 1))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1437 (if (eq (point) comment-start-point) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1438 (error "Strange comment syntax prevents lexical analysis")) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1439 (setq semantic-lex-end-point (point)))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1440 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1441 ;;; Comment lexer |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1442 ;; |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1443 ;; Predefined lexers that could be used instead of creating new |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1444 ;; analyers. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1445 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1446 (define-lex semantic-comment-lexer |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1447 "A simple lexical analyzer that handles comments. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1448 This lexer will only return comment tokens. It is the default lexer |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1449 used by `semantic-find-doc-snarf-comment' to snarf up the comment at |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1450 point." |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1451 semantic-lex-ignore-whitespace |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1452 semantic-lex-ignore-newline |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1453 semantic-lex-comments |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1454 semantic-lex-default-action) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1455 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1456 ;;; Test Lexer |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1457 ;; |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1458 (define-lex semantic-simple-lexer |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1459 "A simple lexical analyzer that handles simple buffers. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1460 This lexer ignores comments and whitespace, and will return |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1461 syntax as specified by the syntax table." |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1462 semantic-lex-ignore-whitespace |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1463 semantic-lex-ignore-newline |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1464 semantic-lex-number |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1465 semantic-lex-symbol-or-keyword |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1466 semantic-lex-charquote |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1467 semantic-lex-paren-or-list |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1468 semantic-lex-close-paren |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1469 semantic-lex-string |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1470 semantic-lex-ignore-comments |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1471 semantic-lex-punctuation |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1472 semantic-lex-default-action) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1473 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1474 ;;; Analyzers generated from grammar. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1475 ;; |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1476 ;; Some analyzers are hand written. Analyzers created with these |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1477 ;; functions are generated from the grammar files. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1478 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1479 (defmacro define-lex-keyword-type-analyzer (name doc syntax) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1480 "Define a keyword type analyzer NAME with DOC string. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1481 SYNTAX is the regexp that matches a keyword syntactic expression." |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1482 (let ((key (make-symbol "key"))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1483 `(define-lex-analyzer ,name |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1484 ,doc |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1485 (and (looking-at ,syntax) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1486 (let ((,key (semantic-lex-keyword-p (match-string 0)))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1487 (when ,key |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1488 (semantic-lex-push-token |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1489 (semantic-lex-token |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1490 ,key (match-beginning 0) (match-end 0))))))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1491 )) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1492 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1493 (defmacro define-lex-sexp-type-analyzer (name doc syntax token) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1494 "Define a sexp type analyzer NAME with DOC string. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1495 SYNTAX is the regexp that matches the beginning of the s-expression. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1496 TOKEN is the lexical token returned when SYNTAX matches." |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1497 `(define-lex-regex-analyzer ,name |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1498 ,doc |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1499 ,syntax |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1500 (semantic-lex-push-token |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1501 (semantic-lex-token |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1502 ,token (point) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1503 (save-excursion |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1504 (semantic-lex-unterminated-syntax-protection ,token |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1505 (forward-sexp 1) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1506 (point)))))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1507 ) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1508 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1509 (defmacro define-lex-regex-type-analyzer (name doc syntax matches default) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1510 "Define a regexp type analyzer NAME with DOC string. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1511 SYNTAX is the regexp that matches a syntactic expression. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1512 MATCHES is an alist of lexical elements used to refine the syntactic |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1513 expression. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1514 DEFAULT is the default lexical token returned when no MATCHES." |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1515 (if matches |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1516 (let* ((val (make-symbol "val")) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1517 (lst (make-symbol "lst")) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1518 (elt (make-symbol "elt")) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1519 (pos (make-symbol "pos")) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1520 (end (make-symbol "end"))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1521 `(define-lex-analyzer ,name |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1522 ,doc |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1523 (and (looking-at ,syntax) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1524 (let* ((,val (match-string 0)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1525 (,pos (match-beginning 0)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1526 (,end (match-end 0)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1527 (,lst ,matches) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1528 ,elt) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1529 (while (and ,lst (not ,elt)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1530 (if (string-match (cdar ,lst) ,val) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1531 (setq ,elt (caar ,lst)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1532 (setq ,lst (cdr ,lst)))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1533 (semantic-lex-push-token |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1534 (semantic-lex-token (or ,elt ,default) ,pos ,end)))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1535 )) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1536 `(define-lex-simple-regex-analyzer ,name |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1537 ,doc |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1538 ,syntax ,default) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1539 )) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1540 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1541 (defmacro define-lex-string-type-analyzer (name doc syntax matches default) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1542 "Define a string type analyzer NAME with DOC string. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1543 SYNTAX is the regexp that matches a syntactic expression. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1544 MATCHES is an alist of lexical elements used to refine the syntactic |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1545 expression. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1546 DEFAULT is the default lexical token returned when no MATCHES." |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1547 (if matches |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1548 (let* ((val (make-symbol "val")) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1549 (lst (make-symbol "lst")) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1550 (elt (make-symbol "elt")) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1551 (pos (make-symbol "pos")) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1552 (end (make-symbol "end")) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1553 (len (make-symbol "len"))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1554 `(define-lex-analyzer ,name |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1555 ,doc |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1556 (and (looking-at ,syntax) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1557 (let* ((,val (match-string 0)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1558 (,pos (match-beginning 0)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1559 (,end (match-end 0)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1560 (,len (- ,end ,pos)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1561 (,lst ,matches) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1562 ,elt) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1563 ;; Starting with the longest one, search if a lexical |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1564 ;; value match a token defined for this language. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1565 (while (and (> ,len 0) (not (setq ,elt (rassoc ,val ,lst)))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1566 (setq ,len (1- ,len) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1567 ,val (substring ,val 0 ,len))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1568 (when ,elt ;; Adjust token end position. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1569 (setq ,elt (car ,elt) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1570 ,end (+ ,pos ,len))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1571 (semantic-lex-push-token |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1572 (semantic-lex-token (or ,elt ,default) ,pos ,end)))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1573 )) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1574 `(define-lex-simple-regex-analyzer ,name |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1575 ,doc |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1576 ,syntax ,default) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1577 )) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1578 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1579 (defmacro define-lex-block-type-analyzer (name doc syntax matches) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1580 "Define a block type analyzer NAME with DOC string. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1581 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1582 SYNTAX is the regexp that matches block delimiters, typically the |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1583 open (`\\\\s(') and close (`\\\\s)') parenthesis syntax classes. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1584 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1585 MATCHES is a pair (OPEN-SPECS . CLOSE-SPECS) that defines blocks. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1586 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1587 OPEN-SPECS is a list of (OPEN-DELIM OPEN-TOKEN BLOCK-TOKEN) elements |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1588 where: |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1589 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1590 OPEN-DELIM is a string: the block open delimiter character. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1591 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1592 OPEN-TOKEN is the lexical token class associated to the OPEN-DELIM |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1593 delimiter. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1594 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1595 BLOCK-TOKEN is the lexical token class associated to the block |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1596 that starts at the OPEN-DELIM delimiter. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1597 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1598 CLOSE-SPECS is a list of (CLOSE-DELIM CLOSE-TOKEN) elements where: |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1599 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1600 CLOSE-DELIM is a string: the block end delimiter character. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1601 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1602 CLOSE-TOKEN is the lexical token class associated to the |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1603 CLOSE-DELIM delimiter. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1604 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1605 Each element in OPEN-SPECS must have a corresponding element in |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1606 CLOSE-SPECS. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1607 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1608 The lexer will return a BLOCK-TOKEN token when the value of |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1609 `semantic-lex-current-depth' is greater than or equal to the maximum |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1610 depth of parenthesis tracking (see also the function `semantic-lex'). |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1611 Otherwise it will return OPEN-TOKEN and CLOSE-TOKEN tokens. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1612 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1613 TO DO: Put the following in the developer's guide and just put a |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1614 reference here. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1615 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1616 In the grammar: |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1617 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1618 The value of a block token must be a string that contains a readable |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1619 sexp of the form: |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1620 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1621 \"(OPEN-TOKEN CLOSE-TOKEN)\" |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1622 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1623 OPEN-TOKEN and CLOSE-TOKEN represent the block delimiters, and must be |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1624 lexical tokens of respectively `open-paren' and `close-paren' types. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1625 Their value is the corresponding delimiter character as a string. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1626 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1627 Here is a small example to analyze a parenthesis block: |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1628 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1629 %token <block> PAREN_BLOCK \"(LPAREN RPAREN)\" |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1630 %token <open-paren> LPAREN \"(\" |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1631 %token <close-paren> RPAREN \")\" |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1632 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1633 When the lexer encounters the open-paren delimiter \"(\": |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1634 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1635 - If the maximum depth of parenthesis tracking is not reached (that |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1636 is, current depth < max depth), it returns a (LPAREN start . end) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1637 token, then continue analysis inside the block. Later, when the |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1638 corresponding close-paren delimiter \")\" will be encountered, it |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1639 will return a (RPAREN start . end) token. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1640 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1641 - If the maximum depth of parenthesis tracking is reached (current |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1642 depth >= max depth), it returns the whole parenthesis block as |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1643 a (PAREN_BLOCK start . end) token." |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1644 (let* ((val (make-symbol "val")) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1645 (lst (make-symbol "lst")) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1646 (elt (make-symbol "elt"))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1647 `(define-lex-analyzer ,name |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1648 ,doc |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1649 (and |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1650 (looking-at ,syntax) ;; "\\(\\s(\\|\\s)\\)" |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1651 (let ((,val (match-string 0)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1652 (,lst ,matches) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1653 ,elt) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1654 (cond |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1655 ((setq ,elt (assoc ,val (car ,lst))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1656 (if (or (not semantic-lex-maximum-depth) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1657 (< semantic-lex-current-depth semantic-lex-maximum-depth)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1658 (progn |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1659 (setq semantic-lex-current-depth (1+ semantic-lex-current-depth)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1660 (semantic-lex-push-token |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1661 (semantic-lex-token |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1662 (nth 1 ,elt) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1663 (match-beginning 0) (match-end 0)))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1664 (semantic-lex-push-token |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1665 (semantic-lex-token |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1666 (nth 2 ,elt) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1667 (match-beginning 0) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1668 (save-excursion |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1669 (semantic-lex-unterminated-syntax-protection (nth 2 ,elt) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1670 (forward-list 1) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1671 (point))))))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1672 ((setq ,elt (assoc ,val (cdr ,lst))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1673 (setq semantic-lex-current-depth (1- semantic-lex-current-depth)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1674 (semantic-lex-push-token |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1675 (semantic-lex-token |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1676 (nth 1 ,elt) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1677 (match-beginning 0) (match-end 0)))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1678 )))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1679 )) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1680 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1681 ;;; Lexical Safety |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1682 ;; |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1683 ;; The semantic lexers, unlike other lexers, can throw errors on |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1684 ;; unbalanced syntax. Since editing is all about changeging test |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1685 ;; we need to provide a convenient way to protect against syntactic |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1686 ;; inequalities. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1687 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1688 (defmacro semantic-lex-catch-errors (symbol &rest forms) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1689 "Using SYMBOL, execute FORMS catching lexical errors. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1690 If FORMS results in a call to the parser that throws a lexical error, |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1691 the error will be caught here without the buffer's cache being thrown |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1692 out of date. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1693 If there is an error, the syntax that failed is returned. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1694 If there is no error, then the last value of FORMS is returned." |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1695 (let ((ret (make-symbol "ret")) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1696 (syntax (make-symbol "syntax")) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1697 (start (make-symbol "start")) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1698 (end (make-symbol "end"))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1699 `(let* ((semantic-lex-unterminated-syntax-end-function |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1700 (lambda (,syntax ,start ,end) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1701 (throw ',symbol ,syntax))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1702 ;; Delete the below when semantic-flex is fully retired. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1703 (semantic-flex-unterminated-syntax-end-function |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1704 semantic-lex-unterminated-syntax-end-function) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1705 (,ret (catch ',symbol |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1706 (save-excursion |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1707 ,@forms |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1708 nil)))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1709 ;; Great Sadness. Assume that FORMS execute within the |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1710 ;; confines of the current buffer only! Mark this thing |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1711 ;; unparseable iff the special symbol was thrown. This |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1712 ;; will prevent future calls from parsing, but will allow |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1713 ;; then to still return the cache. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1714 (when ,ret |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1715 ;; Leave this message off. If an APP using this fcn wants |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1716 ;; a message, they can do it themselves. This cleans up |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1717 ;; problems with the idle scheduler obscuring useful data. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1718 ;;(message "Buffer not currently parsable (%S)." ,ret) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1719 (semantic-parse-tree-unparseable)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1720 ,ret))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1721 (put 'semantic-lex-catch-errors 'lisp-indent-function 1) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1722 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1723 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1724 ;;; Interfacing with edebug |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1725 ;; |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1726 (add-hook |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1727 'edebug-setup-hook |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1728 #'(lambda () |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1729 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1730 (def-edebug-spec define-lex |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1731 (&define name stringp (&rest symbolp)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1732 ) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1733 (def-edebug-spec define-lex-analyzer |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1734 (&define name stringp form def-body) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1735 ) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1736 (def-edebug-spec define-lex-regex-analyzer |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1737 (&define name stringp form def-body) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1738 ) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1739 (def-edebug-spec define-lex-simple-regex-analyzer |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1740 (&define name stringp form symbolp [ &optional form ] def-body) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1741 ) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1742 (def-edebug-spec define-lex-block-analyzer |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1743 (&define name stringp form (&rest form)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1744 ) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1745 (def-edebug-spec semantic-lex-catch-errors |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1746 (symbolp def-body) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1747 ) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1748 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1749 )) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1750 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1751 ;;; Compatibility with Semantic 1.x lexical analysis |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1752 ;; |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1753 ;; NOTE: DELETE THIS SOMEDAY SOON |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1754 |
105760
d0906291f75b
* cedet/semantic/fw.el (semantic-alias-obsolete)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105423
diff
changeset
|
1755 (semantic-alias-obsolete 'semantic-flex-start 'semantic-lex-token-start "23.2") |
d0906291f75b
* cedet/semantic/fw.el (semantic-alias-obsolete)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105423
diff
changeset
|
1756 (semantic-alias-obsolete 'semantic-flex-end 'semantic-lex-token-end "23.2") |
d0906291f75b
* cedet/semantic/fw.el (semantic-alias-obsolete)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105423
diff
changeset
|
1757 (semantic-alias-obsolete 'semantic-flex-text 'semantic-lex-token-text "23.2") |
d0906291f75b
* cedet/semantic/fw.el (semantic-alias-obsolete)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105423
diff
changeset
|
1758 (semantic-alias-obsolete 'semantic-flex-make-keyword-table 'semantic-lex-make-keyword-table "23.2") |
d0906291f75b
* cedet/semantic/fw.el (semantic-alias-obsolete)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105423
diff
changeset
|
1759 (semantic-alias-obsolete 'semantic-flex-keyword-p 'semantic-lex-keyword-p "23.2") |
d0906291f75b
* cedet/semantic/fw.el (semantic-alias-obsolete)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105423
diff
changeset
|
1760 (semantic-alias-obsolete 'semantic-flex-keyword-put 'semantic-lex-keyword-put "23.2") |
d0906291f75b
* cedet/semantic/fw.el (semantic-alias-obsolete)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105423
diff
changeset
|
1761 (semantic-alias-obsolete 'semantic-flex-keyword-get 'semantic-lex-keyword-get "23.2") |
d0906291f75b
* cedet/semantic/fw.el (semantic-alias-obsolete)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105423
diff
changeset
|
1762 (semantic-alias-obsolete 'semantic-flex-map-keywords 'semantic-lex-map-keywords "23.2") |
d0906291f75b
* cedet/semantic/fw.el (semantic-alias-obsolete)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105423
diff
changeset
|
1763 (semantic-alias-obsolete 'semantic-flex-keywords 'semantic-lex-keywords "23.2") |
d0906291f75b
* cedet/semantic/fw.el (semantic-alias-obsolete)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105423
diff
changeset
|
1764 (semantic-alias-obsolete 'semantic-flex-buffer 'semantic-lex-buffer "23.2") |
d0906291f75b
* cedet/semantic/fw.el (semantic-alias-obsolete)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105423
diff
changeset
|
1765 (semantic-alias-obsolete 'semantic-flex-list 'semantic-lex-list "23.2") |
104413
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1766 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1767 ;; This simple scanner uses the syntax table to generate a stream of |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1768 ;; simple tokens of the form: |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1769 ;; |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1770 ;; (SYMBOL START . END) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1771 ;; |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1772 ;; Where symbol is the type of thing it is. START and END mark that |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1773 ;; objects boundary. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1774 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1775 (defvar semantic-flex-tokens semantic-lex-tokens |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1776 "An alist of of semantic token types. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1777 See variable `semantic-lex-tokens'.") |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1778 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1779 (defvar semantic-flex-unterminated-syntax-end-function |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1780 (lambda (syntax syntax-start flex-end) flex-end) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1781 "Function called when unterminated syntax is encountered. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1782 This should be set to one function. That function should take three |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1783 parameters. The SYNTAX, or type of syntax which is unterminated. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1784 SYNTAX-START where the broken syntax begins. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1785 FLEX-END is where the lexical analysis was asked to end. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1786 This function can be used for languages that can intelligently fix up |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1787 broken syntax, or the exit lexical analysis via `throw' or `signal' |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1788 when finding unterminated syntax.") |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1789 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1790 (defvar semantic-flex-extensions nil |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1791 "Buffer local extensions to the lexical analyzer. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1792 This should contain an alist with a key of a regex and a data element of |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1793 a function. The function should both move point, and return a lexical |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1794 token of the form: |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1795 ( TYPE START . END) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1796 nil is also a valid return value. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1797 TYPE can be any type of symbol, as long as it doesn't occur as a |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1798 nonterminal in the language definition.") |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1799 (make-variable-buffer-local 'semantic-flex-extensions) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1800 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1801 (defvar semantic-flex-syntax-modifications nil |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1802 "Changes to the syntax table for this buffer. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1803 These changes are active only while the buffer is being flexed. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1804 This is a list where each element has the form: |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1805 (CHAR CLASS) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1806 CHAR is the char passed to `modify-syntax-entry', |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1807 and CLASS is the string also passed to `modify-syntax-entry' to define |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1808 what syntax class CHAR has.") |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1809 (make-variable-buffer-local 'semantic-flex-syntax-modifications) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1810 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1811 (defvar semantic-ignore-comments t |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1812 "Default comment handling. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1813 t means to strip comments when flexing. Nil means to keep comments |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1814 as part of the token stream.") |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1815 (make-variable-buffer-local 'semantic-ignore-comments) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1816 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1817 (defvar semantic-flex-enable-newlines nil |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1818 "When flexing, report 'newlines as syntactic elements. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1819 Useful for languages where the newline is a special case terminator. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1820 Only set this on a per mode basis, not globally.") |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1821 (make-variable-buffer-local 'semantic-flex-enable-newlines) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1822 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1823 (defvar semantic-flex-enable-whitespace nil |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1824 "When flexing, report 'whitespace as syntactic elements. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1825 Useful for languages where the syntax is whitespace dependent. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1826 Only set this on a per mode basis, not globally.") |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1827 (make-variable-buffer-local 'semantic-flex-enable-whitespace) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1828 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1829 (defvar semantic-flex-enable-bol nil |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1830 "When flexing, report beginning of lines as syntactic elements. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1831 Useful for languages like python which are indentation sensitive. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1832 Only set this on a per mode basis, not globally.") |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1833 (make-variable-buffer-local 'semantic-flex-enable-bol) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1834 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1835 (defvar semantic-number-expression semantic-lex-number-expression |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1836 "See variable `semantic-lex-number-expression'.") |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1837 (make-variable-buffer-local 'semantic-number-expression) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1838 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1839 (defvar semantic-flex-depth 0 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1840 "Default flexing depth. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1841 This specifies how many lists to create tokens in.") |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1842 (make-variable-buffer-local 'semantic-flex-depth) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1843 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1844 (defun semantic-flex (start end &optional depth length) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1845 "Using the syntax table, do something roughly equivalent to flex. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1846 Semantically check between START and END. Optional argument DEPTH |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1847 indicates at what level to scan over entire lists. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1848 The return value is a token stream. Each element is a list, such of |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1849 the form (symbol start-expression . end-expression) where SYMBOL |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1850 denotes the token type. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1851 See `semantic-flex-tokens' variable for details on token types. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1852 END does not mark the end of the text scanned, only the end of the |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1853 beginning of text scanned. Thus, if a string extends past END, the |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1854 end of the return token will be larger than END. To truly restrict |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1855 scanning, use `narrow-to-region'. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1856 The last argument, LENGTH specifies that `semantic-flex' should only |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1857 return LENGTH tokens." |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1858 (message "`semantic-flex' is an obsolete function. Use `define-lex' to create lexers.") |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1859 (if (not semantic-flex-keywords-obarray) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1860 (setq semantic-flex-keywords-obarray [ nil ])) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1861 (let ((ts nil) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1862 (pos (point)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1863 (ep nil) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1864 (curdepth 0) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1865 (cs (if comment-start-skip |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1866 (concat "\\(\\s<\\|" comment-start-skip "\\)") |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1867 (concat "\\(\\s<\\)"))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1868 (newsyntax (copy-syntax-table (syntax-table))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1869 (mods semantic-flex-syntax-modifications) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1870 ;; Use the default depth if it is not specified. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1871 (depth (or depth semantic-flex-depth))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1872 ;; Update the syntax table |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1873 (while mods |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1874 (modify-syntax-entry (car (car mods)) (car (cdr (car mods))) newsyntax) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1875 (setq mods (cdr mods))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1876 (with-syntax-table newsyntax |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1877 (goto-char start) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1878 (while (and (< (point) end) (or (not length) (<= (length ts) length))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1879 (cond |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1880 ;; catch beginning of lines when needed. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1881 ;; Must be done before catching any other tokens! |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1882 ((and semantic-flex-enable-bol |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1883 (bolp) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1884 ;; Just insert a (bol N . N) token in the token stream, |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1885 ;; without moving the point. N is the point at the |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1886 ;; beginning of line. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1887 (setq ts (cons (cons 'bol (cons (point) (point))) ts)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1888 nil)) ;; CONTINUE |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1889 ;; special extensions, includes whitespace, nl, etc. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1890 ((and semantic-flex-extensions |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1891 (let ((fe semantic-flex-extensions) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1892 (r nil)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1893 (while fe |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1894 (if (looking-at (car (car fe))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1895 (setq ts (cons (funcall (cdr (car fe))) ts) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1896 r t |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1897 fe nil |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1898 ep (point))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1899 (setq fe (cdr fe))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1900 (if (and r (not (car ts))) (setq ts (cdr ts))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1901 r))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1902 ;; catch newlines when needed |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1903 ((looking-at "\\s-*\\(\n\\|\\s>\\)") |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1904 (if semantic-flex-enable-newlines |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1905 (setq ep (match-end 1) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1906 ts (cons (cons 'newline |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1907 (cons (match-beginning 1) ep)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1908 ts)))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1909 ;; catch whitespace when needed |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1910 ((looking-at "\\s-+") |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1911 (if semantic-flex-enable-whitespace |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1912 ;; Language wants whitespaces, link them together. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1913 (if (eq (car (car ts)) 'whitespace) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1914 (setcdr (cdr (car ts)) (match-end 0)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1915 (setq ts (cons (cons 'whitespace |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1916 (cons (match-beginning 0) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1917 (match-end 0))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1918 ts))))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1919 ;; numbers |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1920 ((and semantic-number-expression |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1921 (looking-at semantic-number-expression)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1922 (setq ts (cons (cons 'number |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1923 (cons (match-beginning 0) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1924 (match-end 0))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1925 ts))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1926 ;; symbols |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1927 ((looking-at "\\(\\sw\\|\\s_\\)+") |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1928 (setq ts (cons (cons |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1929 ;; Get info on if this is a keyword or not |
104446
df08b7ab0ba0
lisp/cedet/semantic/analyze.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents:
104419
diff
changeset
|
1930 (or (semantic-lex-keyword-p (match-string 0)) |
104413
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1931 'symbol) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1932 (cons (match-beginning 0) (match-end 0))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1933 ts))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1934 ;; Character quoting characters (ie, \n as newline) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1935 ((looking-at "\\s\\+") |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1936 (setq ts (cons (cons 'charquote |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1937 (cons (match-beginning 0) (match-end 0))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1938 ts))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1939 ;; Open parens, or semantic-lists. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1940 ((looking-at "\\s(") |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1941 (if (or (not depth) (< curdepth depth)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1942 (progn |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1943 (setq curdepth (1+ curdepth)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1944 (setq ts (cons (cons 'open-paren |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1945 (cons (match-beginning 0) (match-end 0))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1946 ts))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1947 (setq ts (cons |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1948 (cons 'semantic-list |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1949 (cons (match-beginning 0) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1950 (save-excursion |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1951 (condition-case nil |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1952 (forward-list 1) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1953 ;; This case makes flex robust |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1954 ;; to broken lists. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1955 (error |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1956 (goto-char |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1957 (funcall |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1958 semantic-flex-unterminated-syntax-end-function |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1959 'semantic-list |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1960 start end)))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1961 (setq ep (point))))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1962 ts)))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1963 ;; Close parens |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1964 ((looking-at "\\s)") |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1965 (setq ts (cons (cons 'close-paren |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1966 (cons (match-beginning 0) (match-end 0))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1967 ts)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1968 (setq curdepth (1- curdepth))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1969 ;; String initiators |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1970 ((looking-at "\\s\"") |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1971 ;; Zing to the end of this string. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1972 (setq ts (cons (cons 'string |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1973 (cons (match-beginning 0) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1974 (save-excursion |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1975 (condition-case nil |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1976 (forward-sexp 1) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1977 ;; This case makes flex |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1978 ;; robust to broken strings. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1979 (error |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1980 (goto-char |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1981 (funcall |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1982 semantic-flex-unterminated-syntax-end-function |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1983 'string |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1984 start end)))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1985 (setq ep (point))))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1986 ts))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1987 ;; comments |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1988 ((looking-at cs) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1989 (if (and semantic-ignore-comments |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1990 (not semantic-flex-enable-whitespace)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1991 ;; If the language doesn't deal with comments nor |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1992 ;; whitespaces, ignore them here. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1993 (let ((comment-start-point (point))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1994 (forward-comment 1) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1995 (if (eq (point) comment-start-point) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1996 ;; In this case our start-skip string failed |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1997 ;; to work properly. Lets try and move over |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1998 ;; whatever white space we matched to begin |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1999 ;; with. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2000 (skip-syntax-forward "-.'" |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2001 (save-excursion |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2002 (end-of-line) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2003 (point))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2004 ;;(forward-comment 1) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2005 ;; Generate newline token if enabled |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2006 (if (and semantic-flex-enable-newlines |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2007 (bolp)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2008 (backward-char 1))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2009 (if (eq (point) comment-start-point) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2010 (error "Strange comment syntax prevents lexical analysis")) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2011 (setq ep (point))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2012 (let ((tk (if semantic-ignore-comments 'whitespace 'comment))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2013 (save-excursion |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2014 (forward-comment 1) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2015 ;; Generate newline token if enabled |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2016 (if (and semantic-flex-enable-newlines |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2017 (bolp)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2018 (backward-char 1)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2019 (setq ep (point))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2020 ;; Language wants comments or want them as whitespaces, |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2021 ;; link them together. |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2022 (if (eq (car (car ts)) tk) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2023 (setcdr (cdr (car ts)) ep) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2024 (setq ts (cons (cons tk (cons (match-beginning 0) ep)) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2025 ts)))))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2026 ;; punctuation |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2027 ((looking-at "\\(\\s.\\|\\s$\\|\\s'\\)") |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2028 (setq ts (cons (cons 'punctuation |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2029 (cons (match-beginning 0) (match-end 0))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2030 ts))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2031 ;; unknown token |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2032 (t |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2033 (error "What is that?"))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2034 (goto-char (or ep (match-end 0))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2035 (setq ep nil))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2036 ;; maybe catch the last beginning of line when needed |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2037 (and semantic-flex-enable-bol |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2038 (= (point) end) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2039 (bolp) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2040 (setq ts (cons (cons 'bol (cons (point) (point))) ts))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2041 (goto-char pos) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2042 ;;(message "Flexing muscles...done") |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2043 (nreverse ts))) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2044 |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2045 (provide 'semantic/lex) |
6524f06f3a75
cedet/semantic/lex.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2046 |
104446
df08b7ab0ba0
lisp/cedet/semantic/analyze.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents:
104419
diff
changeset
|
2047 ;; Local variables: |
df08b7ab0ba0
lisp/cedet/semantic/analyze.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents:
104419
diff
changeset
|
2048 ;; generated-autoload-file: "loaddefs.el" |
104447
273e528a9f9b
* emacs-lisp/autoload.el (generated-autoload-load-name): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
104446
diff
changeset
|
2049 ;; generated-autoload-load-name: "semantic/lex" |
104446
df08b7ab0ba0
lisp/cedet/semantic/analyze.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents:
104419
diff
changeset
|
2050 ;; End: |
df08b7ab0ba0
lisp/cedet/semantic/analyze.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents:
104419
diff
changeset
|
2051 |
105377 | 2052 ;; arch-tag: a47664fc-48d9-4b36-921f-cab0ea8cdf92 |
105260
bbd7017a25d9
CEDET (development tools) package merged.
Chong Yidong <cyd@stupidchicken.com>
parents:
104513
diff
changeset
|
2053 ;;; semantic/lex.el ends here |