|
I have used LPeg 1.0.1 for parsing lua and json for a long time. The json file is too large, I have post it in github: https://github.com/sumneko/LuaParser/blob/develop/test/perform/test.json The test parser is the following code: --------------------------------------------------------------- local paser = P { V'Value', Nl = P'\r\n' + S'\r\n', Sp = S' \t', Spnl = (V'Sp' + V'Nl')^0, Bool = P'true' + P'false', Int = '0' + (P'-'^-1 * R'09'^1), Float = P'-'^-1 * ('0' + R'09'^1) * '.' * R'09'^0 * V'FloatSuffix'^-1, Bad = (R'09' + R'az' + R'AZ')^1, FloatSuffix = S'eE' * P'-'^-1 * R'09'^1, Null = P'null', String = '"' * ('\\' * P(1) + (P(1) - '"'))^0 * '"', Table = V'Spnl' * S'[{' * V'Spnl' * ( V'Object' + V'Value' + P',' * V'Spnl' )^0 * V'Spnl' * S']}' * V'Spnl', Object = V'Spnl' * V'Key' * V'Spnl' * V'Value' * V'Spnl', Key = V'String' * V'Spnl' * ':', Value = V'Table' + V'Bool' + V'Null' + V'String' + V'Float' + V'Int' + V'Bad' } --------------------------------------------------------------- This parser did a pure match, performance has decreased by about 50%. In practice, the performance has decreased by about 25% due to the need to process the capture results. Sorry for my bad English. -- sumneko (Please! This is not a spam! I have revised this email 25 times!) |