refactoring patrerns...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2022-04-30 18:35:39 +03:00
parent d452b63465
commit 0c1f48ee22

View File

@ -492,18 +492,19 @@ object.Constructor('BasePage', {
// XXX BUG? '<slot name=x text="moo <now/> foo">' is parsed semi-wrong... // XXX BUG? '<slot name=x text="moo <now/> foo">' is parsed semi-wrong...
var parser = var parser =
module.parser = { module.parser = {
// XXX // XXX update a-la MACRO_ARGS...
MACRO_INLINE_ARGS: '[^)]*', MACRO_INLINE_ARGS: '[^)]*',
// XXX ugly... // XXX need to update the arg pattern below too...
MACRO_ARGS: ['(', MACRO_ARGS: ['(',
// "arg" | 'arg' // "arg" | 'arg'
'\\s+"[^"]"', // XXX add quote escaping??
'|\\s+\'[^\']\'', '\\s+"[^"]*"',
// arg "|\\s+'[^']*'",
'|\\s+[^\\s\\/>\'"]+', // arg
// arg='val' | arg="val" | arg=val '|\\s+[^\\s\\/>\'"]+',
'|\\s+[a-z]+=(\'[^\']*\'|"[^"]*"|[^\\s"\']*)', // arg='val' | arg="val" | arg=val
')*'].join(''), '|\\s+[a-z]+=(\'[^\']*\'|"[^"]*"|[^\\s"\']*)',
')*'].join(''),
// patterns... // patterns...
// //
// NOTE: the actual macro pattern is not stored as it depends on // NOTE: the actual macro pattern is not stored as it depends on
@ -531,7 +532,7 @@ module.parser = {
.replace(/MACRO_ARGS/g, this.MACRO_ARGS) .replace(/MACRO_ARGS/g, this.MACRO_ARGS)
.replace(/MACRO_INLINE_ARGS/g, this.MACRO_INLINE_ARGS) .replace(/MACRO_INLINE_ARGS/g, this.MACRO_INLINE_ARGS)
})`)).length-2) }, })`)).length-2) },
// XXX still buggy... // XXX update using MACRO_ARGS...
MACRO_ARGS_PATTERN: RegExp('('+[ MACRO_ARGS_PATTERN: RegExp('('+[
// named args... // named args...
'(?<nameQuoted>[a-zA-Z-_]+)\\s*=([\'"])(?<valueQuoted>([^\\3]|\\\\3)*)\\3\\s*', '(?<nameQuoted>[a-zA-Z-_]+)\\s*=([\'"])(?<valueQuoted>([^\\3]|\\\\3)*)\\3\\s*',