vlm | fa67ddc | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 1 | WHAT TO READ? |
| 2 | ============= |
| 3 | |
vlm | e43659a | 2004-09-19 19:40:52 +0000 | [diff] [blame] | 4 | If you haven't installed the asn1c yet, read the INSTALL file for |
| 5 | a short installation guide. |
vlm | fa67ddc | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 6 | |
vlm | d3686cd | 2004-09-06 08:08:32 +0000 | [diff] [blame] | 7 | For the list of asn1c command line options, see `asn1c -h` or `man asn1c`. |
| 8 | |
vlm | fa67ddc | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 9 | For more complete documentation on this compiler and on using the |
vlm | e43659a | 2004-09-19 19:40:52 +0000 | [diff] [blame] | 10 | results of compilation phase, please look into asn1c-usage.{pdf,html}. |
| 11 | If you are building the compiler from the sources, these documents reside |
| 12 | in the ./doc directory, otherwise they lie nearby the README file you're |
| 13 | reading right now. |
vlm | fa67ddc | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 14 | |
vlm | d79b30d | 2004-09-05 10:41:23 +0000 | [diff] [blame] | 15 | Please also read the FAQ file. |
| 16 | |
vlm | fa67ddc | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 17 | An excellent book on ASN.1 is written by Olivier Dubuisson: |
| 18 | "ASN.1 Communication between heterogeneous systems", ISBN:0-12-6333361-0. |
| 19 | |
vlm | fa67ddc | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 20 | QUICK START |
| 21 | =========== |
| 22 | |
| 23 | After building [and installing] the compiler (see INSTALL), you may use |
| 24 | the asn1c command to compile the ASN.1 specification: |
| 25 | |
vlm | e43659a | 2004-09-19 19:40:52 +0000 | [diff] [blame] | 26 | asn1c <module.asn1> # Compile module |
vlm | fa67ddc | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 27 | |
| 28 | If several specifications contain interdependencies, all of them must be |
| 29 | specified: |
| 30 | |
vlm | e43659a | 2004-09-19 19:40:52 +0000 | [diff] [blame] | 31 | asn1c <module1.asn1> <module2.asn1> ... # Compile interdependent modules |
vlm | fa67ddc | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 32 | |
vlm | e43659a | 2004-09-19 19:40:52 +0000 | [diff] [blame] | 33 | If you are building the asn1c from the sources, the ./examples directory |
| 34 | contains several ASN.1 modules and a script to extract the ASN.1 modules |
| 35 | from RFC documents. Refer to the README file in that directory. |
| 36 | To compile the X.509 PKI module: |
vlm | fa67ddc | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 37 | |
vlm | e43659a | 2004-09-19 19:40:52 +0000 | [diff] [blame] | 38 | ./asn1c/asn1c -P ./examples/rfc3280-*.asn1 # Compile-n-print |
vlm | fa67ddc | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 39 | |
| 40 | In this example, -P option is used to instruct the compiler to print the |
| 41 | compiled text on the standard output instead of creating multiple .c |
vlm | d79b30d | 2004-09-05 10:41:23 +0000 | [diff] [blame] | 42 | and .h files for every ASN.1 type found inside the specified ASN.1 modules. |
| 43 | This is useful for debugging and test automation. |
vlm | fa67ddc | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 44 | |
| 45 | The compiler -E and -EF options are used for testing the parser and |
| 46 | the semantic fixer, respectively. These options will instruct the compiler |
| 47 | to dump out the parsed (and fixed) ASN.1 specification as it was |
| 48 | "understood" by the compiler. It might be useful for checking |
| 49 | whether a particular syntactic construction is properly supported |
| 50 | by the compiler. |
| 51 | |
vlm | e43659a | 2004-09-19 19:40:52 +0000 | [diff] [blame] | 52 | asn1c -EF <module-to-test.asn1> # Check semantic validity |
vlm | fa67ddc | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 53 | |
| 54 | |
| 55 | MODEL OF OPERATION |
| 56 | ================== |
| 57 | |
| 58 | The asn1c compiler works by processing the ASN.1 module specification |
| 59 | in several stages: |
| 60 | 1. In the first stage, the ASN.1 file is parsed. |
vlm | d79b30d | 2004-09-05 10:41:23 +0000 | [diff] [blame] | 61 | (Parsing produces an ASN.1 syntax tree for the subsequent levels) |
vlm | fa67ddc | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 62 | 2. In the second stage, the syntax tree is "fixed". |
vlm | d79b30d | 2004-09-05 10:41:23 +0000 | [diff] [blame] | 63 | (Fixing is a process of checking the tree for semantic errors, |
| 64 | accompanied by the tree transformation into the canonical form) |
vlm | fa67ddc | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 65 | 3. In the third stage, the syntax tree is compiled into the target language. |
| 66 | |
| 67 | There are several command-line options reserved for printing the results |
| 68 | after each stage of operation: |
| 69 | |
| 70 | <parser> => print (-E) |
| 71 | <parser> => <fixer> => print (-E -F) |
| 72 | <parser> => <fixer> => <compiler> => print (-P) |
| 73 | <parser> => <fixer> => <compiler> => save-compiled [default] |
| 74 | |
| 75 | |
| 76 | -- |
| 77 | Lev Walkin |
| 78 | vlm@lionet.info |