Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support (parsing of) "string call" syntax #8

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 18 additions & 22 deletions minify.lua
Original file line number Diff line number Diff line change
Expand Up @@ -752,6 +752,20 @@ function CreateLuaParser(text)
end
end

local function callexpr(base)
return MkNode{
Type = 'CallExpr';
Base = base;
FunctionArguments = functionargs();
GetFirstToken = function(self)
return self.Base:GetFirstToken()
end;
GetLastToken = function(self)
return self.FunctionArguments:GetLastToken()
end;
}
end

local function primaryexpr()
local base = prefixexpr()
assert(base, "nil prefixexpr")
Expand Down Expand Up @@ -807,29 +821,11 @@ function CreateLuaParser(text)
end;
}
elseif tk.Source == '{' then
base = MkNode{
Type = 'CallExpr';
Base = base;
FunctionArguments = functionargs();
GetFirstToken = function(self)
return self.Base:GetFirstToken()
end;
GetLastToken = function(self)
return self.FunctionArguments:GetLastToken()
end;
}
base = callexpr(base) -- TableCall
elseif tk.Source == '(' then
base = MkNode{
Type = 'CallExpr';
Base = base;
FunctionArguments = functionargs();
GetFirstToken = function(self)
return self.Base:GetFirstToken()
end;
GetLastToken = function(self)
return self.FunctionArguments:GetLastToken()
end;
}
base = callexpr(base) -- ArgCall
elseif tk.Type == 'String' then
base = callexpr(base) -- StringCall
else
return base
end
Expand Down