Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for EXPORT in ASN.1 files #3

Merged
merged 3 commits into from
Sep 20, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions asn1ate/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ def annotation(t):
SIZE = Keyword('SIZE')
OF = Keyword('OF')
IMPORTS = Keyword('IMPORTS')
EXPORTS = Keyword('EXPORTS')
FROM = Keyword('FROM')

# Built-in types
Expand Down Expand Up @@ -296,11 +297,11 @@ def annotation(t):

symbol = Unique(reference) # TODO: parameterized reference?
symbol_list = Group(delimitedList(symbol))

symbols_from_module = symbol_list + Suppress(FROM) + global_module_reference
symbols_from_module_list = OneOrMore(symbols_from_module)
symbols_imported = Optional(symbols_from_module_list)
imports = Optional(Suppress(IMPORTS) + symbols_imported + Suppress(';'))
imports = Optional(EXPORTS + symbol_list + Suppress(Optional(';'))) + Optional(IMPORTS + symbols_imported + Suppress(Optional(';')))


module_body = (imports + assignment_list) | empty
module_defaults = Suppress(tag_default + extension_default) # we don't want these in the AST
Expand Down
17 changes: 17 additions & 0 deletions basic_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/sh

# For every *.asn file, run it through test.py and pipe
# the result back to Python.
# This checks two things:
# 1) All steps of parsing and codegen run without exceptions
# 2) The end result is valid Python
# Note that it does not say anything about correctness or
# completeness of the generated code.

export PYTHONPATH=`pwd`
for f in testdata/*.asn;
do
echo "Checking $f";
python asn1ate/test.py $f | python
done

15 changes: 15 additions & 0 deletions testdata/exports.asn
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
TEST
DEFINITIONS ::=
BEGIN

EXPORTS
Bool,
Int,
Null;

-- Simple scalar types
Bool ::= BOOLEAN
Null ::= NULL
Int ::= INTEGER

END
14 changes: 14 additions & 0 deletions testdata/import_export.asn
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
MyASN1Module DEFINITIONS ::=

BEGIN

EXPORTS EVERYTHING

IMPORTS DataType FROM OtherASN1Module

MyType ::= INTEGER

MySet ::= SET {MyType, BOOLEAN}

END --MyASN1Module