68 if (parser->last_octet_eof) {
72 if (parser->all_eof && (parser->cursor == parser->cursor_eof)) {
73 parser->last_octet_eof =
true;
78 if (!parser->full_source) {
83 if (parser->passed_source) {
84 parser->full_source->s = parser->passed_source->s;
85 parser->full_source->len = parser->passed_source->len;
95 if (parser->callback) {
100 if (parser->estimated_size != (
int)parser->estimated_size) {
103 parser->source_buffer = apr_array_make(parser->apr_p,
105 if (parser->passed_source) {
106 for (s = parser->passed_source->s,
107 len = parser->passed_source->len;
115 parser->full_source->s =
117 parser->full_source->len = parser->source_buffer->nelts;
122 if (parser->cursor < parser->full_source->len) {
123 result = parser->full_source->s[parser->cursor];
128 else if (!parser->callback || parser->callback_eof) {
129 parser->all_eof =
true;
130 parser->last_octet_eof =
true;
131 parser->cursor_eof = parser->cursor;
136 else if (!parser->has_called_callback && parser->scanning_for_residual) {
137 parser->callback_eof =
true;
138 parser->all_eof =
true;
139 parser->last_octet_eof =
true;
140 parser->cursor_eof = parser->cursor;
146 parser->has_called_callback =
true;
148 rv = parser->callback(&result, parser->callback_data,
153 parser->callback_eof =
true;
154 parser->all_eof =
true;
155 parser->last_octet_eof =
true;
156 parser->cursor_eof = parser->cursor;
162 parser->full_source->s =
164 parser->full_source->len = parser->source_buffer->nelts;
186 afw_compile_save_cursor(save);
189 if (impl_get_octet(parser) != *s) {
190 afw_compile_restore_cursor(save);
209 o = impl_get_octet(parser);
210 if (afw_compile_is_at_eof()) {
214 if (o >=
'0' && o <=
'9') {
218 if (o >=
'a' && o <=
'f') {
219 return (o -
'a') + 10;
222 if (o >=
'A' && o <=
'F') {
223 return (o -
'A') + 10;
237 o = impl_get_octet(parser);
238 if (afw_compile_is_at_eof()) {
242 if (o >=
'0' && o <=
'9') {
246 if (o >=
'a' && o <=
'f') {
247 return (o -
'a') + 10;
250 if (o >=
'A' && o <=
'F') {
251 return (o -
'A') + 10;
270 o = impl_get_octet(parser);
272 if (afw_compile_is_at_eof()) {
276 if (o >=
'0' && o <=
'1') {
296 o = impl_get_octet(parser);
298 if (afw_compile_is_at_eof()) {
302 if (o >=
'0' && o <=
'7') {
313 afw_compile_internal_s_push_code_point(
404 state_block_comment_asterisk,
405 state_inline_comment,
409 parser->get_token_found_eol =
false;
410 if (!afw_compile_is_at_eof())
do {
412 afw_compile_save_cursor(start_offset);
413 cp = afw_compile_get_code_point();
419 if (afw_compile_is_at_eof()) {
420 parser->last_octet_eof =
false;
421 state = state_finished;
424 else if (cp ==
'/') {
425 if (!parser->strict) {
426 start_offset_first_slash = start_offset;
427 state = state_first_slash;
430 afw_compile_restore_cursor(start_offset);
431 state = state_finished;
437 afw_compile_restore_cursor(start_offset);
438 state = state_finished;
443 case state_first_slash:
445 if (afw_compile_is_at_eof()) {
446 parser->last_octet_eof =
false;
447 state = state_finished;
450 else if (cp ==
'/') {
451 state = state_inline_comment;
454 else if (cp ==
'*') {
455 state = state_block_comment;
459 afw_compile_restore_cursor(start_offset_first_slash);
460 state = state_finished;
465 case state_block_comment:
467 if (afw_compile_is_at_eof()) {
472 state = state_block_comment_asterisk;
477 case state_block_comment_asterisk:
479 if (afw_compile_is_at_eof()) {
487 else if (cp ==
'*') {
488 state = state_block_comment_asterisk;
492 state = state_block_comment;
497 case state_inline_comment:
499 if (afw_compile_is_at_eof()) {
500 parser->last_octet_eof =
false;
501 state = state_finished;
505 if (parser->get_token_before_eol) {
506 parser->get_token_found_eol =
true;
507 state = state_finished;
516 }
while (state != state_finished);
542 o = impl_get_octet(parser);
543 if (afw_compile_is_at_eof()) {
548 digit = impl_get_HexDigit(parser);
558 digit = impl_get_HexDigit(parser);
559 if (afw_compile_is_at_eof()) {
563 o = impl_get_octet(parser);
564 if (afw_compile_is_at_eof() || o !=
'}') {
577 impl_get_required_HexDigit(parser) * 0x1000 +
578 impl_get_required_HexDigit(parser) * 0x100 +
579 impl_get_required_HexDigit(parser) * 0x10 +
580 impl_get_required_HexDigit(parser);
583 if (cp >= 0xD800 && cp <= 0xDFFF)
589 o = impl_get_octet(parser);
594 o = impl_get_octet(parser);
600 impl_get_required_HexDigit(parser) * 0x1000 +
601 impl_get_required_HexDigit(parser) * 0x100 +
602 impl_get_required_HexDigit(parser) * 0x10 +
603 impl_get_required_HexDigit(parser);
604 if (cp2 < 0xDC00 || cp2 > 0xDFFF)
608 cp = ((cp - 0xD800) << 10) + (cp2 - 0xDC00) + 0x10000;
657 apr_array_clear(parser->s);
660 quot = impl_get_octet(parser);
661 parser->token->string_quote_character = quot;
664 parser->token->type = (quot ==
'`')
665 ? afw_compile_token_type_template_string
666 : afw_compile_token_type_utf8_string;
670 o = impl_get_octet(parser);
671 if (afw_compile_is_at_eof())
break;
672 if (o == quot)
break;
678 o = impl_get_octet(parser);
679 if (afw_compile_is_at_eof())
break;
717 impl_parse_u(parser);
733 if (afw_compile_is_at_eof() || o != quot) {
738 parser->token->string = afw_compile_get_string_literal(
781 digit = impl_get_BinaryDigit(parser);
788 digit = impl_get_BinaryDigit(parser);
812 digit = impl_get_HexDigit(parser);
819 digit = impl_get_HexDigit(parser);
843 digit = impl_get_OctalDigit(parser);
850 digit = impl_get_OctalDigit(parser);
880 afw_compile_save_cursor(start_offset);
887 o = impl_get_octet(parser);
891 if (parser->strict) {
900 if (impl_consume_matching_octets_z(parser,
"Infinity") ||
901 impl_consume_matching_octets_z(parser,
"INF"))
903 parser->token->type = afw_compile_token_type_number;
905 goto reserved_identifier;
908 if (impl_consume_matching_octets_z(parser,
"NaN")) {
909 parser->token->type = afw_compile_token_type_number;
910 parser->token->number = parser->xctx->env->
NaN;
911 goto reserved_identifier;
917 afw_compile_restore_cursor(start_offset);
922 o = impl_get_octet(parser);
925 if (afw_compile_is_at_eof()) {
930 if (o >=
'1' && o <=
'9') {
933 negative = -(o -
'0');
935 o = impl_get_octet(parser);
936 if (afw_compile_is_at_eof()) {
939 if (o < '0' || o >
'9') {
947 negative = (negative * 10);
952 negative -= (o -
'0');
956 o = impl_get_octet(parser);
957 if (afw_compile_is_at_eof()) {
962 if (o >=
'0' && o <=
'9') {
967 if (!parser->strict) {
968 if (o ==
'b' || o ==
'B') {
969 parser->token->type = afw_compile_token_type_integer;
970 parser->token->integer =
971 impl_parse_BinaryIntegerLiteral(parser);
973 parser->token->integer = -parser->token->integer;
977 if (o ==
'x' || o ==
'X') {
978 parser->token->type = afw_compile_token_type_integer;
979 parser->token->integer =
980 impl_parse_HexIntegerLiteral(parser);
982 parser->token->integer = -parser->token->integer;
986 if (o ==
'o' || o ==
'O') {
987 parser->token->type = afw_compile_token_type_integer;
988 parser->token->integer =
989 impl_parse_OctalIntegerLiteral(parser);
991 parser->token->integer = -parser->token->integer;
1005 if (afw_compile_is_at_eof()) {
1010 o = impl_get_octet(parser);
1011 if (afw_compile_is_at_eof()) {
1019 o = impl_get_octet(parser);
1021 if (afw_compile_is_at_eof() || o < '0' || o >
'9') {
1028 o = impl_get_octet(parser);
1029 if (afw_compile_is_at_eof()) {
1032 if (o < '0' || o >
'9') {
1043 if (afw_compile_is_at_eof()) {
1051 o = impl_get_octet(parser);
1052 if (o !=
'e' && o !=
'E') {
1057 o = impl_get_octet(parser);
1060 if (afw_compile_is_at_eof()) {
1065 if (o ==
'+' || o ==
'-') {
1066 o = impl_get_octet(parser);
1070 if (afw_compile_is_at_eof() || o < '0' || o >
'9')
goto error;
1074 o = impl_get_octet(parser);
1075 if (afw_compile_is_at_eof()) {
1078 if (o < '0' || o >
'9') {
1093 parser->token->type = afw_compile_token_type_integer;
1095 parser->token->integer = negative;
1098 parser->token->integer = -negative;
1112 parser->token->number = -0.0;
1114 parser->token->number = 0;
1115 parser->token->type = afw_compile_token_type_number;
1117 s = apr_pstrndup(parser->apr_p,
1118 parser->full_source->s + start_offset,
1119 parser->cursor - start_offset);
1121 parser->token->number = strtod(s, NULL);
1122 if (errno != 0)
goto error;
1127 reserved_identifier:
1129 afw_compile_save_cursor(start_offset);
1130 cp = afw_compile_get_code_point();
1132 afw_compile_restore_cursor(start_offset);
1148 afw_compile_save_cursor(start_offset);
1149 cp = afw_compile_get_code_point();
1154 afw_compile_save_cursor(save);
1155 cp = afw_compile_get_code_point();
1158 afw_compile_restore_cursor(save);
1164 result = afw_compile_get_string_literal(
1166 parser->full_source->s + start_offset,
1167 parser->cursor - start_offset);
1201 afw_compile_save_cursor(start_cursor);
1204 parser->token->type = afw_compile_token_type_identifier;
1207 parser->token->identifier_name = impl_get_identifier(parser);
1208 parser->token->identifier = parser->token->identifier_name;
1211 if (!afw_compile_is_at_eof()) {
1212 afw_compile_save_cursor(save_cursor);
1213 cp = afw_compile_get_code_point();
1215 afw_compile_restore_cursor(save_cursor);
1218 cp = afw_compile_get_code_point();
1220 afw_compile_restore_cursor(save_cursor);
1223 parser->token->identifier_qualifier =
1224 parser->token->identifier_name;
1225 parser->token->identifier_name = impl_get_identifier(parser);
1226 parser->token->identifier = afw_compile_get_string_literal(
1228 parser->full_source->s + start_cursor,
1229 parser->cursor - start_cursor);
1234 if (parser->token->identifier_qualifier ||
1235 parser->next_identifier_is_not_special_literal)
1242 parser->token->type = afw_compile_token_type_boolean;
1243 parser->token->boolean =
true;
1248 parser->token->type = afw_compile_token_type_boolean;
1249 parser->token->boolean =
false;
1254 parser->token->type = afw_compile_token_type_null;
1255 parser->token->null = NULL;
1261 parser->token->type = afw_compile_token_type_undefined;
1269 parser->token->type = afw_compile_token_type_number;
1270 parser->token->number = parser->xctx->env->
infinity;
1275 parser->token->type = afw_compile_token_type_number;
1276 parser->token->number = parser->xctx->env->
NaN;
1317 afw_compile_is_reserved_word(
1371 o = impl_get_octet(parser);
1372 if (afw_compile_is_at_eof())
return -1;
1378 else if (o >= 0xf0 ) {
1380 if (o > 0x07)
goto error;
1383 o = impl_get_octet(parser);
1384 if (afw_compile_is_at_eof())
goto error;
1385 if (o < 0x80)
goto error;
1387 if (o > 0x3f)
goto error;
1390 o = impl_get_octet(parser);
1391 if (afw_compile_is_at_eof())
goto error;
1392 if (o < 0x80)
goto error;
1394 if (o > 0x3f)
goto error;
1397 o = impl_get_octet(parser);
1398 if (afw_compile_is_at_eof())
goto error;
1399 if (o < 0x80)
goto error;
1401 if (o > 0x3f)
goto error;
1405 else if (o >= 0xe0 ) {
1407 if (o > 0x0f)
goto error;
1410 o = impl_get_octet(parser);
1411 if (afw_compile_is_at_eof())
goto error;
1412 if (o < 0x80)
goto error;
1414 if (o > 0x3f)
goto error;
1417 o = impl_get_octet(parser);
1418 if (afw_compile_is_at_eof())
goto error;
1419 if (o < 0x80)
goto error;
1421 if (o > 0x3f)
goto error;
1427 if (o > 0x1f)
goto error;
1430 o = impl_get_octet(parser);
1431 if (afw_compile_is_at_eof())
goto error;
1432 if (o < 0x80)
goto error;
1434 if (o > 0x3f)
goto error;
1453 o = impl_get_octet(parser);
1454 if (afw_compile_is_at_eof()) {
1496 impl_get_required_HexDigit(parser) * 0x1000 +
1497 impl_get_required_HexDigit(parser) * 0x100 +
1498 impl_get_required_HexDigit(parser) * 0x10 +
1499 impl_get_required_HexDigit(parser);
1502 if (cp >= 0xD800 && cp <= 0xDFFF) {
1503 if (cp >= 0xDC00)
goto error;
1504 o = impl_get_octet(parser);
1505 if (o !=
'\\')
goto error;
1506 o = impl_get_octet(parser);
1507 if (o !=
'u')
goto error;
1509 impl_get_required_HexDigit(parser) * 0x1000 +
1510 impl_get_required_HexDigit(parser) * 0x100 +
1511 impl_get_required_HexDigit(parser) * 0x10 +
1512 impl_get_required_HexDigit(parser);
1513 if (cp2 < 0xDC00 || cp2 > 0xDFFF)
goto error;
1514 cp = ((cp - 0xD800) << 10) + (cp2 - 0xDC00) + 0x10000;
1536 cp = afw_compile_get_code_point();
1539 cp = impl_unescaped(parser);
1547 afw_compile_next_raw_starts_with_impl(
1556 afw_compile_save_cursor(cursor);
1557 for (result =
true, i = 0; i < s->len; i++) {
1558 o = impl_get_octet(parser);
1559 if (afw_compile_is_at_eof() || o != s->s[i]) {
1564 afw_compile_restore_cursor(cursor);
1571 afw_compile_next_raw_starts_with_z_impl(
1578 s.len = strlen(s_z);
1579 return afw_compile_next_raw_starts_with_impl(parser, &s);
1585 afw_compile_get_raw_line_impl(
1592 if (parser->last_octet_eof) {
1598 afw_compile_save_cursor(cursor);
1601 parser->current_cursor_index++;
1602 if (parser->current_cursor_index >= AFW_COMPILE_MAX_TOKENS) {
1603 parser->current_cursor_index = 0;
1605 parser->cursors[parser->current_cursor_index] = parser->cursor;
1606 parser->cursor_count++;
1607 if (parser->cursor_count > AFW_COMPILE_MAX_TOKENS) {
1608 parser->cursor_count = AFW_COMPILE_MAX_TOKENS;
1610 parser->token->token_source_offset = parser->cursor;
1614 o = impl_get_octet(parser);
1615 if (afw_compile_is_at_eof() || o ==
'\n') {
1620 line->s = parser->full_source->s + cursor;
1621 line->len = parser->cursor - cursor;
1622 if (line->len > 0 && o != -1 && !afw_compile_is_at_eof())
1627 parser->token->type = afw_compile_token_type_raw_line;
1628 parser->token->token_source_offset = cursor;
1629 parser->token->token_source_len = line->len;
1630 parser->token->raw_line.len = line->len;
1631 parser->token->raw_line.s = line->s;
1635 parser->token->token_source_len =
1636 parser->cursor - parser->token->token_source_offset;
1655 afw_compile_skip_ws(parser);
1661 parser->get_token_before_eol =
false;
1662 if (parser->get_token_found_eol) {
1663 parser->token->type = afw_compile_token_type_eol;
1668 parser->current_cursor_index++;
1669 if (parser->current_cursor_index >= AFW_COMPILE_MAX_TOKENS) {
1670 parser->current_cursor_index = 0;
1672 parser->cursors[parser->current_cursor_index] = parser->cursor;
1673 parser->cursor_count++;
1674 if (parser->cursor_count > AFW_COMPILE_MAX_TOKENS) {
1675 parser->cursor_count = AFW_COMPILE_MAX_TOKENS;
1677 parser->token->token_source_offset = entry_cursor = parser->cursor;
1678 cp = (afw_compile_is_at_eof()) ? -1 : afw_compile_get_code_point();
1682 parser->token->type = afw_compile_token_type_end;
1687 afw_compile_restore_cursor(entry_cursor);
1688 impl_parse_String(parser);
1692 if (parser->next_can_be_template_string) {
1693 afw_compile_restore_cursor(entry_cursor);
1694 impl_parse_String(parser);
1697 parser->token->type = afw_compile_token_type_grave;
1711 afw_compile_restore_cursor(entry_cursor);
1712 if (!impl_parse_number(parser)) {
1719 afw_compile_save_cursor(temp_cursor);
1720 cp2 = afw_compile_get_code_point();
1722 parser->token->type =
1723 afw_compile_token_type_substitute_start;
1726 afw_compile_restore_cursor(temp_cursor);
1727 parser->token->type = afw_compile_token_type_dollar_sign;
1733 afw_compile_save_cursor(temp_cursor);
1734 cp2 = afw_compile_get_code_point();
1736 cp2 = afw_compile_get_code_point();
1738 parser->token->type = afw_compile_token_type_ellipsis;
1741 afw_compile_restore_cursor(temp_cursor);
1742 parser->token->type = afw_compile_token_type_period;
1746 afw_compile_restore_cursor(temp_cursor);
1747 parser->token->type = afw_compile_token_type_period;
1753 afw_compile_save_cursor(temp_cursor);
1754 cp2 = afw_compile_get_code_point();
1756 parser->token->type = afw_compile_token_type_plus_equal;
1758 else if (cp2 ==
'+') {
1759 parser->token->type = afw_compile_token_type_increment;
1762 afw_compile_restore_cursor(temp_cursor);
1763 if (parser->next_can_be_nonunary_operator) {
1764 parser->token->type = afw_compile_token_type_add;
1767 if (!impl_parse_number(parser)) {
1768 afw_compile_restore_cursor(temp_cursor);
1769 parser->token->type = afw_compile_token_type_unary_plus;
1777 afw_compile_save_cursor(temp_cursor);
1778 cp2 = afw_compile_get_code_point();
1780 parser->token->type = afw_compile_token_type_minus_equal;
1782 else if (cp2 ==
'-') {
1783 parser->token->type = afw_compile_token_type_decrement;
1785 else if (cp2 ==
'>') {
1786 parser->token->type = afw_compile_token_type_thin_arrow;
1789 afw_compile_restore_cursor(temp_cursor);
1790 if (parser->next_can_be_nonunary_operator) {
1791 parser->token->type = afw_compile_token_type_subtract;
1794 afw_compile_restore_cursor(entry_cursor);
1795 if (!impl_parse_number(parser)) {
1796 afw_compile_restore_cursor(temp_cursor);
1797 parser->token->type = afw_compile_token_type_unary_minus;
1805 afw_compile_save_cursor(temp_cursor);
1806 cp2 = afw_compile_get_code_point();
1808 parser->token->type = afw_compile_token_type_multiply_equal;
1810 else if (cp2 ==
'*') {
1811 afw_compile_save_cursor(temp_cursor);
1812 cp2 = afw_compile_get_code_point();
1814 parser->token->type = afw_compile_token_type_exponentiation_equal;
1817 afw_compile_restore_cursor(temp_cursor);
1818 parser->token->type = afw_compile_token_type_exponentiation;
1822 afw_compile_restore_cursor(temp_cursor);
1823 parser->token->type = afw_compile_token_type_multiply;
1829 afw_compile_save_cursor(temp_cursor);
1830 cp2 = afw_compile_get_code_point();
1832 parser->token->type = afw_compile_token_type_divide_equal;
1835 afw_compile_restore_cursor(temp_cursor);
1836 parser->token->type = (parser->next_can_be_nonunary_operator)
1837 ? afw_compile_token_type_divide
1838 : afw_compile_token_type_slash;
1839 parser->token->type = afw_compile_token_type_divide;
1845 afw_compile_save_cursor(temp_cursor);
1846 cp2 = afw_compile_get_code_point();
1848 parser->token->type = afw_compile_token_type_modulus_equal;
1851 afw_compile_restore_cursor(temp_cursor);
1852 parser->token->type = (parser->next_can_be_nonunary_operator)
1853 ? afw_compile_token_type_modulus
1854 : afw_compile_token_type_percent;
1860 afw_compile_save_cursor(temp_cursor);
1861 cp2 = afw_compile_get_code_point();
1863 afw_compile_save_cursor(temp_cursor);
1864 cp2 = afw_compile_get_code_point();
1866 parser->token->type =
1867 afw_compile_token_type_equal_value_and_type;
1870 afw_compile_restore_cursor(temp_cursor);
1871 parser->token->type = afw_compile_token_type_equal_to;
1874 else if (cp2 ==
'>') {
1875 parser->token->type = afw_compile_token_type_fat_arrow;
1878 afw_compile_restore_cursor(temp_cursor);
1879 parser->token->type = afw_compile_token_type_equal;
1885 afw_compile_save_cursor(temp_cursor);
1886 cp2 = afw_compile_get_code_point();
1888 afw_compile_save_cursor(temp_cursor);
1889 cp2 = afw_compile_get_code_point();
1891 parser->token->type =
1892 afw_compile_token_type_not_equal_value_and_type;
1895 afw_compile_restore_cursor(temp_cursor);
1896 parser->token->type = afw_compile_token_type_not_equal_to;
1900 afw_compile_restore_cursor(temp_cursor);
1901 parser->token->type = afw_compile_token_type_unary_not;
1907 afw_compile_save_cursor(temp_cursor);
1908 cp2 = afw_compile_get_code_point();
1910 parser->token->type = afw_compile_token_type_less_than_or_equal_to;
1913 afw_compile_restore_cursor(temp_cursor);
1914 parser->token->type = (parser->next_can_be_nonunary_operator)
1915 ? afw_compile_token_type_less_than
1916 : afw_compile_token_type_open_angle_bracket;
1922 afw_compile_save_cursor(temp_cursor);
1923 cp2 = afw_compile_get_code_point();
1925 parser->token->type =
1926 afw_compile_token_type_greater_than_or_equal_to;
1929 afw_compile_restore_cursor(temp_cursor);
1930 parser->token->type = (parser->next_can_be_nonunary_operator)
1931 ? afw_compile_token_type_greater_than
1932 : afw_compile_token_type_close_angle_bracket;
1937 afw_compile_save_cursor(temp_cursor);
1938 cp2 = afw_compile_get_code_point();
1940 afw_compile_save_cursor(temp_cursor);
1941 cp2 = afw_compile_get_code_point();
1943 parser->token->type = afw_compile_token_type_and_equal;
1946 afw_compile_restore_cursor(temp_cursor);
1947 parser->token->type = afw_compile_token_type_and;
1951 afw_compile_restore_cursor(temp_cursor);
1952 parser->token->type = afw_compile_token_type_ampersand;
1957 afw_compile_save_cursor(temp_cursor);
1958 cp2 = afw_compile_get_code_point();
1960 afw_compile_save_cursor(temp_cursor);
1961 cp2 = afw_compile_get_code_point();
1963 parser->token->type = afw_compile_token_type_or_equal;
1966 afw_compile_restore_cursor(temp_cursor);
1967 parser->token->type = afw_compile_token_type_or;
1971 afw_compile_restore_cursor(temp_cursor);
1972 parser->token->type = afw_compile_token_type_vertical_bar;
1977 parser->token->type = afw_compile_token_type_back_slash;
1981 parser->token->type = afw_compile_token_type_caret;
1985 parser->token->type = afw_compile_token_type_colon;
1989 parser->token->type = afw_compile_token_type_comma;
1993 afw_compile_save_cursor(temp_cursor);
1994 cp2 = afw_compile_get_code_point();
1996 afw_compile_save_cursor(temp_cursor);
1997 cp2 = afw_compile_get_code_point();
1999 parser->token->type = afw_compile_token_type_nullish_equal;
2002 afw_compile_restore_cursor(temp_cursor);
2003 parser->token->type = afw_compile_token_type_nullish_coalescing;
2006 else if (cp2 ==
'.') {
2007 parser->token->type = afw_compile_token_type_optional_chaining;
2009 else if (cp2 ==
'-') {
2010 cp2 = afw_compile_get_code_point();
2012 parser->token->type =
2013 afw_compile_token_type_optional_chaining_thin_arrow;
2016 afw_compile_restore_cursor(temp_cursor);
2017 parser->token->type = afw_compile_token_type_question_mark;
2021 afw_compile_restore_cursor(temp_cursor);
2022 parser->token->type = afw_compile_token_type_question_mark;
2027 parser->token->type = afw_compile_token_type_semicolon;
2031 parser->token->type = afw_compile_token_type_tilde;
2035 parser->token->type = afw_compile_token_type_open_brace;
2039 parser->token->type = afw_compile_token_type_close_brace;
2043 parser->token->type = afw_compile_token_type_open_parenthesis;
2047 parser->token->type = afw_compile_token_type_close_parenthesis;
2051 parser->token->type = afw_compile_token_type_open_bracket;
2055 parser->token->type = afw_compile_token_type_close_bracket;
2060 afw_compile_restore_cursor(entry_cursor);
2061 impl_parse_identifier(parser);
2064 parser->token->type = afw_compile_token_type_invalid;
2069 parser->next_can_be_nonunary_operator =
false;
2070 parser->next_can_be_template_string =
false;
2071 parser->next_identifier_is_not_special_literal =
false;
2074 parser->token->token_source_len =
2075 parser->cursor - parser->token->token_source_offset;
2083 if (parser->get_token_found_eol) {
2084 parser->get_token_found_eol =
false;
2089 if (parser->cursor_count > 0) {
2090 parser->cursor_count--;
2091 parser->cursor = parser->cursors[parser->current_cursor_index];
2092 parser->current_cursor_index--;
2093 if (parser->current_cursor_index < 0) {
2094 parser->current_cursor_index = AFW_COMPILE_MAX_TOKENS - 1;
2096 parser->last_octet_eof =
false;
2097 parser->token->type = afw_compile_token_type_invalid;
2108 afw_compile_internal_token_type_t result;
2110 afw_compile_get_token_impl(parser);
2111 result = parser->token->type;
2112 afw_compile_reuse_token_impl(parser);
2125 parser->scanning_for_residual =
true;
2127 switch (parser->residual_check) {
2129 case afw_compile_residual_check_none:
2132 case afw_compile_residual_check_to_newline:
2133 if (!afw_compile_is_at_eof())
for (;;) {
2134 o = impl_get_octet(parser);
2135 if (afw_compile_is_at_eof() || o ==
'\n')
break;
2137 afw_compile_save_cursor(save);
2143 case afw_compile_residual_check_to_full:
2144 if (afw_compile_is_at_eof())
break;
2145 afw_compile_skip_ws(parser);
2146 afw_compile_save_cursor(save);
2147 if (!afw_compile_next_is_at_eof())
goto error;
2177 shared->string_literals = apr_hash_make(
2187 afw_compile_lexical_parser_create(
2190 void *callback_data,
2204 if (cede_p && ( shared || parent)) {
2206 "afw_compile_lexical_parser_create() parameter cede_p true when "
2207 "parent or shared is not NULL",
2210 if (!p && !shared && !parent) {
2212 "afw_compile_lexical_parser_create() either "
2213 "parent, shared or p must be non-NULL",
2217 parser->p = shared->p;
2218 parser->shared = shared;
2222 parser->p = parent->
p;
2233 parser->xctx = xctx;
2234 parser->cede_p = cede_p;
2235 parser->error = xctx->error;
2236 parser->passed_source = source;
2237 parser->callback = callback,
2238 parser->callback_data = callback_data,
2239 parser->strict = compile_type == afw_compile_type_json;
2240 parser->compile_type = compile_type;
2241 parser->residual_check = residual_check;
2243 parser->s = apr_array_make(parser->apr_p, 256,
2245 parser->values = apr_array_make(parser->apr_p, 10,
2248 parser->estimated_size = 4096;
2249 parser->token = &parser->token_storage;
2255 parser->compiled_value->
p = parser->p;
2256 if (source_location) {
2261 parser->compiled_value->
parent = parent;
2262 parser->compiled_value->top_block = parent->current_block;
2263 parser->compiled_value->current_block = parent->current_block;
2271 afw_compile_lexical_parser_finish_and_release(
2281 afw_compile_get_string_literal(
2288 result = apr_hash_get(parser->shared->string_literals, s, len);
2291 parser->p, parser->xctx);
2292 apr_hash_set(parser->shared->string_literals,
2293 (
const void *)result->s,
2294 (apr_ssize_t)result->len,
2295 (
const void *)result);
2303 afw_compile_current_raw_token(
2306 return afw_compile_get_string_literal(parser,
2307 parser->full_source->s + parser->token->token_source_offset,
2308 parser->token->token_source_len);
AFW_DEFINE(const afw_object_t *)
#define AFW_DEFINE_INTERNAL(type)
Define an internal function for /src/afw/ source*.c files.
Adaptive Framework Core Internal.
#define AFW_ASCII_VT
Vertical Tab.
#define AFW_ASCII_FF
Form Feed.
#define AFW_ASCII_CR
Carriage Return.
#define AFW_ASCII_HT
Horizontal Tab.
#define AFW_ASCII_LF
Line Feed.
#define afw_ascii_is_whitespace(v)
Determine if octet is white space.
#define AFW_ASCII_BS
BackSpace (non-destructive)
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.
afw_int32_t afw_code_point_t
Unicode code point.
int(* afw_utf8_octet_get_cb_t)(afw_utf8_octet_t *octet, void *data, afw_xctx_t *xctx)
Get an utf-8 octet (8 bits).
afw_utf8_octet_t afw_utf8_z_t
NFC normalized UTF-8 null terminated string.
enum afw_compile_type_e afw_compile_type_t
Compile type enum.
char afw_utf8_octet_t
8 bits of utf-8 codepoint.
apr_size_t afw_size_t
size_t.
unsigned char afw_octet_t
8 bits (unsigned).
#define AFW_SIZE_T_FMT
Format string specifier used for afw_size_t.
#define AFW_INTEGER_MAX
largest afw_integer_t
#define AFW_INTEGER_MIN
smallest afw_integer_t
apr_int64_t afw_integer_t
typedef for big signed int.
#define AFW_COMPILE_THROW_ERROR_Z(message_z)
enum afw_compile_residual_check_e afw_compile_residual_check_t
Residual checking options.
afw_compile_shared_create(const afw_pool_t *p, afw_xctx_t *xctx)
Created a struct for sharing resources by multiple compiles.
#define AFW_THROW_ERROR_FZ(code, xctx, format_z,...)
Macro used to set error and 0 rv in xctx and throw it.
#define AFW_THROW_ERROR_Z(code, message_z, xctx)
Macro used to set error and 0 rv in xctx and throw it.
#define afw_pool_get_apr_pool(instance)
Call method get_apr_pool of interface afw_pool.
#define afw_pool_calloc_type(instance, type, xctx)
Macro to allocate cleared memory to hold type in pool.
const afw_pool_t * afw_pool_create(const afw_pool_t *parent, afw_xctx_t *xctx)
Create a new pool.
afw_boolean_t afw_utf8_equal_utf8_z(const afw_utf8_t *s1, const afw_utf8_z_t *s2_z)
Check to see if a string equals a utf8_z string.
#define afw_utf8_create_copy(s, len, p, xctx)
Make a utf-8 sting from chars in pool specified.
afw_boolean_t afw_utf8_equal(const afw_utf8_t *s1, const afw_utf8_t *s2)
Check to see if a string equals another string.
afw_utf8_from_code_point(afw_utf8_octet_t utf8_z[5], afw_code_point_t cp, afw_xctx_t *xctx)
Convert a code point to utf8.
const afw_utf8_t * afw_utf8_clone(const afw_utf8_t *string, const afw_pool_t *p, afw_xctx_t *xctx)
Clone a utf-8 string into a specific pool.
afw_value_compiled_value_inf
Value call inf.
#define afw_xctx_calloc_type(type, xctx)
Macro to allocate cleared memory to hold type in xctx's pool.
Resources that can be shared by multiple compiles.
const afw_utf8_t * source_location
Source location.
afw_double_t minus_infinity
Double minus infinity.
afw_double_t NaN
Double NaN.
afw_double_t infinity
Double infinity.
Interface afw_pool public struct.
NFC normalized UTF-8 string.
Struct for compiled value value.
const afw_value_compiled_value_t * parent
The parent compiled value or NULL.
const afw_pool_t * p
Pool containing value.
const afw_utf8_t * source_location
Source location provided to compiler.
Interface afw_value public struct.
Interface afw_xctx public struct.