gnu-emacs-sources
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

asn-1-generic-mode: A generic mode for ASN.1 (X.680) definitions


From: Ivan Shmakov
Subject: asn-1-generic-mode: A generic mode for ASN.1 (X.680) definitions
Date: Sun, 04 Nov 2012 14:53:38 +0700
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux)

Archive-name: asn-1-generic-mode-is
Submitted-by: address@hidden
Last-modified: 2012-11-04 +00:00
Copyright-Notice: Both the README and the code are under the
    CC0 Public Domain Dedication.

        The code below provides asn-1-generic-mode: a simplistic Emacs
        mode to edit Abstract Syntax Notation One (ASN.1) definitions,
        as per ITU-T X.680 [1].

        ASN.1 definitions are used to define (primarily binary, but also
        text- and XML-based) protocols and file formats independently of
        the implementation language, and may be considered a
        cross-language alternative to C language "struct" definitions.

        An example of an ASN.1 definition:

--- foo.asn.1 --- An ASN.1 definition example  -*- ASN-1-Generic -*-

Foo DEFINITIONS EXPLICIT TAGS ::=
BEGIN

FooSet ::= SET OF Foo

Foo ::= SEQUENCE {
    identifier  Identifier,
    name        Name
}

Identifier ::= CHOICE {
    nullId      NULL,
    integerId   INTEGER
}

Name ::= UTF8String

--- foo.asn.1 ends here

        Among the free software ASN.1 implementations are Convert::ASN1
        [2] and GNU Libtasn1 [3].

[1] http://www.itu.int/ITU-T/studygroups/com17/languages/X.680-0207.pdf
[2] http://search.cpan.org/dist/Convert-ASN1/
[3] http://www.gnu.org/software/libtasn1/

;;; asn1-generic.el --- Provide asn-1-generic-mode  -*- Emacs-Lisp -*-

;;; Ivan Shmakov, 2012

;; To the extent possible under law, the author(s) have dedicated all
;; copyright and related and neighboring rights to this software to the
;; public domain worldwide.  This software is distributed without any
;; warranty.

;; You should have received a copy of the CC0 Public Domain Dedication
;; along with this software.  If not, see
;; <http://creativecommons.org/publicdomain/zero/1.0/>.

;;; Code:

(define-generic-mode asn-1-generic-mode
  '("--" ("/*" . "*/"))
  ;; as per X.680, section 11.27
  '("ABSTRACT-SYNTAX"
    "ALL"
    "APPLICATION"
    "AUTOMATIC"
    "BEGIN"
    "BIT"
    "BMPString"
    "BOOLEAN"
    "BY"
    "CHARACTER"
    "CHOICE"
    "CLASS"
    "COMPONENT"
    "COMPONENTS"
    "CONSTRAINED"
    "CONTAINING"
    "DEFAULT"
    "DEFINITIONS"
    "EMBEDDED"
    "ENCODED"
    "END"
    "ENUMERATED"
    "EXCEPT"
    "EXPLICIT"
    "EXPORTS"
    "EXTENSIBILITY"
    "EXTERNAL"
    "FALSE"
    "FROM"
    "GeneralizedTime"
    "GeneralString"
    "GraphicString"
    "IA5String"
    "IDENTIFIER"
    "IMPLICIT"
    "IMPLIED"
    "IMPORTS"
    "INCLUDES"
    "INSTANCE"
    "INTEGER"
    "INTERSECTION"
    "ISO646String"
    "MAX"
    "MIN"
    "MINUS-INFINITY"
    "NULL"
    "NumericString"
    "OBJECT"
    "ObjectDescriptor"
    "OCTET"
    "OF"
    "OPTIONAL"
    "PATTERN"
    "PDV"
    "PLUS-INFINITY"
    "PRESENT"
    "PrintableString"
    "PRIVATE"
    "REAL"
    "RELATIVE-OID"
    "SEQUENCE"
    "SET"
    "SIZE"
    "STRING"
    "SYNTAX"
    "T61String"
    "TAGS"
    "TeletexString"
    "TRUE"
    "TYPE-IDENTIFIER"
    "UNION"
    "UNIQUE"
    "UNIVERSAL"
    "UniversalString"
    "UTCTime"
    "UTF8String"
    "VideotexString"
    "VisibleString"
    "WITH")
  '(("\\([A-Za-z0-9_]+\\)\\s-*::="
     (1 font-lock-variable-name-face)))
  '("\\.asn\\.?1\\'")
  nil
  "Generic mode for Abstract Syntax Notation One (ASN.1, X.680) files.")

;;; asn1-generic.el ends here

-- 
FSF associate member #7257


reply via email to

[Prev in Thread] Current Thread [Next in Thread]