Clean up after claude
This commit is contained in:
@@ -10,11 +10,11 @@ import (
|
||||
// Processor defines the interface for all file processors
|
||||
type Processor interface {
|
||||
// Process handles processing a file with the given pattern and Lua expression
|
||||
Process(filename string, pattern string, luaExpr string, originalExpr string) (int, int, error)
|
||||
Process(filename string, pattern string, luaExpr string) (int, int, error)
|
||||
|
||||
// ProcessContent handles processing a string content directly with the given pattern and Lua expression
|
||||
// Returns the modified content, modification count, match count, and any error
|
||||
ProcessContent(content string, pattern string, luaExpr string, originalExpr string) (string, int, int, error)
|
||||
ProcessContent(content string, pattern string, luaExpr string) (string, int, int, error)
|
||||
|
||||
// ToLua converts processor-specific data to Lua variables
|
||||
ToLua(L *lua.LState, data interface{}) error
|
||||
@@ -76,6 +76,29 @@ func LimitString(s string, maxLen int) string {
|
||||
return s[:maxLen-3] + "..."
|
||||
}
|
||||
|
||||
// BuildLuaScript prepares a Lua expression from shorthand notation
|
||||
func BuildLuaScript(luaExpr string) string {
|
||||
// Auto-prepend v1 for expressions starting with operators
|
||||
if strings.HasPrefix(luaExpr, "*") ||
|
||||
strings.HasPrefix(luaExpr, "/") ||
|
||||
strings.HasPrefix(luaExpr, "+") ||
|
||||
strings.HasPrefix(luaExpr, "-") ||
|
||||
strings.HasPrefix(luaExpr, "^") ||
|
||||
strings.HasPrefix(luaExpr, "%") {
|
||||
luaExpr = "v1 = v1" + luaExpr
|
||||
} else if strings.HasPrefix(luaExpr, "=") {
|
||||
// Handle direct assignment with = operator
|
||||
luaExpr = "v1 " + luaExpr
|
||||
}
|
||||
|
||||
// Add assignment if needed
|
||||
if !strings.Contains(luaExpr, "=") {
|
||||
luaExpr = "v1 = " + luaExpr
|
||||
}
|
||||
|
||||
return luaExpr
|
||||
}
|
||||
|
||||
// Max returns the maximum of two integers
|
||||
func Max(a, b int) int {
|
||||
if a > b {
|
||||
|
Reference in New Issue
Block a user