Adaptive Framework  0.9.0
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
afw_compile_code_point.c
Go to the documentation of this file.
1 // See the 'COPYING' file in the project root for licensing information.
2 /*
3  * Adaptive Framework Unicode Code Point Support
4  *
5  * Copyright (c) 2010-2023 Clemson University
6  *
7  */
8 
14 #include "afw_internal.h"
15 #include <unicode/uchar.h>
16 #include <unicode/utypes.h>
17 
18 
19 /* Determine if codepoint is one that can start an afw identifier. */
22 {
23  return u_hasBinaryProperty(cp, UCHAR_ID_START)
24  || cp == '$'
25  || cp == '_';
26 }
27 
28 
29 /* Determine if codepoint is one that can continue an afw identifier. */
32 {
33  return u_hasBinaryProperty(cp, UCHAR_ID_CONTINUE)
34  || cp == '$'
35  || cp == 0x200c /* ZWNJ */
36  || cp == 0x200d; /* ZWJ */
37 }
38 
39 
40 /* Determine if codepoint matches AFW EOL production. */
43 {
44  return ( cp == 0x000A /* LF */
45  || cp == 0x000D /* CR */
46  || cp == 0x2028 /* LS */
47  || cp == 0x2029 /* PS */
48  );
49 }
50 
51 
52 /* Determine if codepoint matches AFW Whitespace production. */
55 {
56  if ( cp == 0x0009 /* Tab */
57  || cp == 0x000B /* VT */
58  || cp == 0x000C /* FF */
59  || cp == 0xFEFF /* ZWNBSP */
60  )
61  {
62  return true;
63  }
64 
65  /* This function checks for TAB + Zs */
66  return u_charType(cp) == U_SPACE_SEPARATOR;
67 }
68 
69 /* Determine if codepoint matches AFW WhitespaceOrEOL production. */
72 {
73  if ( cp == 0x0009 /* Tab */
74  || cp == 0x000B /* VT */
75  || cp == 0x000C /* FF */
76  || cp == 0xFEFF /* ZWNBSP */
77  || cp == 0x000A /* LF */
78  || cp == 0x000D /* CR */
79  || cp == 0x2028 /* LS */
80  || cp == 0x2029 /* PS */
81  )
82  {
83  return true;
84  }
85 
86  /* USP = SPACE_SEPARATOR = Zs */
87  return u_charType(cp) == U_SPACE_SEPARATOR;
88 }
89 
AFW_DEFINE(const afw_object_t *)
Adaptive Framework Core Internal.
afw_compile_code_point_is_Whitespace(afw_code_point_t cp)
Determine if codepoint matches Whitespace production.
afw_compile_code_point_is_IdentifierContinue(afw_code_point_t cp)
Determine if codepoint matches AFW IdentifierContinue production.
afw_compile_code_point_is_IdentifierStart(afw_code_point_t cp)
Determine if codepoint matches AFW IdentifierStart production.
afw_compile_code_point_is_EOL(afw_code_point_t cp)
Determine if codepoint matches AFW EOL production.
afw_compile_code_point_is_WhitespaceOrEOL(afw_code_point_t cp)
Determine if codepoint matches AFW Whitespace or EOL productions.
_Bool afw_boolean_t
Definition: afw_common.h:373
afw_int32_t afw_code_point_t
Unicode code point.
Definition: afw_common.h:205