From 43fdbf94ad87ea91a173c72688cad70a0a5f1ab4 Mon Sep 17 00:00:00 2001 From: Ryo Nihei Date: Fri, 30 Apr 2021 01:54:02 +0900 Subject: Add character property expression (Meet RL1.2 of UTS #18 partially) \p{property name=property value} matches a character has the property. When the property name is General_Category, it can be omitted. That is, \p{Letter} equals \p{General_Category=Letter}. Currently, only General_Category is supported. This feature meets RL1.2 of UTS #18 partially. RL1.2 Properties: https://unicode.org/reports/tr18/#RL1.2 --- compiler/syntax_error.go | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) (limited to 'compiler/syntax_error.go') diff --git a/compiler/syntax_error.go b/compiler/syntax_error.go index df8977d..d784995 100644 --- a/compiler/syntax_error.go +++ b/compiler/syntax_error.go @@ -18,23 +18,26 @@ func (e *SyntaxError) Error() string { var ( // lexical errors - synErrIncompletedEscSeq = newSyntaxError("incompleted escape sequence; unexpected EOF following \\") - synErrInvalidEscSeq = newSyntaxError("invalid escape sequence") - synErrInvalidCodePoint = newSyntaxError("code points must consist of just 4 or 6 hex digits") + synErrIncompletedEscSeq = newSyntaxError("incompleted escape sequence; unexpected EOF following \\") + synErrInvalidEscSeq = newSyntaxError("invalid escape sequence") + synErrInvalidCodePoint = newSyntaxError("code points must consist of just 4 or 6 hex digits") + synErrCharPropInvalidSymbol = newSyntaxError("invalid character property symbol") // syntax errors - synErrUnexpectedToken = newSyntaxError("unexpected token") - synErrNullPattern = newSyntaxError("a pattern must be a non-empty byte sequence") - synErrAltLackOfOperand = newSyntaxError("an alternation expression must have operands") - synErrRepNoTarget = newSyntaxError("a repeat expression must have an operand") - synErrGroupNoElem = newSyntaxError("a grouping expression must include at least one character") - synErrGroupUnclosed = newSyntaxError("unclosed grouping expression") - synErrGroupNoInitiator = newSyntaxError(") needs preceding (") - synErrGroupInvalidForm = newSyntaxError("invalid grouping expression") - synErrBExpNoElem = newSyntaxError("a bracket expression must include at least one character") - synErrBExpUnclosed = newSyntaxError("unclosed bracket expression") - synErrBExpInvalidForm = newSyntaxError("invalid bracket expression") - synErrRangeInvalidOrder = newSyntaxError("a range expression with invalid order") - synErrCPExpInvalidForm = newSyntaxError("invalid code point expression") - synErrCPExpOutOfRange = newSyntaxError("a code point must be between U+0000 to U+10FFFF") + synErrUnexpectedToken = newSyntaxError("unexpected token") + synErrNullPattern = newSyntaxError("a pattern must be a non-empty byte sequence") + synErrAltLackOfOperand = newSyntaxError("an alternation expression must have operands") + synErrRepNoTarget = newSyntaxError("a repeat expression must have an operand") + synErrGroupNoElem = newSyntaxError("a grouping expression must include at least one character") + synErrGroupUnclosed = newSyntaxError("unclosed grouping expression") + synErrGroupNoInitiator = newSyntaxError(") needs preceding (") + synErrGroupInvalidForm = newSyntaxError("invalid grouping expression") + synErrBExpNoElem = newSyntaxError("a bracket expression must include at least one character") + synErrBExpUnclosed = newSyntaxError("unclosed bracket expression") + synErrBExpInvalidForm = newSyntaxError("invalid bracket expression") + synErrRangeInvalidOrder = newSyntaxError("a range expression with invalid order") + synErrCPExpInvalidForm = newSyntaxError("invalid code point expression") + synErrCPExpOutOfRange = newSyntaxError("a code point must be between U+0000 to U+10FFFF") + synErrCharPropExpInvalidForm = newSyntaxError("invalid character property expression") + synErrCharPropUnsupported = newSyntaxError("unsupported character property") ) -- cgit v1.2.3