[ClangAstParser] Adds support for whitespace between # and pragma
@@ -79,8 +79,11 @@ public class SnippetParser {
}
// String pragmaPrefix = extractPragmaPrefix(currentCode);
- if (lowerCurrentCode.startsWith("#pragma ")) {
- String pragmaContent = currentCode.substring("#pragma ".length());
+ if (lowerCurrentCode.startsWith("#")) {
+ String pragmaContent = currentCode.substring("#".length());
+ pragmaContent = pragmaContent.stripLeading();
+ if (pragmaContent.startsWith("pragma ")) {
+ pragmaContent = pragmaContent.substring("pragma ".length());
// Split pragmaContent into lines, in case it is multiline
List<String> pragmaLines = pragmaContent.lines()
@@ -103,6 +106,7 @@ public class SnippetParser {
return ClavaNodes.toStmt(pragma);
*/
}
+ }
if (lowerCurrentCode.startsWith("_pragma")) {
String pragmaContent = currentCode.substring("_pragma".length());
