This is the parser that smali itself uses when reassembling the smali files.
https://github.com/JesusFreke/smali/blob/master/smali/src/main/antlr/smaliParser.g
Another option might be to use dexlib2 directly to read in a dex file, perform the modifications you want, and write it back out.