aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2010-03-25 19:34:05 +0000
committerMatthew Wild <mwild1@gmail.com>2010-03-25 19:34:05 +0000
commit6fa3afd4ef1db7709ba4fe07555ce14638e35e44 (patch)
tree3c6fe47e9d6fe247afdd9355f290a9b0eae5a087
parentb697788460e186879148ca722e52d47d2a5a6169 (diff)
downloadprosody-6fa3afd4ef1db7709ba4fe07555ce14638e35e44.tar.gz
prosody-6fa3afd4ef1db7709ba4fe07555ce14638e35e44.zip
tools/erlparse: Report the line number when showing a syntax error in the input file
-rw-r--r--tools/erlparse.lua8
1 files changed, 6 insertions, 2 deletions
diff --git a/tools/erlparse.lua b/tools/erlparse.lua
index fdef7e8c..a5cef464 100644
--- a/tools/erlparse.lua
+++ b/tools/erlparse.lua
@@ -12,12 +12,16 @@ local type, tonumber, tostring = type, tonumber, tostring;
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)