Next: , Previous: languagemode Decl, Up: Declarations


2.3.3 keyword Decl

— %-Decl: %keyword keyword-name keyword-value

Declare a language keyword (a reserved word).

keyword-name
Is the terminal symbol used in grammar rules to represent this reserved word.
keyword-value
Is the actual value of the keyword as a string.

Here is how the if, else, endif keywords might be declared:

          %keyword IF    "if"
          %keyword ELSE  "else"
          %keyword ENDIF "endif"

Keywords have the implicit reserved type keyword (see type Decl).

In the generated library, keyword declarations are defined in the constant library-name--keyword-table. The keyword table value is an Emacs Lisp obarray, available at run time in the parsed buffer, in the buffer local variable semantic-flex-keywords-obarray.

However you shouldn't use that variable directly. semantic provides the following API to use with language keywords at run time.

— Function: semantic-lex-keyword-symbol name

Return keyword symbol with NAME or nil if not found. Return nil otherwise.

— Function: semantic-lex-keyword-p name

Return non-nil if a keyword with NAME exists in the keyword table. Return nil otherwise.

     
     
Compatibility: semantic-lex-keyword-p introduced in semantic version 2.0 supercedes semantic-flex-keyword-p which is now obsolete.

— Function: semantic-lex-keyword-set name value

Set value of keyword with NAME to VALUE and return VALUE.

— Function: semantic-lex-keyword-value name

Return value of keyword with NAME. Signal an error if a keyword with NAME does not exist.

— Function: semantic-lex-map-keywords fun &optional property

Call function FUN on every semantic keyword. If optional PROPERTY is non-nil, call FUN only on every keyword which as a PROPERTY value. FUN receives a semantic keyword as argument.

     
     
Compatibility: semantic-lex-map-keywords introduced in semantic version 2.0 supercedes semantic-flex-map-keywords which is now obsolete.

— Function: semantic-lex-keywords &optional property

Return a list of semantic keywords. If optional PROPERTY is non-nil, return only keywords which have a PROPERTY set (see put Decl).

     
     
Compatibility: semantic-lex-keywords introduced in semantic version 2.0 supercedes semantic-flex-keywords which is now obsolete.