Added a partial fix to regex, started improving the krakenGrammer regexes

This commit is contained in:
Nathan Braswell
2016-05-10 00:40:46 -04:00
parent 9d7a65294f
commit 4d31ca8b0f
2 changed files with 8 additions and 5 deletions

View File

@@ -157,7 +157,7 @@ numeric = "[0-9]+" ;
string = triple_quoted_string | "\"(`|[0-9]|-|=| |[a-z]|\[|]|(\\\\)|(\\n)|(\\t)|(\\\*)|(\\0)|;|'| string = triple_quoted_string | "\"(`|[0-9]|-|=| |[a-z]|\[|]|(\\\\)|(\\n)|(\\t)|(\\\*)|(\\0)|;|'|
|,|.|/|~|!|@|#|$|%|^|&|\*|\(|\)|_|\+|[A-Z]|{|}|\||:|<|>|\?| |(\\\"))*\"" ; |,|.|/|~|!|@|#|$|%|^|&|\*|\(|\)|_|\+|[A-Z]|{|}|\||:|<|>|\?| |(\\\"))*\"" ;
comment = cpp_comment | c_comment ; comment = cpp_comment | c_comment ;
cpp_comment = "//(`|[0-9]|-|=| |[a-z]|\[|]|\\|;|'|,|.|/|~|!|@|#|$|%|^|&|\*|\(|\)|_|\+|[A-Z]|{|}|\||:|\"|<|>|\?| )* cpp_comment = "//[ -~]*
" ; " ;
c_comment = "(/\*/*\**((`|[0-9]|-|=| |[a-z]|\[|]|\\|;|'| c_comment = "(/\*/*\**(([ -)]|[0-~]|[+-.]| |
|,|.|~|!|@|#|$|%|^|&|\(|\)|_|\+|[A-Z]|{|}|\||:|\"|<|>|\?| )/*\**)+\*/)|(/\*\*/)" ; )/*\**)+\*/)|(/\*\*/)" ;

View File

@@ -137,9 +137,12 @@ obj regex (Object, Serializable) {
for (var depth = 1; depth > 0; perenEnd++;) { for (var depth = 1; depth > 0; perenEnd++;) {
if (perenEnd >= regex_string.length()) if (perenEnd >= regex_string.length())
ast_transformation::error(string::string("can't find matching peren in: ") + regex_string) ast_transformation::error(string::string("can't find matching peren in: ") + regex_string)
if (regex_string[perenEnd] == '(') // be careful, this isn't quite right yet
/*var not_non_special = perenEnd == 0 || (regex_string[perenEnd-1] != '\\' && regex_string[perenEnd-1] != '[' && (perenEnd+1 >= regex_string.length() || regex_string[perenEnd+1] != ']'))*/
var not_non_special = perenEnd == 0 || (regex_string[perenEnd-1] != '[' && (perenEnd+1 >= regex_string.length() || regex_string[perenEnd+1] != ']'))
if (regex_string[perenEnd] == '(' && not_non_special)
depth++ depth++
else if (regex_string[perenEnd] == ')') else if (regex_string[perenEnd] == ')' && not_non_special)
depth-- depth--
} }
var innerBeginEnd = compile(regex_string.slice(i+1, perenEnd-1)) var innerBeginEnd = compile(regex_string.slice(i+1, perenEnd-1))