Skip to content

Commit

Permalink
Correct and modernize the "A First Example" section
Browse files Browse the repository at this point in the history
Replace "IMPLICIT TAGS" with "AUTOMATIC TAGS" since AUTOMATIC TAGS
is recommended for all new ASN.1 specifications.
  • Loading branch information
bjorng committed Mar 28, 2014
1 parent ae7a4c5 commit e3db20e
Showing 1 changed file with 21 additions and 24 deletions.
45 changes: 21 additions & 24 deletions lib/asn1/doc/src/asn1_ug.xml
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -134,19 +134,17 @@
<title>A First Example</title> <title>A First Example</title>
<p>The following example demonstrates the basic functionality used to run <p>The following example demonstrates the basic functionality used to run
the Erlang ASN.1 compiler.</p> the Erlang ASN.1 compiler.</p>
<p>First, create a file called <c>People.asn</c> containing the following:</p> <p>Create a file called <c>People.asn</c> containing the following:</p>
<pre> <pre>
People DEFINITIONS IMPLICIT TAGS ::= People DEFINITIONS AUTOMATIC TAGS ::=

BEGIN BEGIN
EXPORTS Person; Person ::= SEQUENCE {

name PrintableString,
Person ::= [PRIVATE 19] SEQUENCE { location INTEGER {home(0),field(1),roving(2)},
name PrintableString, age INTEGER OPTIONAL
location INTEGER {home(0),field(1),roving(2)}, }
age INTEGER OPTIONAL }
END </pre> END </pre>
<p>This file (<c>people.asn</c>) must be compiled before it can be <p>This file (<c>People.asn</c>) must be compiled before it can be
used. used.
The ASN.1 compiler checks that the syntax is correct and that the The ASN.1 compiler checks that the syntax is correct and that the
text represents proper ASN.1 code before generating an abstract text represents proper ASN.1 code before generating an abstract
Expand All @@ -158,32 +156,32 @@ END </pre>
The following shows how the compiler The following shows how the compiler
can be called from the Erlang shell:</p> can be called from the Erlang shell:</p>
<pre> <pre>
1><input>asn1ct:compile("People", [ber]).</input> 1><input> asn1ct:compile("People", [ber]).</input>
ok ok
2> </pre> 2> </pre>


<p>The <c>verbose</c> option can be given to have information <p>The <c>verbose</c> option can be given to have information
about the generated files printed:</p> about the generated files printed:</p>
<pre> <pre>
2><input>asn1ct:compile("People", [ber,verbose]).</input> 2><input> asn1ct:compile("People", [ber,verbose]).</input>
Erlang ASN.1 compiling "People.asn" Erlang ASN.1 compiling "People.asn"
--{generated,"People.asn1db"}-- --{generated,"People.asn1db"}--
--{generated,"People.hrl"}-- --{generated,"People.hrl"}--
--{generated,"People.erl"}-- --{generated,"People.erl"}--
ok ok
3> </pre> 3> </pre>


<p>The ASN.1 module People is now accepted and the abstract syntax tree <p>The ASN.1 module <c>People</c> is now accepted and the
is saved in the <c>People.asn1db</c> file, the abstract syntax tree is saved in the <c>People.asn1db</c> file;
generated Erlang code is compiled using the Erlang compiler and the generated Erlang code is compiled using the Erlang compiler
loaded into the Erlang runtime system. Now there is a user interface and loaded into the Erlang runtime system. Now there is an API
for <c>encode/2</c> and <c>decode/2</c> in the module People, for <c>encode/2</c> and <c>decode/2</c> in the module
which is invoked by: <c>People</c>, which is invoked by: <br></br>
<br></br> <c><![CDATA['People':encode(<Type name>, <Value>)]]></c>
<c><![CDATA['People':encode(<Type name>,<Value>),]]></c> <br></br> <br></br>

or <br></br> or <br></br>
<c><![CDATA['People':decode(<Type name>,<Value>),]]></c></p> <c><![CDATA['People':decode(<Type name>, <Value>)]]></c></p>

<p>Assume there is a network <p>Assume there is a network
application which receives instances of the ASN.1 defined application which receives instances of the ASN.1 defined
type Person, modifies and sends them back again:</p> type Person, modifies and sends them back again:</p>
Expand All @@ -206,8 +204,7 @@ receive
constructed and encoded using constructed and encoded using
<c>'People':encode('Person',Answer)</c> which takes an <c>'People':encode('Person',Answer)</c> which takes an
instance of a defined ASN.1 type and transforms it to a instance of a defined ASN.1 type and transforms it to a
binary according to the BER or PER binary according to the BER or PER encoding rules.
encoding-rules.
<br></br> <br></br>
The encoder and the decoder can also be run from The encoder and the decoder can also be run from
the shell.</p> the shell.</p>
Expand Down

0 comments on commit e3db20e

Please sign in to comment.