1package gojsonld 2 3import ( 4 "regexp" 5) 6 7var ( 8 HEX = regexp.MustCompile("[0-9A-Fa-f]") 9 10 PN_CHARS_BASE = regexp.MustCompile("[a-zA-Z]|[\u00C0-\u00D6]|[\u00D8-\u00F6]|[\u00F8-\u02FF]|[\u0370-\u037D]|[\u037F-\u1FFF]|" + 11 "[\u200C-\u200D]|[\u2070-\u218F]|[\u2C00-\u2FEF]|[\u3001-\uD7FF]|[\uF900-\uFDCF]|[\uFDF0-\uFFFD]") 12 PN_CHARS_U = regexp.MustCompile("(?:" + PN_CHARS_BASE.String() + ")" + "|[_]|[:]") 13 PN_CHARS = regexp.MustCompile("(?:" + PN_CHARS_U.String() + ")" + "|[-]|[0-9]|[\u00B7]|[\u0300-\u036F]|[\u203F-\u2040]") 14 15 ECHAR = regexp.MustCompile("\\\\[tbnrf\\\\\"']") 16 UCHAR = regexp.MustCompile("\\\\u" + HEX.String() + HEX.String() + HEX.String() + HEX.String() + 17 "|\\\\U" + HEX.String() + HEX.String() + HEX.String() + HEX.String() + HEX.String() + HEX.String() + HEX.String() + HEX.String()) 18 19 BLANK_NODE_LABEL = regexp.MustCompile("_:(" + "(?:" + PN_CHARS_U.String() + ")" + "|[0-9])((" + "(?:" + PN_CHARS.String() + ")" + 20 "|[\\.])*" + "(?:" + PN_CHARS.String() + ")" + ")?") 21 22 STRING_LITERAL_QUOTE = regexp.MustCompile("\"([^\u0022\u005C\u000A\u000D]|" + ECHAR.String() + "|" + UCHAR.String() + ")*\"") 23 STRING_LITERAL_SINGLE_QUOTE = regexp.MustCompile("'([^\u0027\u005C\u000A\u000D]|" + ECHAR.String() + "|" + UCHAR.String() + ")*'") 24 STRING_LITERAL_LONG_SINGLE_QUOTE = regexp.MustCompile("'''(?:(?:(?:'|'')?[^'\\\\])|" + ECHAR.String() + "|" + UCHAR.String() + ")*'''") 25 STRING_LITERAL_LONG_QUOTE = regexp.MustCompile("\"\"\"(?:(?:(?:\"|\"\")?[^\\\"\\\\])|" + ECHAR.String() + "|" + UCHAR.String() + ")*\"\"\"") 26 27 IRIREF = regexp.MustCompile("<([^\u0000-\u0020<>\"\\{\\}\\|\\^`\\\\]|" + UCHAR.String() + ")*" + ">") 28 EOL = regexp.MustCompile("[\u000D\u000A]+") 29 LANGTAG = regexp.MustCompile("@[a-zA-Z]+(-[a-zA-Z0-9]+)*") 30 DATATYPE = regexp.MustCompile("\\^\\^" + IRIREF.String()) 31 LITERAL = regexp.MustCompile("(?:" + STRING_LITERAL_QUOTE.String() + "){1}" + "((?:" + DATATYPE.String() + ")" + 32 "|" + "(?:" + LANGTAG.String() + ")" + ")?") 33 GRAPH_LABEL = regexp.MustCompile("(?:" + IRIREF.String() + ")" + "|" + "(?:" + BLANK_NODE_LABEL.String() + ")") 34 OBJECT = regexp.MustCompile("(?:" + IRIREF.String() + ")" + "|" + "(?:" + BLANK_NODE_LABEL.String() + ")" + 35 "|" + "(?:" + LITERAL.String() + ")") 36 //TODO predicate needs to be IRIFEF | BLANK_NODE in order to pass the tests 37 PREDICATE = regexp.MustCompile("(?:" + IRIREF.String() + ")" + "|" + "(?:" + BLANK_NODE_LABEL.String() + ")") 38 SUBJECT = regexp.MustCompile("(?:" + IRIREF.String() + ")" + "|" + "(?:" + BLANK_NODE_LABEL.String() + ")") 39 STATEMENT = regexp.MustCompile("(?P<subject>" + SUBJECT.String() + ")" + WS_1_N.String() + 40 "(?P<predicate>" + PREDICATE.String() + ")" + WS_1_N.String() + 41 "(?P<object>" + OBJECT.String() + ")" + WS_1_N.String() + 42 "((?P<graph>" + GRAPH_LABEL.String() + ")" + WS_1_N.String() + ")?" + "(?:\\.){1}") 43 44 // TRICKY_UTF_CHARS = regexp.MustCompile("[\uD800\uDC00-\uDB7F\uDFFF]") 45 PN_PREFIX = regexp.MustCompile("(?:(?:" + PN_CHARS_BASE.String() + ")(?:(?:" + 46 PN_CHARS.String() + "|[\\.])*(?:" + PN_CHARS.String() + "))?)") 47 PN_LOCAL_ESC = regexp.MustCompile("[\\\\][_~\\.\\-!$&'\\(\\)*+,;=/?#@%]") 48 PERCENT = regexp.MustCompile("%" + HEX.String() + HEX.String()) 49 PLX = regexp.MustCompile(PERCENT.String() + "|" + PN_LOCAL_ESC.String()) 50 PN_LOCAL = regexp.MustCompile("((?:" + PN_CHARS_U.String() + "|[:]|[0-9]|" + 51 PLX.String() + ")(?:(?:" + PN_CHARS.String() + "|[.]|[:]|" + PLX.String() + ")*(?:" + PN_CHARS.String() + "|[:]|" + PLX.String() + 52 "))?)") 53 PNAME_NS = regexp.MustCompile("((?:" + PN_PREFIX.String() + ")?):") 54 PNAME_LN = regexp.MustCompile("" + PNAME_NS.String() + PN_LOCAL.String()) 55 WS = regexp.MustCompile("[ \t]") 56 WS_0_N = regexp.MustCompile(WS.String() + "*") 57 WS_0_1 = regexp.MustCompile(WS.String() + "?") 58 WS_1_N = regexp.MustCompile(WS.String() + "+") 59 INTEGER = regexp.MustCompile("[+-]?[0-9]+") 60 DECIMAL = regexp.MustCompile("[+-]?[0-9]*\\.[0-9]+") 61 EXPONENT = regexp.MustCompile("[eE][+-]?[0-9]+") 62 DOUBLE = regexp.MustCompile("[+-]?(?:(?:[0-9]+\\.[0-9]*" + EXPONENT.String() + 63 ")|(?:\\.[0-9]+" + EXPONENT.String() + ")|(?:[0-9]+" + EXPONENT.String() + "))") 64) 65