2

Can any one suggest how to parse TEXT using ABNF grammar?

Installed abnf module. I have grammar in abc.abnf file. I have text content in abc.txt file. I am successful in validating the grammar. I want content in abc.txt need to validated against abc.abnf grammar.

I just want to convert below text message into Json after parsing/validating...

Input Text

DMS/6
Dinesh-Sr.Anlayst/12345678
DBMS/PLSQL/JOINS
DATASTRUCTURE/TRESS/GRAPHS

{
"message": "DMS",
"version": "6"
"employee": {
"name":"dinesh",
"designation": "Sr,Analyst",
"contact": "12345678"
}
"skills": {
"dbms": {
"PLSQL",
"Joins"
},
"datastructure": {
"Trees",
"Graphs"

}
}
}

====

Grammar i tried

DMS = MessageInfo
Employe
e Skills;

MessageInfo = MessageIdentifier
Slant
Version
CRLF;

Employee =
name
Hyphen
Designation
Slant
contact;


Skils =
5skill;


skill =
subject
expert1
expert2;

name=10Alpha
Designation=20Alpha
contact=10Numeric
subject=10Alpha
expert1=10Alpha
expert2=10Alpha;

MessageIdentifier ="DMS";
Slant = "/";
CRLF = %x0D;
Version = "5";
Alpha = %x41-5A;
Hyphen = "-";
Numeric= %x30-39;

Dinesh
  • 51
  • 1
  • 6
  • Are you using https://www.npmjs.com/package/abnf ? As far as I can see, that only parses the ABNF into "rules"; it does not include any code which would use the rules to parse text. You might want to look at [jison](https://zaa.ch/jison) although that implements yacc/lex style parsing. – rici Apr 07 '17 at 17:12
  • yes, i am using abnf (npmjs.com/package/abnf). – Dinesh Apr 10 '17 at 05:44
  • @rici I have answered your question and updated some more info also. I seen jison, i don't think thats what i expected.. Can you suggest something else as what i written above? (edited) – Dinesh Apr 10 '17 at 06:01

0 Answers0