提交 91102f9d 编写于 作者: C calin cerchez

working on parser

上级 30c52e88
file 13724 1341907082
file 13724 1342196896
version 2
run General-0-20120709-16:16:37-6492
attr configname General
......
......@@ -19,9 +19,7 @@
#define RRC_H_
#include <omnetpp.h>
#include "RRCPDUDefinitions.h"
using namespace RRC;
//#include "RRCPDUDefinitions.h"
class RRC : public cSimpleModule {
public:
......
......@@ -17,7 +17,7 @@
#include "RRCClassDefinitions.h"
namespace RRC {
namespace rrcNamespace {
const void *DLDCCHMessageType::choicesInfo[32] = {
&ActiveSetUpdate::theInfo,
......
......@@ -22,7 +22,7 @@
#include "RRCPDUDefinitions.h"
#include "RRCInformationElements.h"
namespace RRC {
namespace rrcNamespace {
typedef Null DLDCCHMessageTypeSpare3;
......@@ -252,4 +252,5 @@ public:
};
}
#endif /* RRCCLASSDEFINITIONS_H_ */
......@@ -17,3 +17,6 @@
#include "RRCConstantDefinitions.h"
namespace rrcNamespace {
}
......@@ -20,6 +20,8 @@
#include "ASNTypes.h"
namespace rrcNamespace {
#define hiPDSCHidentities 64
#define hiPUSCHidentities 64
......@@ -326,4 +328,6 @@
#define maxURNTI_Group 8
}
#endif /* RRCCONSTANTDEFINITIONS_H_ */
......@@ -17,7 +17,7 @@
#include "RRCInformationElements.h"
namespace RRC {
namespace rrcNamespace {
const void *CNDomainInformation::itemsInfo[2] = {
&CNDomainIdentity::theInfo,
......@@ -21,7 +21,7 @@
#include "ASNTypes.h"
#include "RRCConstantDefinitions.h"
namespace RRC {
namespace rrcNamespace {
typedef BitString<CONSTRAINED, 14, 14> Ansi41IDNNS;
......
......@@ -17,7 +17,7 @@
#include "RRCPDUDefinitions.h"
namespace RRC {
namespace rrcNamespace {
const void *ActiveSetUpdater3IEs::itemsInfo[12] = {
&RRCTransactionIdentifier::theInfo,
......@@ -22,7 +22,7 @@
#include "RRCInformationElements.h"
#include "RRCConstantDefinitions.h"
namespace RRC {
namespace rrcNamespace {
class ActiveSetUpdater3IEs : Sequence {
private:
......@@ -14595,5 +14595,6 @@ public:
SystemInformationContainer(): Sequence(&theInfo) {}
};
#endif /* RRCPDUDEFINITIONS_H_ */
}
#endif /* RRCPDUDEFINITIONS_H_ */
import re
from optparse import OptionParser
import os
openbracket = '{'
closedbracket = '}'
......@@ -49,6 +50,8 @@ constrainttypes = ['Integer',
'OctetString',
'OctetStringBase']
module = "RRC"
#directory = "/root/Desktop/omnetpp-4.2.2/samples/4Gsim/src/linklayer/lte/rrc/message/"
directory = "D:\\omnetpp-4.2.2\\samples\\4Gsim\\src\\linklayer\\lte\\rrc\\message\\"
outfilename = ''
includes = list()
imports = list()
......@@ -345,7 +348,7 @@ def writeobject(asnobj, hdrfile, srcfile):
if asnobj.type in constrainttypes:
if asnobj.constrainttype == "CONSTANT":
hdrfile.write("#define " + asnobj.name + " " + str(asnobj.value) + "\n")
if asnobj.constrainttype == "UNCONSTRAINED":
elif asnobj.constrainttype == "UNCONSTRAINED":
hdrfile.write("typedef " + asnobj.type + " " + asnobj.name + ";\n")
else:
hdrfile.write("typedef " + asnobj.type + "<" + asnobj.constrainttype)
......@@ -469,27 +472,16 @@ def writeheader(file):
"//\n" +
"// You should have received a copy of the GNU Lesser General Public License\n" +
"// along with this program. If not, see http://www.gnu.org/licenses/.\n" +
"//\n\n")
"//\n\n")
def main():
usage = "usage: %prog [options] input filename"
parser = OptionParser(usage)
parser.add_option("-o", "--output", dest="filename",
help="name of output file", metavar="FILENAME")
(options, args) = parser.parse_args()
#directory = "/root/Desktop/omnetpp-4.2.2/samples/4Gsim/src/linklayer/lte/rrc/message/"
directory = "D:\\omnetpp-4.2.2\\samples\\4Gsim\\src\\linklayer\\lte\\rrc\\message\\"
filename = "InformationElements"
file = open(directory + filename + ".asn", "r")
def parsefile(filename):
file = open(directory + filename, "r")
lines = file.readlines()
file.close()
objectstring = ""
print ("parsing file...")
print ("parsing file " + filename + "...")
for i, line in enumerate(lines):
if assign in line:
if len(objectstring) > 0:
......@@ -500,8 +492,12 @@ def main():
asnobjs.append(parsestring(objectstring))
#printobjects(asnobjs)
print ("writing source files...")
def writefile(filename):
global asnobjs
global includes
global imports
print ("writing source files for " + filename + "...")
hdrfile = open(directory + outfilename + ".h", 'w')
srcfile = open(directory + outfilename + ".cc", 'w')
writeheader(hdrfile)
......@@ -516,8 +512,8 @@ def main():
srcfile.write("#include \"" + outfilename + ".h\"\n\n")
srcfile.write("namespace " + module + " {\n\n")
hdrfile.write("namespace " + module + " {\n\n")
srcfile.write("namespace " + module.lower() + "Namespace {\n\n")
hdrfile.write("namespace " + module.lower() + "Namespace {\n\n")
for i in range (0, len(asnobjs)):
asnobj = asnobjs[i]
......@@ -530,6 +526,30 @@ def main():
srcfile.close()
hdrfile.close()
includes = list()
imports = list()
asnobjs = list()
def main():
os.chdir(directory)
for filename in os.listdir("."):
if filename.endswith(".asn"):
parsefile(filename)
writefile(filename)
## usage = "usage: %prog [options] input filename"
## parser = OptionParser(usage)
## parser.add_option("-o", "--output", dest="filename",
## help="name of output file", metavar="FILENAME")
##
## (options, args) = parser.parse_args()
##
##
## #printobjects(asnobjs)
if __name__ == "__main__":
main()
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册