chore: fix style
This commit is contained in:
parent
1120374505
commit
dfc9815e83
2 changed files with 20 additions and 11 deletions
|
@ -4,7 +4,7 @@
|
|||
<component name="FrameworkDetectionExcludesConfiguration">
|
||||
<file type="web" url="file://$PROJECT_DIR$" />
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_22" default="true" project-jdk-name="openjdk-22" project-jdk-type="JavaSDK">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_23" default="true" project-jdk-name="openjdk-22" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
|
@ -11,6 +11,15 @@ class SourceFile {
|
|||
companion object {
|
||||
val function_define_regex = """\b([a-zA-Z_][a-zA-Z0-9_]*)\s*\([^)]*\)\s*\{""".toRegex() // main(){ 匹配函数名
|
||||
|
||||
/**
|
||||
* C文件预处理器
|
||||
* 处理内容:
|
||||
* 删除注释;
|
||||
* 处理 #define;
|
||||
* 处理连续创建变量;
|
||||
* 格式化代码
|
||||
* @return 处理好的C源代码
|
||||
*/
|
||||
fun formatSource(src: String): String {
|
||||
// 去掉注释
|
||||
val noComment = src.lines()
|
||||
|
@ -142,7 +151,7 @@ class SourceFile {
|
|||
}
|
||||
|
||||
constructor(content: String) {
|
||||
this.content = formatSource(content.trim())
|
||||
this.content = formatSource(content)
|
||||
}
|
||||
|
||||
fun parseFunction(): List<CFunction> { // 找所有的函数定义
|
||||
|
|
Loading…
Reference in a new issue