mtail
mtail copied to clipboard
language: regex concatenation not working as expected
Hi! Great tool and maybe this is not a bug but a question for which the documentation is not clear enough. In this case please apologize thus "bug".
In my program I am doing the following - which does not work:
const A /^\/some\/path\/to\/wherever\/and\/whenever\/rest\//
const B /(servicename)\/?$/
# THE FOLLOWING LINE FAILS:
const C A + B
# THIS ALSO FAILS:
$uri =~ A + /(servicename)\/?$/ {
service_name=$1
}
The error (first case) is:
I1113 11:34:56.517650 7604 lexer.go:116] Emitting CONST spelled "const" at mtail.mtail:49:5-9 I1113 11:34:56.517697 7604 lexer.go:116] Emitting ID spelled "C" at mtail.mtail:49:11 I1113 11:34:56.517790 7604 parser.y:628] position marked at mtail.mtail:49:11 I1113 11:34:56.517807 7604 lexer.go:116] Emitting ID spelled "A" at mtail.mtail:49:13 E1113 11:34:56.518126 7604 main.go:180] Compile encountered errors: compile failed for mtail.mtail: mtail.mtail:49:13: syntax error: unexpected ID, expecting DIV
So the problem is obviously the concatenation of two regex vars.
Is this a bug or am I missing some knowledge here? THX!
I think these are known issues with the parser, but I also think you can force it to recognise the pattern by starting your expression with "// +" is an explicit regex and then you can append the consts.
On Fri, 13 Nov 2020, 21:16 Boris Kairat, [email protected] wrote:
Hi! Great tool and maybe this is not a bug but a question for which the documentation is not clear enough. In this case please apologize thus "bug".
In my program I am doing the following - which does not work:
const A /^/some/path/to/wherever/and/whenever/rest// const B /(servicename)/?$/
THE FOLLOWING LINE FAILS:
const C A + B
THIS ALSO FAILS:
$uri =~ A + /(servicename)/?$/ { service_name=$1 }
The error (first case) is:
I1113 11:34:56.517650 7604 lexer.go:116] Emitting CONST spelled "const" at mtail.mtail:49:5-9 I1113 11:34:56.517697 7604 lexer.go:116] Emitting ID spelled "C" at mtail.mtail:49:11 I1113 11:34:56.517790 7604 parser.y:628] position marked at mtail.mtail:49:11 I1113 11:34:56.517807 7604 lexer.go:116] Emitting ID spelled "A" at mtail.mtail:49:13 E1113 11:34:56.518126 7604 main.go:180] Compile encountered errors: compile failed for mtail.mtail: mtail.mtail:49:13: syntax error: unexpected ID, expecting DIV
So the problem is obviously the concatenation of two regex vars.
Is this a bug or am I missing some knowledge here? THX!
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/google/mtail/issues/340, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAXFX652SMPY3O4K34U2UE3SPUFAJANCNFSM4TUNWKWA .
Wow the first one is actually very terrible syntax. I should have required using an equal sign!