Skip to content

Working on #if directives, Part I. #25

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Jul 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ execute_process(COMMAND
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/src/version.cc.in" "${CMAKE_CURRENT_BINARY_DIR}/src/version.cc" @ONLY)


set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++20 -O0 -Werror")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++20 -Werror")

set(CMAKE_INSTALL_PREFIX ${PROJECT_SOURCE_DIR}/.install/)

Expand All @@ -36,5 +36,11 @@ set(INCLUDE_DIR ${PROJECT_SOURCE_DIR}/include)

include_directories(${INCLUDE_DIR})


SET(FUNC_IMPL ${CMAKE_SOURCE_DIR}/src/parse_function/function_impl.cc)
SET(FUNC_DEF ${CMAKE_SOURCE_DIR}/include/parse_function/function.h)
SET(FUNC_KIND_DEF ${CMAKE_SOURCE_DIR}/include/parse_function/kinds.def)
SET(FUNC_DIAG_DEF ${CMAKE_SOURCE_DIR}/include/diag/kinds_parse.def)

add_subdirectory(src)
add_subdirectory(tests)
123 changes: 37 additions & 86 deletions gram/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,19 @@
"`false`":"kw_false",
"`true`":"kw_true",
"`nullptr`":"kw_nullptr",
"`binary-literal`":"binary_literal",
"`floating-point-literal`":"floating_point_literal",
"`character-literal`":"char_literal",
"`string-literal`":"string_literal",
"`integer-literal`":"integer_literal",
"`decimal-literal`":"decimal_literal",
"`octal-literal`":"octal_literal",
"`hexadecimal-literal`":"hexadecimal_literal",
"`raw-string`":"raw_string",
"`user-defined-character-literal`":"user_defined_char_literal",
"`user-defined-string-literal`":"user_defined_string_literal",
"`user-defined-floating-point-literal`":"user_defined_floating_point_literal",
"`user-defined-integer-literal`":"user_defined_integer_literal",
}

gram_tree = {}
Expand Down Expand Up @@ -654,7 +667,7 @@

gram_tree["static_assert-declaration"] = [
["`static_assert`", "`(`", "constant-expression", "`)`", "`;`"],
["`static_assert`", "`(`", "constant-expression", "`,`", "string-literal", "`)`", "`;`"]
["`static_assert`", "`(`", "constant-expression", "`,`", "`string-literal`", "`)`", "`;`"]
]

gram_tree["empty-declaration"] = [
Expand Down Expand Up @@ -1056,16 +1069,16 @@
]

gram_tree["asm-declaration"] = [
"attribute-specifier-seq[opt]", "`asm`", "`(`", "string-literal", "`)`", "`;`",
"attribute-specifier-seq[opt]", "`asm`", "`(`", "`string-literal`", "`)`", "`;`",
]

gram_tree["linkage-specification"] = [
["`extern`", "string-literal", "`{`", "declaration-seq[opt]", "`}`"],
["`extern`", "string-literal", "declaration"],
["`extern`", "`string-literal`", "`{`", "declaration-seq[opt]", "`}`"],
["`extern`", "`string-literal`", "declaration"],
]

gram_tree["attribute-specifier-seq"] = [
"attribute-specifier", "attribute-specifier-seq[opt]",
"attribute-specifier", "attribute-specifier-seq[opt]",
]

gram_tree["attribute-specifier"] = [
Expand Down Expand Up @@ -1310,8 +1323,8 @@
]

gram_tree["literal-operator-id"] = [
["`operator`", "string-literal", "`identifier`"],
["`operator`", "user-defined-string-literal"],
["`operator`", "`string-literal`", "`identifier`"],
["`operator`", "`user-defined-string-literal`"],
]

gram_tree["template-declaration"] = [
Expand Down Expand Up @@ -1562,7 +1575,7 @@
]

gram_tree["header-name-tokens"] = [
["string-literal"],
["`string-literal`"],
["`<`", "h-pp-tokens", "`>`"],
]

Expand Down Expand Up @@ -1605,10 +1618,10 @@
["`export`"],
["`identifier`"],
["pp-number"],
["character-literal"],
["user-defined-character-literal"],
["string-literal"],
["user-defined-string-literal"],
["`character-literal`"],
["`user-defined-character-literal`"],
["`string-literal`"],
["`user-defined-string-literal`"],
["preprocessing-op-or-punc"],
# each non-whitespace character that cannot be one of the above
]
Expand Down Expand Up @@ -1698,43 +1711,19 @@
]

