1 This is semantic-langdev.info, produced by makeinfo version 5.2 from
2 lang-support-guide.texi.
4 This manual documents Application Development with Semantic.
6 Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007 Eric M.
7 Ludlam Copyright (C) 2001, 2002, 2003, 2004 David Ponce Copyright (C)
8 2002, 2003 Richard Y. Kim
10 Permission is granted to copy, distribute and/or modify this
11 document under the terms of the GNU Free Documentation License,
12 Version 1.1 or any later version published by the Free Software
13 Foundation; with the Invariant Sections being list their titles,
14 with the Front-Cover Texts being list, and with the Back-Cover
15 Texts being list. A copy of the license is included in the section
16 entitled "GNU Free Documentation License".
17 INFO-DIR-SECTION Emacs
19 * Semantic Language Writer's guide: (semantic-langdev).
22 This file documents Language Support Development with Semantic.
23 _Infrastructure for parser based text analysis in Emacs_
25 Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004 Eric M. Ludlam,
26 David Ponce, and Richard Y. Kim
29 File: semantic-langdev.info, Node: Top, Next: Tag Structure, Up: (dir)
31 Language Support Developer's Guide
32 **********************************
34 Semantic is bundled with support for several languages such as C, C++,
35 Java, Python, etc. However one of the primary gols of semantic is to
36 provide a framework in which anyone can add support for other languages
37 easily. In order to support a new lanaugage, one typically has to
38 provide a lexer and a parser along with appropriate semantic actions
39 that produce the end result of the parser - the semantic tags.
41 This chapter first discusses the semantic tag data structure to
42 familiarize the reader to the goal. Then all the components necessary
43 for supporting a lanaugage is discussed starting with the writing lexer,
44 writing the parser, writing semantic rules, etc. Finally several
45 parsers bundled with semantic are discussed as case studies.
50 * Language Support Overview::
53 * Parsing a language file::
55 * Parser Error Handling::
56 * GNU Free Documentation License::
60 File: semantic-langdev.info, Node: Tag Structure, Next: Language Support Overview, Prev: Top, Up: Top
65 The end result of the parser for a buffer is a list of tags. Currently
66 each tag is a list with up to five elements:
67 ("NAME" CLASS ATTRIBUTES PROPERTIES OVERLAY)
69 CLASS represents what kind of tag this is. Common CLASS values include
70 'variable', 'function', or 'type'. *note (semantic-appdev.info)Tag
73 ATTRIBUTES is a slot filled with langauge specific options for the tag.
74 Function arguments, return type, and other flags all are stored in
75 attributes. A language author fills in the ATTRIBUTES with the tag
76 constructor, which is parser style dependant.
78 PROPERTIES is a slot generated by the semantic parser harness, and need
79 not be provided by a language author. Programmatically access tag
80 properties with 'semantic--tag-put-property',
81 'semantic--tag-put-property-no-side-effect' and
82 'semantic--tag-get-property'.
84 OVERLAY represents positional information for this tag. It is
85 automatically generated by the semantic parser harness, and need not be
86 provided by the language author, unless they provide a tag expansion
87 function via 'semantic-tag-expand-function'.
89 The OVERLAY property is accessed via several functions returning the
90 beginning, end, and buffer of a token. Use these functions unless the
91 overlay is really needed (see *note (app-dev-guide)Tag Query::).
92 Depending on the overlay in a program can be dangerous because sometimes
93 the overlay is replaced with an integer pair
95 when the buffer the tag belongs to is not in memory. This happens when
96 a user has activated the Semantic Database *note
97 (semantic-appdev)semanticdb::.
99 To create tags for a functional or object oriented language, you can use
100 s series of tag creation functions. *note (semantic-appdev)Creating
104 File: semantic-langdev.info, Node: Language Support Overview, Next: Writing Lexers, Prev: Tag Structure, Up: Top
106 2 Language Support Overview
107 ***************************
109 Starting with version 2.0, semantic provides many ways to add support
110 for a language into the semantic framework.
112 The primary means to customize how semantic works is to implement
113 language specific versions of overloadable functions. Semantic has a
114 specialized mode bound way to do this. *note Semantic Overload
117 The parser has several parts which are all also overloadable. The
118 primary entry point into the parser is 'semantic-fetch-tags' which calls
119 'semantic-parse-region' which returns a list of semantic tags which get
120 set to 'semantic--buffer-cache'.
122 'semantic-parse-region' is the first "overloadable" function. The
123 default behavior of this is to simply call 'semantic-lex', then pass the
124 lexical token list to 'semantic-repeat-parse-whole-stream'. At each
125 stage, another more focused layer provides a means of overloading.
127 The parser is not the only layer that provides overloadable methods.
128 Application APIs *note (semantic-appdev)top:: provide many overload
133 * Semantic Overload Mechanism::
134 * Semantic Parser Structure::
135 * Application API Structure::
138 File: semantic-langdev.info, Node: Semantic Overload Mechanism, Next: Semantic Parser Structure, Prev: Language Support Overview, Up: Language Support Overview
140 2.1 Semantic Overload Mechanism
141 ===============================
143 one of semantic's goals is to provide a framework for supporting a wide
144 range of languages. writing parsers for some languages are very simple,
145 e.g., any dialect of lisp family such as emacs-lisp and scheme. parsers
146 for many languages can be written in context free grammars such as c,
147 java, python, etc. on the other hand, it is impossible to specify
148 context free grammars for other languages such as texinfo. Yet semantic
149 already provides parsers for all these languages.
151 In order to support such wide range of languages, a mechanism for
152 customizing the parser engine at many levels was needed to maximize the
153 code reuse yet give each programmer the flexibility of customizing the
154 parser engine at many levels of granularity. The solution that semantic
155 provides is the function overloading mechanism which allows one to
156 intercept and customize the behavior of many of the functions in the
157 parser engine. First the parser engine breaks down the task of parsing
158 a language into several steps. Each step is represented by an
159 Emacs-Lisp function. Some of these are 'semantic-parse-region',
160 'semantic-lex', 'semantic-parse-stream', 'semantic-parse-changes', etc.
162 Many built-in semantic functions are declared as being over-loadable
163 functions, i.e., functions that do reasonable things for most languages,
164 but can be customized to suit the particular needs of a given language.
165 All over-loadable functions then can easily be over-ridden if necessary.
166 The rest of this section provides details on this overloading mechanism.
168 Over-loadable functions are created by defining functions with the
169 'define-overload' macro rather than the usual 'defun'.
170 'define-overload' is a thin wrapper around 'defun' that sets up the
171 function so that it can be overloaded. An over-loadable function then
172 can be over-ridden in one of two ways:
173 'define-mode-overload-implementation' and
174 'semantic-install-function-overrides'.
176 Let's look at a couple of examples. 'semantic-parse-region' is one of
177 the top level functions in the parser engine defined via
180 (define-overload semantic-parse-region
181 (start end &optional nonterminal depth returnonerror)
182 "Parse the area between START and END, and return any tokens found.
188 The document string was truncated in the middle above since it is not
189 relevant here. The macro invocation above defines the
190 'semantic-parse-region' Emacs-Lisp function that checks first if there
191 is an overloaded implementation. If one is found, then that is called.
192 If a mode specific implementation is not found, then the default
193 implementation is called which in this case is to call
194 'semantic-parse-region-default', i.e., a function with the same name but
195 with the tailing -default. That function needs to be written separately
196 and take the same arguments as the entry created with 'define-overload'.
198 One way to overload 'semantic-parse-region' is via
199 'semantic-install-function-overrides'. An example from
200 'semantic-texi.el' file is shown below:
202 (defun semantic-default-texi-setup ()
203 "Set up a buffer for parsing of Texinfo files."
204 ;; This will use our parser.
205 (semantic-install-function-overrides
206 '((parse-region . semantic-texi-parse-region)
207 (parse-changes . semantic-texi-parse-changes)))
211 (add-hook 'texinfo-mode-hook 'semantic-default-texi-setup)
213 Above function is called whenever a buffer is setup as texinfo mode.
214 'semantic-install-function-overrides' above indicates that
215 'semantic-texi-parse-region' is to over-ride the default implementation
216 of 'semantic-parse-region'. Note the use of 'parse-region' symbol which
217 is 'semantic-parse-region' without the leading semantic- prefix.
219 Another way to over-ride a built-in semantic function is via
220 'define-mode-overload-implementation'. An example from
221 'wisent-python.el' file is shown below.
223 (define-mode-overload-implementation
224 semantic-parse-region python-mode
225 (start end &optional nonterminal depth returnonerror)
226 "Over-ride in order to initialize some variables."
227 (let ((wisent-python-lexer-indent-stack '(0))
228 (wisent-python-explicit-line-continuation nil))
229 (semantic-parse-region-default
230 start end nonterminal depth returnonerror)))
232 Above over-rides 'semantic-parse-region' so that for buffers whose major
233 mode is 'python-mode', the code specified above is executed rather than
234 the default implementation.
236 2.1.1 Why not to use advice
237 ---------------------------
239 One may wonder why semantic defines an overload mechanism when Emacs
240 already has advice. *Note (elisp)Advising Functions::.
242 Advising is generally considered a mechanism of last resort when
243 modifying or hooking into an existing package without modifying that
244 sourse file. Overload files advertise that they should be overloaded,
245 and define syntactic sugar to do so.
248 File: semantic-langdev.info, Node: Semantic Parser Structure, Next: Application API Structure, Prev: Semantic Overload Mechanism, Up: Language Support Overview
250 2.2 Semantic Parser Structure
251 =============================
253 NOTE: describe the functions that do parsing, and how to overload each.
260 File: semantic-langdev.info, Node: Application API Structure, Prev: Semantic Parser Structure, Up: Language Support Overview
262 2.3 Application API Structure
263 =============================
267 How to program with the Application programming API into the data
268 structures created by semantic are in the Application development guide.
269 Read that guide to get a feel for the specifics of what you can
270 customize. *note (semantic-appdev)top::
272 Here are a list of applications, and the specific APIs that you will
273 need to overload to make them work properly with your language.
278 These tools requires that the 'semantic-format' methods create
279 correct strings. *note (semantic-addpev)Format Tag::
281 The analysis tool requires that the 'semanticdb' tool is active,
282 and that the searching methods are overloaded. In addition,
283 'semanticdb' system database could be written to provide symbols
284 from the global environment of your langauge. *note
285 (semantic-appdev)System Databases::
287 In addition, the analyzer requires that the 'semantic-ctxt' methods
288 are overloaded. These methods allow the analyzer to look at the
289 context of the cursor in your language, and predict the type of
290 location of the cursor. *note (semantic-appdev)Derived Context::.
291 'semantic-idle-summary-mode'
292 'semantic-idle-completions-mode'
293 These tools use the semantic analysis tool. *note Context
294 Analysis. . semantic-appdev::
298 * Semantic Analyzer Support::
301 File: semantic-langdev.info, Node: Semantic Analyzer Support, Prev: Application API Structure, Up: Application API Structure
303 2.3.1 Semantic Analyzer Support
304 -------------------------------
307 File: semantic-langdev.info, Node: Writing Lexers, Next: Writing Parsers, Prev: Language Support Overview, Up: Top
312 In order to reduce a source file into a tag table, it must first be
313 converted into a token stream. Tokens are syntactic elements such as
314 whitespace, symbols, strings, lists, and punctuation.
316 The lexer uses the major-mode's syntax table for conversion. *Note
317 (elisp)Syntax Tables::. As long as that is set up correctly (along with
318 the important 'comment-start' and 'comment-start-skip' variable) the
319 lexer should already work for your language.
321 The primary entry point of the lexer is the "semantic-lex" function
322 shown below. Normally, you do not need to call this function. It is
323 usually called by _semantic-fetch-tags_ for you.
325 -- Function: semantic-lex start end &optional depth length
326 Lexically analyze text in the current buffer between START and END.
327 Optional argument DEPTH indicates at what level to scan over entire
328 lists. The last argument, LENGTH specifies that "semantic-lex"
329 should only return LENGTH tokens. The return value is a token
330 stream. Each element is a list, such of the form (symbol
331 start-expression . end-expression) where SYMBOL denotes the token
332 type. See 'semantic-lex-tokens' variable for details on token
333 types. END does not mark the end of the text scanned, only the end
334 of the beginning of text scanned. Thus, if a string extends past
335 END, the end of the return token will be larger than END. To truly
336 restrict scanning, use "narrow-to-region".
340 * Lexer Overview:: What is a Lexer?
341 * Lexer Output:: Output of a Lexical Analyzer
342 * Lexer Construction:: Constructing your own lexer
343 * Lexer Built In Analyzers:: Built in analyzers you can use
344 * Lexer Analyzer Construction:: Constructing your own anlyzers
345 * Keywords:: Specialized lexical tokens.
346 * Keyword Properties::
349 File: semantic-langdev.info, Node: Lexer Overview, Next: Lexer Output, Prev: Writing Lexers, Up: Writing Lexers
354 semantic lexer breaks up the content of an Emacs buffer into a stream of
355 tokens. This process is based mostly on regular expressions which in
356 turn depend on the syntax table of the buffer's major mode being setup
357 properly. *Note (emacs)Major Modes::. *Note (elisp)Syntax Tables::.
358 *Note (emacs)Regexps::.
360 The top level lexical function "semantic-lex", calls the function stored
361 in "semantic-lex-analyzer". The default value is the function
362 "semantic-flex" from version 1.4 of Semantic. This will eventually be
365 In the default lexer, the following regular expressions which rely on
366 syntax tables are used:
369 whitespace characters
375 punctuation character
383 close parenthesis character
391 In addition, Emacs' built-in features such as 'comment-start-skip',
392 'forward-comment', 'forward-list', and 'forward-sexp' are employed.
395 File: semantic-langdev.info, Node: Lexer Output, Next: Lexer Construction, Prev: Lexer Overview, Up: Writing Lexers
400 The lexer, *note semantic-lex::, scans the content of a buffer and
401 returns a token list. Let's illustrate this using this simple example.
404 01: * Simple program to demonstrate semantic.
407 04: #include <stdio.h>
412 09: main(int argc, char** argv)
414 11: printf("Hello world.\n");
417 Evaluating '(semantic-lex (point-min) (point-max))' within the buffer
418 with the code above returns the following token list. The input line
419 and string that produced each token is shown after each semi-colon.
421 ((punctuation 52 . 53) ; 04: #
422 (INCLUDE 53 . 60) ; 04: include
423 (punctuation 61 . 62) ; 04: <
424 (symbol 62 . 67) ; 04: stdio
425 (punctuation 67 . 68) ; 04: .
426 (symbol 68 . 69) ; 04: h
427 (punctuation 69 . 70) ; 04: >
428 (INT 72 . 75) ; 06: int
429 (symbol 76 . 79) ; 06: i_1
430 (punctuation 79 . 80) ; 06: ;
431 (INT 82 . 85) ; 08: int
432 (symbol 86 . 90) ; 08: main
433 (semantic-list 90 . 113) ; 08: (int argc, char** argv)
434 (semantic-list 114 . 147) ; 09-12: body of main function
437 As shown above, the token list is a list of "tokens". Each token in
438 turn is a list of the form
440 (TOKEN-TYPE BEGINNING-POSITION . ENDING-POSITION)
442 where TOKEN-TYPE is a symbol, and the other two are integers indicating
443 the buffer position that delimit the token such that
445 (buffer-substring BEGINNING-POSITION ENDING-POSITION)
447 would return the string form of the token.
449 Note that one line (line 4 above) can produce seven tokens while the
450 whole body of the function produces a single token. This is because the
451 DEPTH parameter of 'semantic-lex' was not specified. Let's see the
452 output when DEPTH is set to 1. Evaluate '(semantic-lex (point-min)
453 (point-max) 1)' in the same buffer. Note the third argument of '1'.
455 ((punctuation 52 . 53) ; 04: #
456 (INCLUDE 53 . 60) ; 04: include
457 (punctuation 61 . 62) ; 04: <
458 (symbol 62 . 67) ; 04: stdio
459 (punctuation 67 . 68) ; 04: .
460 (symbol 68 . 69) ; 04: h
461 (punctuation 69 . 70) ; 04: >
462 (INT 72 . 75) ; 06: int
463 (symbol 76 . 79) ; 06: i_1
464 (punctuation 79 . 80) ; 06: ;
465 (INT 82 . 85) ; 08: int
466 (symbol 86 . 90) ; 08: main
468 (open-paren 90 . 91) ; 08: (
469 (INT 91 . 94) ; 08: int
470 (symbol 95 . 99) ; 08: argc
471 (punctuation 99 . 100) ; 08: ,
472 (CHAR 101 . 105) ; 08: char
473 (punctuation 105 . 106) ; 08: *
474 (punctuation 106 . 107) ; 08: *
475 (symbol 108 . 112) ; 08: argv
476 (close-paren 112 . 113) ; 08: )
478 (open-paren 114 . 115) ; 10: {
479 (symbol 120 . 126) ; 11: printf
480 (semantic-list 126 . 144) ; 11: ("Hello world.\n")
481 (punctuation 144 . 145) ; 11: ;
482 (close-paren 146 . 147) ; 12: }
485 The DEPTH parameter "peeled away" one more level of "list" delimited by
486 matching parenthesis or braces. The depth parameter can be specified to
487 be any number. However, the parser needs to be able to handle the extra
490 This is an interesting benefit of the lexer having the full resources of
491 Emacs at its disposal. Skipping over matched parenthesis is achieved by
492 simply calling the built-in functions 'forward-list' and 'forward-sexp'.
495 File: semantic-langdev.info, Node: Lexer Construction, Next: Lexer Built In Analyzers, Prev: Lexer Output, Up: Writing Lexers
497 3.3 Lexer Construction
498 ======================
500 While using the default lexer is certainly an option, particularly for
501 grammars written in semantic 1.4 style, it is usually more efficient to
502 create a custom lexer for your language.
504 You can create a new lexer with "define-lex".
506 -- Function: define-lex name doc &rest analyzers
507 Create a new lexical analyzer with NAME. DOC is a documentation
508 string describing this analyzer. ANALYZERS are small code snippets
509 of analyzers to use when building the new NAMED analyzer. Only use
510 analyzers which are written to be used in "define-lex". Each
511 analyzer should be an analyzer created with "define-lex-analyzer".
512 Note: The order in which analyzers are listed is important. If two
513 analyzers can match the same text, it is important to order the
514 analyzers so that the one you want to match first occurs first.
515 For example, it is good to put a numbe analyzer in front of a
516 symbol analyzer which might mistake a number for as a symbol.
518 The list of ANALYZERS, needed here can consist of one of several built
519 in analyzers, or one of your own construction. The built in analyzers
523 File: semantic-langdev.info, Node: Lexer Built In Analyzers, Next: Lexer Analyzer Construction, Prev: Lexer Construction, Up: Writing Lexers
525 3.4 Lexer Built In Analyzers
526 ============================
528 -- Special Form: semantic-lex-default-action
529 The default action when no other lexical actions match text. This
530 action will just throw an error.
532 -- Special Form: semantic-lex-beginning-of-line
533 Detect and create a beginning of line token (BOL).
535 -- Special Form: semantic-lex-newline
536 Detect and create newline tokens.
538 -- Special Form: semantic-lex-newline-as-whitespace
539 Detect and create newline tokens. Use this ONLY if newlines are
540 not whitespace characters (such as when they are comment end
541 characters) AND when you want whitespace tokens.
543 -- Special Form: semantic-lex-ignore-newline
544 Detect and create newline tokens. Use this ONLY if newlines are
545 not whitespace characters (such as when they are comment end
548 -- Special Form: semantic-lex-whitespace
549 Detect and create whitespace tokens.
551 -- Special Form: semantic-lex-ignore-whitespace
552 Detect and skip over whitespace tokens.
554 -- Special Form: semantic-lex-number
555 Detect and create number tokens. Number tokens are matched via
558 -- Variable: semantic-lex-number-expression
559 Regular expression for matching a number. If this value is
560 'nil', no number extraction is done during lex. This
561 expression tries to match C and Java like numbers.
573 <DECIMAL_LITERAL>[lL]?
575 | <OCTAL_LITERAL>[lL]?
580 FLOATING_POINT_LITERAL:
581 [0-9]+[.][0-9]*<EXPONENT>?[fFdD]?
582 | [.][0-9]+<EXPONENT>?[fFdD]?
583 | [0-9]+<EXPONENT>[fFdD]?
584 | [0-9]+<EXPONENT>?[fFdD]
587 -- Special Form: semantic-lex-symbol-or-keyword
588 Detect and create symbol and keyword tokens.
590 -- Special Form: semantic-lex-charquote
591 Detect and create charquote tokens.
593 -- Special Form: semantic-lex-punctuation
594 Detect and create punctuation tokens.
596 -- Special Form: semantic-lex-punctuation-type
597 Detect and create a punctuation type token. Recognized
598 punctuations are defined in the current table of lexical types, as
599 the value of the 'punctuation' token type.
601 -- Special Form: semantic-lex-paren-or-list
602 Detect open parenthesis. Return either a paren token or a semantic
603 list token depending on 'semantic-lex-current-depth'.
605 -- Special Form: semantic-lex-open-paren
606 Detect and create an open parenthisis token.
608 -- Special Form: semantic-lex-close-paren
609 Detect and create a close paren token.
611 -- Special Form: semantic-lex-string
612 Detect and create a string token.
614 -- Special Form: semantic-lex-comments
615 Detect and create a comment token.
617 -- Special Form: semantic-lex-comments-as-whitespace
618 Detect comments and create a whitespace token.
620 -- Special Form: semantic-lex-ignore-comments
621 Detect and create a comment token.
624 File: semantic-langdev.info, Node: Lexer Analyzer Construction, Next: Keywords, Prev: Lexer Built In Analyzers, Up: Writing Lexers
626 3.5 Lexer Analyzer Construction
627 ===============================
629 Each of the previous built in analyzers are constructed using a set of
630 analyzer construction macros. The root construction macro is:
632 -- Function: define-lex-analyzer name doc condition &rest forms
633 Create a single lexical analyzer NAME with DOC. When an analyzer
634 is called, the current buffer and point are positioned in a buffer
635 at the location to be analyzed. CONDITION is an expression which
636 returns 't' if FORMS should be run. Within the bounds of CONDITION
637 and FORMS, the use of backquote can be used to evaluate expressions
638 at compile time. While forms are running, the following variables
639 will be locally bound: 'semantic-lex-analysis-bounds' - The bounds
640 of the current analysis. of the form (START . END)
641 'semantic-lex-maximum-depth' - The maximum depth of semantic-list
642 for the current analysis. 'semantic-lex-current-depth' - The
643 current depth of 'semantic-list' that has been decended.
644 'semantic-lex-end-point' - End Point after match. Analyzers should
645 set this to a buffer location if their match string does not
646 represent the end of the matched text. 'semantic-lex-token-stream'
647 - The token list being collected. Add new lexical tokens to this
648 list. Proper action in FORMS is to move the value of
649 'semantic-lex-end-point' to after the location of the analyzed
650 entry, and to add any discovered tokens at the beginning of
651 'semantic-lex-token-stream'. This can be done by using
652 "semantic-lex-push-token".
654 Additionally, a simple regular expression based analyzer can be built
657 -- Function: define-lex-regex-analyzer name doc regexp &rest forms
658 Create a lexical analyzer with NAME and DOC that will match REGEXP.
659 FORMS are evaluated upon a successful match. See
660 "define-lex-analyzer" for more about analyzers.
662 -- Function: define-lex-simple-regex-analyzer name doc regexp toksym
663 &optional index &rest forms
664 Create a lexical analyzer with NAME and DOC that match REGEXP.
665 TOKSYM is the symbol to use when creating a semantic lexical token.
666 INDEX is the index into the match that defines the bounds of the
667 token. Index should be a plain integer, and not specified in the
668 macro as an expression. FORMS are evaluated upon a successful
669 match BEFORE the new token is created. It is valid to ignore
670 FORMS. See "define-lex-analyzer" for more about analyzers.
672 Regular expression analyzers are the simplest to create and manage.
673 Often, a majority of your lexer can be built this way. The analyzer for
674 matching punctuation looks like this:
676 (define-lex-simple-regex-analyzer semantic-lex-punctuation
677 "Detect and create punctuation tokens."
678 "\\(\\s.\\|\\s$\\|\\s'\\)" 'punctuation)
680 More complex analyzers for matching larger units of text to optimize the
681 speed of parsing and analysis is done by matching blocks.
683 -- Function: define-lex-block-analyzer name doc spec1 &rest specs
684 Create a lexical analyzer NAME for paired delimiters blocks. It
685 detects a paired delimiters block or the corresponding open or
686 close delimiter depending on the value of the variable
687 'semantic-lex-current-depth'. DOC is the documentation string of
688 the lexical analyzer. SPEC1 and SPECS specify the token symbols
689 and open, close delimiters used. Each SPEC has the form:
691 (BLOCK-SYM (OPEN-DELIM OPEN-SYM) (CLOSE-DELIM CLOSE-SYM))
693 where BLOCK-SYM is the symbol returned in a block token.
694 OPEN-DELIM and CLOSE-DELIM are respectively the open and close
695 delimiters identifying a block. OPEN-SYM and CLOSE-SYM are
696 respectively the symbols returned in open and close tokens.
698 These blocks is what makes the speed of semantic's Emacs Lisp based
699 parsers fast. For exmaple, by defining all text inside { braces } as a
700 block the parser does not need to know the contents of those braces
701 while parsing, and can skip them all together.
704 File: semantic-langdev.info, Node: Keywords, Next: Keyword Properties, Prev: Lexer Analyzer Construction, Up: Writing Lexers
709 Another important piece of the lexer is the keyword table (see *note
710 Writing Parsers::). You language will want to set up a keyword table
711 for fast conversion of symbol strings to language terminals.
713 The keywords table can also be used to store additional information
714 about those keywords. The following programming functions can be useful
715 when examining text in a language buffer.
717 -- Function: semantic-lex-keyword-p name
718 Return non-'nil' if a keyword with NAME exists in the keyword
719 table. Return 'nil' otherwise.
721 -- Function: semantic-lex-keyword-put name property value
722 For keyword with NAME, set its PROPERTY to VALUE.
724 -- Function: semantic-lex-keyword-get name property
725 For keyword with NAME, return its PROPERTY value.
727 -- Function: semantic-lex-map-keywords fun &optional property
728 Call function FUN on every semantic keyword. If optional PROPERTY
729 is non-'nil', call FUN only on every keyword which as a PROPERTY
730 value. FUN receives a semantic keyword as argument.
732 -- Function: semantic-lex-keywords &optional property
733 Return a list of semantic keywords. If optional PROPERTY is
734 non-'nil', return only keywords which have a PROPERTY set.
736 Keyword properties can be set up in a grammar file for ease of
737 maintenance. While examining the text in a language buffer, this can
738 provide an easy and quick way of storing details about text in the
742 File: semantic-langdev.info, Node: Keyword Properties, Prev: Keywords, Up: Writing Lexers
744 3.7 Standard Keyword Properties
745 ===============================
747 Keywords in a language can have multiple properties. These properties
748 can be used to associate the string that is the keyword with additional
751 Currently available properties are:
754 The summary property is used by semantic-summary-mode as a help
755 string for the keyword specified.
759 Possible future properties. This is just me musing:
762 Face used for highlighting this keyword, differentiating it from
766 Some sort of tempo/skel template for inserting the programatic
767 structure associated with this keyword.
772 Perhaps the keyword is clickable and some action would be useful.
775 File: semantic-langdev.info, Node: Writing Parsers, Next: Parsing a language file, Prev: Writing Lexers, Up: Top
780 When converting a source file into a tag table it is important to
781 specify rules to accomplish this. The rules are stored in the buffer
782 local variable 'semantic--buffer-cache'.
784 While it is certainly possible to write this table yourself, it is most
785 likely you will want to use the *note Grammar Programming Environment::.
787 There are three choices for parsing your language.
790 The "bovine" parser is the original semantic parser, and is an
791 implementation of an LL parser. For more information, *note the
792 Bovine Parser Manual: (bovine)top.
795 The "wisent" parser is a port of the GNU Compiler Compiler Bison to
796 Emacs Lisp. Wisent includes the iterative error handler of the
797 bovine parser, and has the same error correction as traditional
798 LALR parsers. For more information, *note the Wisent Parser
802 External parsers, such as the texinfo parser can be implemented
803 using any means. This allows the use of a regular expression
804 parser for non-regular languages, or external programs for speed.
808 * External Parsers:: Writing an external parser
809 * Grammar Programming Environment:: Using the grammar writing environemt
810 * Parser Backend Support:: Lisp needed to support a grammar.
813 File: semantic-langdev.info, Node: External Parsers, Next: Grammar Programming Environment, Prev: Writing Parsers, Up: Writing Parsers
818 The texinfo parser in 'semantic-texi.el' is an example of an external
819 parser. To make your parser work, you need to have a setup function.
824 File: semantic-langdev.info, Node: Grammar Programming Environment, Next: Parser Backend Support, Prev: External Parsers, Up: Writing Parsers
826 4.2 Grammar Programming Environment
827 ===================================
829 Semantic grammar files in '.by' or '.wy' format have their own
830 programming mode. This mode provides indentation and coloring services
831 in those languages. In addition, the grammar languages are also
832 supported by semantic so tagging information is available to tools such
833 as imenu or speedbar.
835 For more information, *note the Grammar Framework Manual:
839 File: semantic-langdev.info, Node: Parsing a language file, Next: Debugging, Prev: Writing Parsers, Up: Top
841 5 Parsing a language file
842 *************************
844 The best way to call the parser from programs is via
845 'semantic-fetch-tags'. This, in turn, uses other internal API functions
846 which plug-in parsers can take advantage of.
848 -- Function: semantic-fetch-tags
849 Fetch semantic tags from the current buffer. If the buffer cache
850 is up to date, return that. If the buffer cache is out of date,
851 attempt an incremental reparse. If the buffer has not been parsed
852 before, or if the incremental reparse fails, then parse the entire
853 buffer. If a lexcial error had been previously discovered and the
854 buffer was marked unparseable, then do nothing, and return the
857 Another approach is to let Emacs call the parser on idle time, when
858 needed, then use 'semantic-fetch-available-tags' to retrieve and process
859 only the available tags, provided that the 'semantic-after-*-hook' hooks
860 have been setup to synchronize with new tags when they become available.
862 -- Function: semantic-fetch-available-tags
863 Fetch available semantic tags from the current buffer. That is,
864 return tags currently in the cache without parsing the current
867 Parse operations happen asynchronously when needed on Emacs idle
868 time. Use the 'semantic-after-toplevel-cache-change-hook' and
869 'semantic-after-partial-cache-change-hook' hooks to synchronize
870 with new tags when they become available.
872 -- Command: semantic-clear-toplevel-cache
873 Clear the toplevel tag cache for the current buffer. Clearing the
874 cache will force a complete reparse next time a token stream is
878 File: semantic-langdev.info, Node: Parser Backend Support, Prev: Grammar Programming Environment, Up: Writing Parsers
880 5.1 Parser Backend Support
881 ==========================
883 Once you have written a grammar file that has been compiled into Emacs
884 Lisp code, additional glue needs to be written to finish connecting the
885 generated parser into the Emacs framework.
887 Large portions of this glue is automatically generated, but will
888 probably need additional modification to get things to work properly.
890 Typically, a grammar file 'foo.wy' will create the file 'foo-wy.el'. It
891 is then useful to also create a file 'wisent-foo.el' (or
892 'sematnic-foo.el') to contain the parser back end, or the glue that
893 completes the semantic support for the language.
897 * Example Backend File::
901 File: semantic-langdev.info, Node: Example Backend File, Next: Tag Expansion, Prev: Parser Backend Support, Up: Parser Backend Support
903 5.1.1 Example Backend File
904 --------------------------
906 Typical structure for this file is:
908 ;;; semantic-foo.el -- parser support for FOO.
910 ;;; Your copyright Notice
912 (require 'foo-wy.el) ;; The parser
913 (require 'foo) ;; major mode definition for FOO
920 ;; It is possible to define your lexical analyzer completely in your
923 (define-lex foo-lexical-analyzer
924 "Create a lexical analyzer."
930 ;; Not all langauges are so complex as to need this function.
931 ;; See `semantic-tag-expand-function' for more details.
932 (defun foo-tag-expand-function (tag)
933 "Expand TAG into multiple tags if needed."
939 ;; If you need some specialty routines inside your grammar file
940 ;; you can add some here. The process may be to take diverse info
941 ;; and reorganize it.
943 ;; It is also appropriate to write these functions in the prologue
944 ;; of the grammar function.
945 (defun foo-do-something-hard (...)
951 ;; To allow your langauge to be fully supported by all the
952 ;; applications that use semantic, it is important, but not necessary
953 ;; to create implementations of overload methods.
954 (define-mode-overload-implementation some-semantic-function foo-mode (tag)
955 "Implement some-semantic-function for FOO."
959 (defun semantic-default-foo-setup ()
960 "Set up a buffer for semantic parsing of the FOO language."
961 (semantic-foo-by--install-parser)
962 (setq semantic-tag-expand-function foo-tag-expand-function
963 ;; Many other language specific settings can be done here
966 ;; This may be optional
967 (setq semantic-lex-analyzer #'foo-lexical-analyzer)
971 (add-hook 'foo-mode-hook 'semantic-default-foo-setup)
973 (provide 'semantic-c)
975 ;;; semantic-foo.el ends here
978 File: semantic-langdev.info, Node: Tag Expansion, Prev: Example Backend File, Up: Parser Backend Support
983 In any language with compound tag types, you will need to implement an
984 _expand function_. Once written, assign it to this variable.
986 -- Variable: semantic-tag-expand-function
987 Function used to expand a tag. It is passed each tag production,
988 and must return a list of tags derived from it, or 'nil' if it does
989 not need to be expanded.
991 Languages with compound definitions should use this function to
992 expand from one compound symbol into several. For example, in C or
993 Java the following definition is easily parsed into one tag:
997 This function should take this compound tag and turn it into two
998 tags, one for A, and the other for B.
1000 Additionally, you can use the expand function in conjuntion with your
1001 language for other types of compound statements. For example, in Common
1002 Lisp Object System, you can have a definition:
1004 (defclass classname nil
1007 This will create both the datatype 'classname' and the functional
1008 constructor 'classname'. Each slot may have a ':accessor' method as
1011 You can create a special compounded tag in your rule, for example:
1013 classdef: LPAREN DEFCLASS name semantic-list semantic-list RPAREN
1014 (TAG "custom" 'compound-class
1016 (TYPE-TAG $3 "class" ...)
1017 (FUNCTION-TAG $3 ...)
1021 and in your expand function, you would write:
1023 (defun my-tag-expand (tag)
1024 "Expand tags for my langauge."
1025 (when (semantic-tag-of-class-p tag 'compound-class)
1027 (semantic-tag-get-attribute tag :value))))
1029 This will cause the custom tag to be replaced by the tags created in the
1030 :value attribute of the specially constructed tag.
1033 File: semantic-langdev.info, Node: Debugging, Next: Parser Error Handling, Prev: Parsing a language file, Up: Top
1038 Grammars can be tricky things to debug. There are several types of
1039 tools for debugging in Semantic, and the type of problem you have
1040 requires different types of tools.
1044 * Lexical Debugging::
1045 * Parser Output tools::
1046 * Bovine Parser Debugging::
1047 * Wisent Parser Debugging::
1048 * Overlay Debugging::
1049 * Incremental Parser Debugging::
1050 * Debugging Analysis::
1051 * Semantic 1.4 Doc::
1054 File: semantic-langdev.info, Node: Lexical Debugging, Next: Parser Output tools, Prev: Debugging, Up: Debugging
1056 6.1 Lexical Debugging
1057 =====================
1059 The first major problem you may encounter is with lexical analysis. If
1060 the text is not transformed into the expected token stream, no parser
1063 You can step through the lexical analyzer with the following command:
1065 -- Command: semantic-lex-debug arg
1066 Debug the semantic lexer in the current buffer. Argument ARG
1067 specifies of the analyze the whole buffer, or start at point.
1068 While engaged, each token identified by the lexer will be
1069 highlighted in the target buffer A description of the current token
1070 will be displayed in the minibuffer. Press 'SPC' to move to the
1073 For an example of what the output of the 'semantic-lex' function should
1074 return, see *note Lexer Output::.
1077 File: semantic-langdev.info, Node: Parser Output tools, Next: Bovine Parser Debugging, Prev: Lexical Debugging, Up: Debugging
1079 6.2 Parser Output tools
1080 =======================
1082 There are several tools which can be used to see what the parser output
1083 is. These will work for any type of parser, including the Bovine
1084 parser, Wisent parser.
1086 The first and easiest is a minor mode which highlights text the parser
1089 -- Command: semantic-show-unmatched-syntax-mode &optional arg
1090 Minor mode to highlight unmatched lexical syntax tokens. When a
1091 parser executes, some elements in the buffer may not match any
1092 parser rules. These text characters are considered unmatched
1093 syntax. Often time, the display of unmatched syntax can expose
1094 coding problems before the compiler is run.
1096 With prefix argument ARG, turn on if positive, otherwise off. The
1097 minor mode can be turned on only if semantic feature is available
1098 and the current buffer was set up for parsing. Return non-'nil' if
1099 the minor mode is enabled.
1106 semantic-show-unmatched-syntax-next
1108 Another interesting mode will display a line between all the tags in the
1109 current buffer to make it more obvious where boundaries lie. You can
1110 enable this as a minor mode.
1112 -- Command: semantic-show-tag-boundaries-mode &optional arg
1113 Minor mode to display a boundary in front of tags. The boundary is
1114 displayed using an overline in Emacs 21. With prefix argument ARG,
1115 turn on if positive, otherwise off. The minor mode can be turned
1116 on only if semantic feature is available and the current buffer was
1117 set up for parsing. Return non-'nil' if the minor mode is enabled.
1119 Another interesting mode helps if you are worred about specific
1120 attributes, you can se this minor mode to highlight different tokens in
1121 different ways based on the attributes you are most concerned with.
1123 -- Command: semantic-highlight-by-attribute-mode &optional arg
1124 Minor mode to highlight tags based on some attribute. By default,
1125 the protection of a tag will give it a different background color.
1127 With prefix argument ARG, turn on if positive, otherwise off. The
1128 minor mode can be turned on only if semantic feature is available
1129 and the current buffer was set up for parsing. Return non-'nil' if
1130 the minor mode is enabled.
1132 Another tool that can be used is a dump of the current list of tags.
1133 This shows the actual Lisp representation of the tags generated in a
1134 rather bland dump. This can be useful if text was successfully parsed,
1135 and you want to be sure that the correct information was captured.
1137 -- Command: bovinate &optional clear
1138 Bovinate the current buffer. Show output in a temp buffer.
1139 Optional argument CLEAR will clear the cache before bovinating. If
1140 CLEAR is negative, it will do a full reparse, and also not display
1144 File: semantic-langdev.info, Node: Bovine Parser Debugging, Next: Wisent Parser Debugging, Prev: Parser Output tools, Up: Debugging
1146 6.3 Bovine Parser Debugging
1147 ===========================
1149 The bovine parser is described in *note (bovine)top::.
1151 Asside using a traditional Emacs Lisp debugger on functions you provide
1152 for token expansion, there is one other means of debugging which
1153 interactively steps over the rules in your grammar file.
1155 -- Command: semantic-debug
1156 Parse the current buffer and run in debug mode.
1158 Once the parser is activated in this mode, the current tag cache is
1159 flushed, and the parser started. At each stage in the LALR parser, the
1160 current rule, and match step is highlighted in your parser source
1161 buffer. In a second window, the text being parsed is shown, and the
1162 lexical token found is highlighted. A clue of the current stack of
1163 saved data is displayed in the minibuffer.
1165 There is a wide range of keybindings that can be used to execute code in
1166 your buffer. (Not all are implemented.)
1174 Up. (Not implemented yet.)
1176 Down. (Not implemented yet.)
1178 Fail Match. Pretend the current match element and the token in the
1179 buffer is a failed match, even if it is not.
1181 Print information about the current parser state.
1183 Jump to to the source buffer.
1185 Jump to the parser buffer.
1187 Quit. Exits this debug session and the parser.
1189 Abort. Aborts one level of the parser, possibly exiting the
1192 Go. Stop debugging, and just start parsing.
1194 Set Breakpoint. (Not implemented yet.)
1196 'eval-expression'. Lets you execute some random Emacs Lisp
1199 Note: While the core of 'semantic-debug' is a generic debugger interface
1200 for rule based grammars, only the bovine parser has a specific backend
1201 implementation. If someone wants to implement a debugger backend for
1202 wisent, that would be spiff.
1205 File: semantic-langdev.info, Node: Wisent Parser Debugging, Next: Overlay Debugging, Prev: Bovine Parser Debugging, Up: Debugging
1207 6.4 Wisent Parser Debugging
1208 ===========================
1210 Wisent does not implement a backend for 'semantic-debug', it does have
1211 some debugging commands the rule actions. You can read about them in
1214 *note (wisent)Grammar Debugging::
1217 File: semantic-langdev.info, Node: Overlay Debugging, Next: Incremental Parser Debugging, Prev: Wisent Parser Debugging, Up: Debugging
1219 6.5 Overlay Debugging
1220 =====================
1222 Once a buffer has been parsed into a tag table, the next most important
1223 step is getting those tags activated for a buffer, and storable in a
1224 'semanticdb' backend. *note (semantic-appdev)semanticdb::.
1226 These two activities depend on the ability of every tag in the table to
1227 be linked and unlinked to the current buffer with an overlay. *note
1228 (Tag Overlay)semantic-appdev:: *note (Tag Hooks)semantic-appdev::
1230 In this case, the most important function that must be written is:
1232 -- Function: semantic-tag-components-with-overlays tag
1233 Return the list of top level components belonging to TAG. Children
1234 are any sub-tags which contain overlays.
1236 Default behavior is to get "semantic-tag-components" in addition to
1237 the components of an anonymous types (if applicable.)
1239 Note for language authors: If a mode defines a language tag that
1240 has tags in it with overlays you should still return them with this
1241 function. Ignoring this step will prevent several features from
1242 working correctly. This function can be overriden in semantic
1243 using the symbol 'tag-components-with-overlays'.
1245 If your are successfully building a tag table, and errors occur saving
1246 or restoring tags from semanticdb, this is the most likely cause of the
1250 File: semantic-langdev.info, Node: Incremental Parser Debugging, Next: Debugging Analysis, Prev: Overlay Debugging, Up: Debugging
1252 6.6 Incremental Parser Debugging
1253 ================================
1255 The incremental parser is a highly complex engine for quickly refreshing
1256 the tag table of a buffer after some set of changes have been made to
1257 that buffer by a user.
1259 There is no debugger or interface to the incremental parser, however
1260 there are a few minor modes which can help you identify issues if you
1261 think there are problems while incrementally parsing a buffer.
1263 The first stage of the incremental parser is in tracking the changes the
1264 user makes to a buffer. You can visibly track these changes too.
1266 -- Command: semantic-highlight-edits-mode &optional arg
1267 Minor mode for highlighting changes made in a buffer. Changes are
1268 tracked by semantic so that the incremental parser can work
1269 properly. This mode will highlight those changes as they are made,
1270 and clear them when the incremental parser accounts for those
1271 edits. With prefix argument ARG, turn on if positive, otherwise
1272 off. The minor mode can be turned on only if semantic feature is
1273 available and the current buffer was set up for parsing. Return
1274 non-'nil' if the minor mode is enabled.
1276 Another important aspect of the incremental parser involves tracking the
1277 current parser state of the buffer. You can track this state also.
1279 -- Command: semantic-show-parser-state-mode &optional arg
1280 Minor mode for displaying parser cache state in the modeline. The
1281 cache can be in one of three states. They are Up to date, Partial
1282 reprase needed, and Full reparse needed. The state is indicated in
1283 the modeline with the following characters:
1285 The cache is up to date.
1287 The cache requires a full update.
1289 The cache needs to be incrementally parsed.
1291 The cache is not currently parseable.
1293 Auto-parse in progress (not set here.)
1295 With prefix argument ARG, turn on if positive, otherwise off. The
1296 minor mode can be turned on only if semantic feature is available
1297 and the current buffer was set up for parsing. Return non-'nil' if
1298 the minor mode is enabled.
1300 When the incremental parser starts updating the tags buffer, you can
1301 also enable a set of messages to help identify how the incremental
1302 parser is merging changes with the main buffer.
1304 -- Variable: semantic-edits-verbose-flag
1305 Non-'nil' means the incremental perser is verbose. If 'nil',
1306 errors are still displayed, but informative messages are not.
1309 File: semantic-langdev.info, Node: Debugging Analysis, Next: Semantic 1.4 Doc, Prev: Incremental Parser Debugging, Up: Debugging
1311 6.7 Debugging Analysis
1312 ======================
1314 The semantic analyzer is a at the top of the food chain when it comes to
1315 semantic service functionality. The semantic support for a language
1316 must be absolute before analysis will work property.
1318 A good way to test analysis is by placing the cursor in different
1319 places, and requesting a dump of the context.
1321 -- Command: semantic-analyze-current-context position
1322 Analyze the current context at POSITION. If called interactively,
1323 display interesting information about POSITION in a separate
1324 buffer. Returns an object based on symbol
1325 "semantic-analyze-context".
1327 *note Semantic Analyzer Support:: *note (semantic-user)Analyzer::
1330 File: semantic-langdev.info, Node: Semantic 1.4 Doc, Prev: Debugging Analysis, Up: Debugging
1332 6.8 Semantic 1.4 Doc
1333 ====================
1335 In semantic 1.4 the following documentation was written for debugging.
1336 I'm leaving in here until better doc for 2.0 is done.
1338 Writing language files using BY is significantly easier than writing
1339 then using regular expressions in a functional manner. Debugging them,
1340 however, can still prove challenging.
1342 There are two ways to debug a language definition if it is not behaving
1343 as expected. One way is to debug against the source '.by' file.
1345 If your language definition was written in BNF notation, debugging is
1346 quite easy. The command 'semantic-debug' will start you off.
1348 -- Command: semantic-debug
1349 Reprase the current buffer and run in parser debug mode.
1351 While debugging, two windows are visible. One window shows the file
1352 being parsed, and the syntactic token being tested is highlighted. The
1353 second window shows the table being used (in the BY source) with the
1354 current rule highlighted. The cursor will sit on the specific match
1355 rule being tested against.
1357 In the minibuffer, a brief summary of the current situation is listed.
1358 The first element is the syntactic token which is a list of the form:
1362 The rest of the display is a list of all strings collected for the
1363 currently tested rule. Each time a new rule is entered, the list is
1364 restarted. Upon returning from a rule into a previous match list, the
1365 previous match list is restored, with the production of the dependent
1368 Use 'C-g' to stop debugging. There are no commands for any fancier
1371 NOTE: Semantic 2.0 has more debugging commands. Use: 'C-h m
1372 semantic-debug-mode' to view.
1375 File: semantic-langdev.info, Node: Parser Error Handling, Next: GNU Free Documentation License, Prev: Debugging, Up: Top
1377 7 Parser Error Handling
1378 ***********************
1383 File: semantic-langdev.info, Node: GNU Free Documentation License, Next: Index, Prev: Parser Error Handling, Up: Top
1385 Appendix A GNU Free Documentation License
1386 *****************************************
1388 Version 1.1, March 2000
1390 Copyright (C) 2000 Free Software Foundation, Inc.
1391 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1393 Everyone is permitted to copy and distribute verbatim copies
1394 of this license document, but changing it is not allowed.
1398 The purpose of this License is to make a manual, textbook, or other
1399 written document "free" in the sense of freedom: to assure everyone
1400 the effective freedom to copy and redistribute it, with or without
1401 modifying it, either commercially or noncommercially. Secondarily,
1402 this License preserves for the author and publisher a way to get
1403 credit for their work, while not being considered responsible for
1404 modifications made by others.
1406 This License is a kind of "copyleft", which means that derivative
1407 works of the document must themselves be free in the same sense.
1408 It complements the GNU General Public License, which is a copyleft
1409 license designed for free software.
1411 We have designed this License in order to use it for manuals for
1412 free software, because free software needs free documentation: a
1413 free program should come with manuals providing the same freedoms
1414 that the software does. But this License is not limited to
1415 software manuals; it can be used for any textual work, regardless
1416 of subject matter or whether it is published as a printed book. We
1417 recommend this License principally for works whose purpose is
1418 instruction or reference.
1421 1. APPLICABILITY AND DEFINITIONS
1423 This License applies to any manual or other work that contains a
1424 notice placed by the copyright holder saying it can be distributed
1425 under the terms of this License. The "Document", below, refers to
1426 any such manual or work. Any member of the public is a licensee,
1427 and is addressed as "you".
1429 A "Modified Version" of the Document means any work containing the
1430 Document or a portion of it, either copied verbatim, or with
1431 modifications and/or translated into another language.
1433 A "Secondary Section" is a named appendix or a front-matter section
1434 of the Document that deals exclusively with the relationship of the
1435 publishers or authors of the Document to the Document's overall
1436 subject (or to related matters) and contains nothing that could
1437 fall directly within that overall subject. (For example, if the
1438 Document is in part a textbook of mathematics, a Secondary Section
1439 may not explain any mathematics.) The relationship could be a
1440 matter of historical connection with the subject or with related
1441 matters, or of legal, commercial, philosophical, ethical or
1442 political position regarding them.
1444 The "Invariant Sections" are certain Secondary Sections whose
1445 titles are designated, as being those of Invariant Sections, in the
1446 notice that says that the Document is released under this License.
1448 The "Cover Texts" are certain short passages of text that are
1449 listed, as Front-Cover Texts or Back-Cover Texts, in the notice
1450 that says that the Document is released under this License.
1452 A "Transparent" copy of the Document means a machine-readable copy,
1453 represented in a format whose specification is available to the
1454 general public, whose contents can be viewed and edited directly
1455 and straightforwardly with generic text editors or (for images
1456 composed of pixels) generic paint programs or (for drawings) some
1457 widely available drawing editor, and that is suitable for input to
1458 text formatters or for automatic translation to a variety of
1459 formats suitable for input to text formatters. A copy made in an
1460 otherwise Transparent file format whose markup has been designed to
1461 thwart or discourage subsequent modification by readers is not
1462 Transparent. A copy that is not "Transparent" is called "Opaque".
1464 Examples of suitable formats for Transparent copies include plain
1465 ASCII without markup, Texinfo input format, LaTeX input format,
1466 SGML or XML using a publicly available DTD, and standard-conforming
1467 simple HTML designed for human modification. Opaque formats
1468 include PostScript, PDF, proprietary formats that can be read and
1469 edited only by proprietary word processors, SGML or XML for which
1470 the DTD and/or processing tools are not generally available, and
1471 the machine-generated HTML produced by some word processors for
1472 output purposes only.
1474 The "Title Page" means, for a printed book, the title page itself,
1475 plus such following pages as are needed to hold, legibly, the
1476 material this License requires to appear in the title page. For
1477 works in formats which do not have any title page as such, "Title
1478 Page" means the text near the most prominent appearance of the
1479 work's title, preceding the beginning of the body of the text.
1483 You may copy and distribute the Document in any medium, either
1484 commercially or noncommercially, provided that this License, the
1485 copyright notices, and the license notice saying this License
1486 applies to the Document are reproduced in all copies, and that you
1487 add no other conditions whatsoever to those of this License. You
1488 may not use technical measures to obstruct or control the reading
1489 or further copying of the copies you make or distribute. However,
1490 you may accept compensation in exchange for copies. If you
1491 distribute a large enough number of copies you must also follow the
1492 conditions in section 3.
1494 You may also lend copies, under the same conditions stated above,
1495 and you may publicly display copies.
1497 3. COPYING IN QUANTITY
1499 If you publish printed copies of the Document numbering more than
1500 100, and the Document's license notice requires Cover Texts, you
1501 must enclose the copies in covers that carry, clearly and legibly,
1502 all these Cover Texts: Front-Cover Texts on the front cover, and
1503 Back-Cover Texts on the back cover. Both covers must also clearly
1504 and legibly identify you as the publisher of these copies. The
1505 front cover must present the full title with all words of the title
1506 equally prominent and visible. You may add other material on the
1507 covers in addition. Copying with changes limited to the covers, as
1508 long as they preserve the title of the Document and satisfy these
1509 conditions, can be treated as verbatim copying in other respects.
1511 If the required texts for either cover are too voluminous to fit
1512 legibly, you should put the first ones listed (as many as fit
1513 reasonably) on the actual cover, and continue the rest onto
1516 If you publish or distribute Opaque copies of the Document
1517 numbering more than 100, you must either include a machine-readable
1518 Transparent copy along with each Opaque copy, or state in or with
1519 each Opaque copy a publicly-accessible computer-network location
1520 containing a complete Transparent copy of the Document, free of
1521 added material, which the general network-using public has access
1522 to download anonymously at no charge using public-standard network
1523 protocols. If you use the latter option, you must take reasonably
1524 prudent steps, when you begin distribution of Opaque copies in
1525 quantity, to ensure that this Transparent copy will remain thus
1526 accessible at the stated location until at least one year after the
1527 last time you distribute an Opaque copy (directly or through your
1528 agents or retailers) of that edition to the public.
1530 It is requested, but not required, that you contact the authors of
1531 the Document well before redistributing any large number of copies,
1532 to give them a chance to provide you with an updated version of the
1537 You may copy and distribute a Modified Version of the Document
1538 under the conditions of sections 2 and 3 above, provided that you
1539 release the Modified Version under precisely this License, with the
1540 Modified Version filling the role of the Document, thus licensing
1541 distribution and modification of the Modified Version to whoever
1542 possesses a copy of it. In addition, you must do these things in
1543 the Modified Version:
1545 A. Use in the Title Page (and on the covers, if any) a title
1546 distinct from that of the Document, and from those of previous
1547 versions (which should, if there were any, be listed in the History
1548 section of the Document). You may use the same title as a previous
1549 version if the original publisher of that version gives permission.
1550 B. List on the Title Page, as authors, one or more persons or
1551 entities responsible for authorship of the modifications in the
1552 Modified Version, together with at least five of the principal
1553 authors of the Document (all of its principal authors, if it has
1555 C. State on the Title page the name of the publisher of the
1556 Modified Version, as the publisher.
1557 D. Preserve all the copyright notices of the Document.
1558 E. Add an appropriate copyright notice for your modifications
1559 adjacent to the other copyright notices.
1560 F. Include, immediately after the copyright notices, a license
1561 notice giving the public permission to use the Modified Version
1562 under the terms of this License, in the form shown in the Addendum
1564 G. Preserve in that license notice the full lists of Invariant
1565 Sections and required Cover Texts given in the Document's license
1567 H. Include an unaltered copy of this License.
1568 I. Preserve the section entitled "History", and its title, and add
1569 to it an item stating at least the title, year, new authors, and
1570 publisher of the Modified Version as given on the Title Page. If
1571 there is no section entitled "History" in the Document, create one
1572 stating the title, year, authors, and publisher of the Document as
1573 given on its Title Page, then add an item describing the Modified
1574 Version as stated in the previous sentence.
1575 J. Preserve the network location, if any, given in the Document for
1576 public access to a Transparent copy of the Document, and likewise
1577 the network locations given in the Document for previous versions
1578 it was based on. These may be placed in the "History" section.
1579 You may omit a network location for a work that was published at
1580 least four years before the Document itself, or if the original
1581 publisher of the version it refers to gives permission.
1582 K. In any section entitled "Acknowledgements" or "Dedications",
1583 preserve the section's title, and preserve in the section all the
1584 substance and tone of each of the contributor acknowledgements
1585 and/or dedications given therein.
1586 L. Preserve all the Invariant Sections of the Document, unaltered
1587 in their text and in their titles. Section numbers or the
1588 equivalent are not considered part of the section titles.
1589 M. Delete any section entitled "Endorsements". Such a section may
1590 not be included in the Modified Version.
1591 N. Do not retitle any existing section as "Endorsements" or to
1592 conflict in title with any Invariant Section.
1594 If the Modified Version includes new front-matter sections or
1595 appendices that qualify as Secondary Sections and contain no
1596 material copied from the Document, you may at your option designate
1597 some or all of these sections as invariant. To do this, add their
1598 titles to the list of Invariant Sections in the Modified Version's
1599 license notice. These titles must be distinct from any other
1602 You may add a section entitled "Endorsements", provided it contains
1603 nothing but endorsements of your Modified Version by various
1604 parties-for example, statements of peer review or that the text has
1605 been approved by an organization as the authoritative definition of
1608 You may add a passage of up to five words as a Front-Cover Text,
1609 and a passage of up to 25 words as a Back-Cover Text, to the end of
1610 the list of Cover Texts in the Modified Version. Only one passage
1611 of Front-Cover Text and one of Back-Cover Text may be added by (or
1612 through arrangements made by) any one entity. If the Document
1613 already includes a cover text for the same cover, previously added
1614 by you or by arrangement made by the same entity you are acting on
1615 behalf of, you may not add another; but you may replace the old
1616 one, on explicit permission from the previous publisher that added
1619 The author(s) and publisher(s) of the Document do not by this
1620 License give permission to use their names for publicity for or to
1621 assert or imply endorsement of any Modified Version.
1623 5. COMBINING DOCUMENTS
1625 You may combine the Document with other documents released under
1626 this License, under the terms defined in section 4 above for
1627 modified versions, provided that you include in the combination all
1628 of the Invariant Sections of all of the original documents,
1629 unmodified, and list them all as Invariant Sections of your
1630 combined work in its license notice.
1632 The combined work need only contain one copy of this License, and
1633 multiple identical Invariant Sections may be replaced with a single
1634 copy. If there are multiple Invariant Sections with the same name
1635 but different contents, make the title of each such section unique
1636 by adding at the end of it, in parentheses, the name of the
1637 original author or publisher of that section if known, or else a
1638 unique number. Make the same adjustment to the section titles in
1639 the list of Invariant Sections in the license notice of the
1642 In the combination, you must combine any sections entitled
1643 "History" in the various original documents, forming one section
1644 entitled "History"; likewise combine any sections entitled
1645 "Acknowledgements", and any sections entitled "Dedications". You
1646 must delete all sections entitled "Endorsements."
1648 6. COLLECTIONS OF DOCUMENTS
1650 You may make a collection consisting of the Document and other
1651 documents released under this License, and replace the individual
1652 copies of this License in the various documents with a single copy
1653 that is included in the collection, provided that you follow the
1654 rules of this License for verbatim copying of each of the documents
1655 in all other respects.
1657 You may extract a single document from such a collection, and
1658 distribute it individually under this License, provided you insert
1659 a copy of this License into the extracted document, and follow this
1660 License in all other respects regarding verbatim copying of that
1663 7. AGGREGATION WITH INDEPENDENT WORKS
1665 A compilation of the Document or its derivatives with other
1666 separate and independent documents or works, in or on a volume of a
1667 storage or distribution medium, does not as a whole count as a
1668 Modified Version of the Document, provided no compilation copyright
1669 is claimed for the compilation. Such a compilation is called an
1670 "aggregate", and this License does not apply to the other
1671 self-contained works thus compiled with the Document, on account of
1672 their being thus compiled, if they are not themselves derivative
1673 works of the Document.
1675 If the Cover Text requirement of section 3 is applicable to these
1676 copies of the Document, then if the Document is less than one
1677 quarter of the entire aggregate, the Document's Cover Texts may be
1678 placed on covers that surround only the Document within the
1679 aggregate. Otherwise they must appear on covers around the whole
1684 Translation is considered a kind of modification, so you may
1685 distribute translations of the Document under the terms of section
1686 4. Replacing Invariant Sections with translations requires special
1687 permission from their copyright holders, but you may include
1688 translations of some or all Invariant Sections in addition to the
1689 original versions of these Invariant Sections. You may include a
1690 translation of this License provided that you also include the
1691 original English version of this License. In case of a
1692 disagreement between the translation and the original English
1693 version of this License, the original English version will prevail.
1697 You may not copy, modify, sublicense, or distribute the Document
1698 except as expressly provided for under this License. Any other
1699 attempt to copy, modify, sublicense or distribute the Document is
1700 void, and will automatically terminate your rights under this
1701 License. However, parties who have received copies, or rights,
1702 from you under this License will not have their licenses terminated
1703 so long as such parties remain in full compliance.
1705 10. FUTURE REVISIONS OF THIS LICENSE
1707 The Free Software Foundation may publish new, revised versions of
1708 the GNU Free Documentation License from time to time. Such new
1709 versions will be similar in spirit to the present version, but may
1710 differ in detail to address new problems or concerns. See
1711 http://www.gnu.org/copyleft/.
1713 Each version of the License is given a distinguishing version
1714 number. If the Document specifies that a particular numbered
1715 version of this License "or any later version" applies to it, you
1716 have the option of following the terms and conditions either of
1717 that specified version or of any later version that has been
1718 published (not as a draft) by the Free Software Foundation. If the
1719 Document does not specify a version number of this License, you may
1720 choose any version ever published (not as a draft) by the Free
1721 Software Foundation.
1723 ADDENDUM: How to use this License for your documents
1724 ====================================================
1726 To use this License in a document you have written, include a copy of
1727 the License in the document and put the following copyright and license
1728 notices just after the title page:
1731 Copyright (C) YEAR YOUR NAME.
1732 Permission is granted to copy, distribute and/or modify this document
1733 under the terms of the GNU Free Documentation License, Version 1.1
1734 or any later version published by the Free Software Foundation;
1735 with the Invariant Sections being LIST THEIR TITLES, with the
1736 Front-Cover Texts being LIST, and with the Back-Cover Texts being LIST.
1737 A copy of the license is included in the section entitled ``GNU
1738 Free Documentation License''.
1739 If you have no Invariant Sections, write "with no Invariant Sections"
1740 instead of saying which ones are invariant. If you have no Front-Cover
1741 Texts, write "no Front-Cover Texts" instead of "Front-Cover Texts being
1742 LIST"; likewise for Back-Cover Texts.
1744 If your document contains nontrivial examples of program code, we
1745 recommend releasing these examples in parallel under your choice of free
1746 software license, such as the GNU General Public License, to permit
1747 their use in free software.
1750 File: semantic-langdev.info, Node: Index, Prev: GNU Free Documentation License, Up: Top
1758 * bovinate: Parser Output tools. (line 61)
1759 * define-lex: Lexer Construction. (line 12)
1760 * define-lex-analyzer: Lexer Analyzer Construction.
1762 * define-lex-block-analyzer: Lexer Analyzer Construction.
1764 * define-lex-regex-analyzer: Lexer Analyzer Construction.
1766 * define-lex-simple-regex-analyzer: Lexer Analyzer Construction.
1768 * function overloading: Semantic Overload Mechanism.
1770 * Language Support Overview: Language Support Overview.
1772 * overloading, function: Semantic Overload Mechanism.
1774 * Parser Error Handling: Parser Error Handling.
1776 * semantic-analyze-current-context: Debugging Analysis. (line 13)
1777 * semantic-clear-toplevel-cache: Parsing a language file.
1779 * semantic-debug: Bovine Parser Debugging.
1781 * semantic-debug <1>: Semantic 1.4 Doc. (line 19)
1782 * semantic-edits-verbose-flag: Incremental Parser Debugging.
1784 * semantic-fetch-available-tags: Parsing a language file.
1786 * semantic-fetch-tags: Parsing a language file.
1788 * semantic-highlight-by-attribute-mode: Parser Output tools. (line 47)
1789 * semantic-highlight-edits-mode: Incremental Parser Debugging.
1791 * semantic-lex: Writing Lexers. (line 19)
1792 * semantic-lex-beginning-of-line: Lexer Built In Analyzers.
1794 * semantic-lex-charquote: Lexer Built In Analyzers.
1796 * semantic-lex-close-paren: Lexer Built In Analyzers.
1798 * semantic-lex-comments: Lexer Built In Analyzers.
1800 * semantic-lex-comments-as-whitespace: Lexer Built In Analyzers.
1802 * semantic-lex-debug: Lexical Debugging. (line 12)
1803 * semantic-lex-default-action: Lexer Built In Analyzers.
1805 * semantic-lex-ignore-comments: Lexer Built In Analyzers.
1807 * semantic-lex-ignore-newline: Lexer Built In Analyzers.
1809 * semantic-lex-ignore-whitespace: Lexer Built In Analyzers.
1811 * semantic-lex-keyword-get: Keywords. (line 21)
1812 * semantic-lex-keyword-p: Keywords. (line 14)
1813 * semantic-lex-keyword-put: Keywords. (line 18)
1814 * semantic-lex-keywords: Keywords. (line 29)
1815 * semantic-lex-map-keywords: Keywords. (line 24)
1816 * semantic-lex-newline: Lexer Built In Analyzers.
1818 * semantic-lex-newline-as-whitespace: Lexer Built In Analyzers.
1820 * semantic-lex-number: Lexer Built In Analyzers.
1822 * semantic-lex-number-expression: Lexer Built In Analyzers.
1824 * semantic-lex-open-paren: Lexer Built In Analyzers.
1826 * semantic-lex-paren-or-list: Lexer Built In Analyzers.
1828 * semantic-lex-punctuation: Lexer Built In Analyzers.
1830 * semantic-lex-punctuation-type: Lexer Built In Analyzers.
1832 * semantic-lex-string: Lexer Built In Analyzers.
1834 * semantic-lex-symbol-or-keyword: Lexer Built In Analyzers.
1836 * semantic-lex-whitespace: Lexer Built In Analyzers.
1838 * semantic-show-parser-state-mode: Incremental Parser Debugging.
1840 * semantic-show-tag-boundaries-mode: Parser Output tools. (line 36)
1841 * semantic-show-unmatched-syntax-mode: Parser Output tools. (line 13)
1842 * semantic-tag-components-with-overlays: Overlay Debugging. (line 16)
1843 * semantic-tag-expand-function: Tag Expansion. (line 9)
1844 * Tag Structure: Tag Structure. (line 6)
1845 * Writing Lexers: Writing Lexers. (line 6)
1846 * Writing Parsers: Writing Parsers. (line 6)
1852 Node: Tag Structure
\7f2340
1853 Node: Language Support Overview
\7f4214
1854 Node: Semantic Overload Mechanism
\7f5510
1855 Node: Semantic Parser Structure
\7f10651
1856 Node: Application API Structure
\7f10956
1857 Node: Semantic Analyzer Support
\7f12514
1858 Node: Writing Lexers
\7f12710
1859 Ref: semantic-lex
\7f13504
1860 Node: Lexer Overview
\7f14716
1861 Node: Lexer Output
\7f15974
1862 Node: Lexer Construction
\7f19831
1863 Ref: define-lex
\7f20293
1864 Node: Lexer Built In Analyzers
\7f21142
1865 Node: Lexer Analyzer Construction
\7f24639
1866 Node: Keywords
\7f28814
1867 Node: Keyword Properties
\7f30388
1868 Node: Writing Parsers
\7f31265
1869 Node: External Parsers
\7f32749
1870 Node: Grammar Programming Environment
\7f33095
1871 Node: Parsing a language file
\7f33688
1872 Ref: semantic-fetch-tags
\7f34062
1873 Ref: semantic-fetch-available-tags
\7f34832
1874 Ref: semantic-clear-toplevel-cache
\7f35282
1875 Node: Parser Backend Support
\7f35440
1876 Node: Example Backend File
\7f36243
1877 Node: Tag Expansion
\7f38554
1878 Ref: semantic-tag-expand-function
\7f38883
1879 Node: Debugging
\7f40533
1880 Node: Lexical Debugging
\7f41125
1881 Ref: semantic-lex-debug
\7f41559
1882 Node: Parser Output tools
\7f42032
1883 Ref: semantic-show-unmatched-syntax-mode
\7f42531
1884 Ref: semantic-show-tag-boundaries-mode
\7f43467
1885 Ref: semantic-highlight-by-attribute-mode
\7f44100
1886 Ref: bovinate
\7f44810
1887 Node: Bovine Parser Debugging
\7f45045
1888 Ref: semantic-debug
\7f45520
1889 Node: Wisent Parser Debugging
\7f47022
1890 Node: Overlay Debugging
\7f47412
1891 Ref: semantic-tag-components-with-overlays
\7f48133
1892 Node: Incremental Parser Debugging
\7f48875
1893 Ref: semantic-highlight-edits-mode
\7f49646
1894 Ref: semantic-show-parser-state-mode
\7f50381
1895 Ref: semantic-edits-verbose-flag
\7f51399
1896 Node: Debugging Analysis
\7f51534
1897 Ref: semantic-analyze-current-context
\7f52081
1898 Node: Semantic 1.4 Doc
\7f52368
1899 Node: Parser Error Handling
\7f54129
1900 Node: GNU Free Documentation License
\7f54322