# HG changeset patch # User Matthew Wild # Date 1269545645 0 # Node ID ad306c5ae689af434f3d95dc125f55a8eb219208 # Parent 475dee08b40053a76195eada41dca64b9a24e856 tools/erlparse: Report the line number when showing a syntax error in the input file diff -r 475dee08b400 -r ad306c5ae689 tools/erlparse.lua --- a/tools/erlparse.lua Thu Mar 25 19:32:35 2010 +0000 +++ b/tools/erlparse.lua Thu Mar 25 19:34:05 2010 +0000 @@ -12,12 +12,16 @@ local file = nil; local last = nil; +local line = 1; local function read(expected) local ch; if last then ch = last; last = nil; - else ch = file:read(1); end - if expected and ch ~= expected then error("expected: "..expected.."; got: "..(ch or "nil")); end + else + ch = file:read(1); + if ch == "\n" then line = line + 1; end + end + if expected and ch ~= expected then error("expected: "..expected.."; got: "..(ch or "nil").." on line "..line); end return ch; end local function pushback(ch)