gram_tree["literal"] = [
["integer-literal"],
["character-literal"],
["floating-point-literal"],
["string-literal"],
["`integer-literal`"],
["`binary-literal`"],
["`octal-literal`"],
["`decimal-literal`"],
["`hexadecimal-literal`"],
["`character-literal`"],
["`floating-point-literal`"],
["`string-literal`"],
["boolean-literal"],
["pointer-literal"],
["user-defined-literal"],
]

gram_tree["integer-literal"] = [
["binary-literal", "integer-suffix[opt]"],
["octal-literal", "integer-suffix[opt]"],
["decimal-literal", "integer-suffix[opt]"],
["hexadecimal-literal", "integer-suffix[opt]"],
]

gram_tree["binary-literal"] = [
["`0b`", "binary-digit"],
["`0B`", "`binary-digit`"],
["binary-literal", "`'`"],
["binary-literal", "`'`[opt]", "binary-digit"],
]

gram_tree["octal-literal"] = [
["`0`"],
["octal-literal", "`'`[opt]", "octal-digit"],
]

gram_tree["decimal-literal"] = [
["nonzero-digit"],
["decimal-literal", "`'`[opt]", "digit"],
]

gram_tree["hexadecimal-literal"] = [
"hexadecimal-prefix", "hexadecimal-digit-sequence",
]

gram_tree["binary-digit"] = [
["`0`"],
["`1`"],
Expand Down Expand Up @@ -1810,10 +1799,6 @@
["`ll`"], ["`LL`"],
]

gram_tree["character-literal"] = [
"encoding-prefix[opt]", "`'`","c-char-sequence", "`'`",
]

gram_tree["encoding-prefix"] = [
["`u8`"],["`u`"], ["`U`"], ["`L`"],
]
Expand Down Expand Up @@ -1851,11 +1836,6 @@
["hexadecimal-escape-sequence", "hexadecimal-digit"],
]

gram_tree["floating-point-literal"] = [
["decimal-floating-point-literal"],
["hexadecimal-floating-point-literal"],
]

gram_tree["decimal-floating-point-literal"] = [
["fractional-constant", "exponent-part[opt]", "floating-point-suffix[opt]"],
["digit-sequence", "exponent-part[opt]", "floating-point-suffix[opt]"],
Expand Down Expand Up @@ -1899,11 +1879,6 @@
["`f`"], ["`l`"], ["`F`"], ["`L`"],
]

gram_tree["string-literal"] = [
["encoding-prefix[opt]", '`"`', "s-char-sequence[opt]", '`"`'],
["encoding-prefix[opt]", '`R`', "raw-string"],
]

gram_tree["s-char-sequence"] = [
["s-char"],
["s-char-sequence", "s-char"],
Expand All @@ -1915,9 +1890,6 @@
["universal-character-name"],
]

gram_tree["raw-string"] = [
'`"`', "d-char-sequence[opt]", "`(`", "r-char-sequence[opt]" ,"`)`", "d-char-sequence[opt]", '`"`',
]

gram_tree["r-char-sequence"] = [
["r-char"],
Expand Down Expand Up @@ -1950,33 +1922,12 @@
]

gram_tree["user-defined-literal"] = [
["user-defined-integer-literal"],
["user-defined-floating-point-literal"],
["user-defined-string-literal"],
["user-defined-character-literal"],
]

gram_tree["user-defined-integer-literal"] = [
["decimal-literal", "ud-suffix"],
["octal-literal", "ud-suffix"],
["hexadecimal-literal", "ud-suffix"],
["binary-literal", "ud-suffix"],
]

gram_tree["user-defined-floating-point-literal"] = [
["fractional-constant", "exponent-part[opt]", "ud-suffix"],
["digit-sequence", "exponent-part", "ud-suffix"],
["hexadecimal-prefix", "hexadecimal-fractional-constant", "binary-exponent-part", "ud-suffix"],
["hexadecimal-prefix", "hexadecimal-digit-sequence", "binary-exponent-part", "ud-suffix"],
["`user-defined-integer-literal`"],
["`user-defined-floating-point-literal`"],
["`user-defined-string-literal`"],
["`user-defined-character-literal`"],
]

gram_tree["user-defined-string-literal"] = [
"string-literal", "ud-suffix",
]

gram_tree["user-defined-character-literal"] = [
"character-literal", "ud-suffix",
]

gram_tree["ud-suffix"] = [
"`identifier`",
Expand Down
Loading