Skip to content

Commit

Permalink
feat(c): add support for adding source code to the program #24
Browse files Browse the repository at this point in the history
This commit adds the ability to add source code to the program in the chapi-ast-c module. The `addSource` method now takes a string representation of the source code and adds it to the program. This allows for the inclusion of C header files and other source code files.
  • Loading branch information
phodal committed Feb 1, 2024
1 parent 199ba07 commit 023fabe
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 71 deletions.
12 changes: 1 addition & 11 deletions chapi-ast-c/src/main/kotlin/chapi/ast/cast/CAnalyser.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,7 @@ open class CAnalyser : Analyser {
}

/**
* Adds a source code to the program.
*
* This method takes a string representation of the source code and adds it to the program. The source code is read from
* an input stream created from the given string. The input stream is then passed to the LexerSource object, which
* tokenizes the code and adds it to the program's input.
*
* @param code The string representation of the source code to be added.
*
* @throws IOException if an I/O error occurs while reading the source code.
*
* @see LexerSource
* Adds a source code to the program, for example, C header files.
*/
fun addSource(code: String) {
pp.addInput(LexerSource(InputStreamReader(code.byteInputStream()), true))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@ import kotlinx.coroutines.flow.asFlow
import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.flow.mapNotNull
import kotlinx.coroutines.runBlocking
import org.anarres.cpp.*
import org.junit.jupiter.api.Test
import java.io.File
import java.io.InputStreamReader
import kotlin.test.assertEquals


Expand Down
36 changes: 0 additions & 36 deletions chapi-ast-c/src/test/resources/realworld/SlowMacro.c

This file was deleted.

22 changes: 0 additions & 22 deletions chapi-ast-c/src/test/resources/realworld/SlowMacro2.h

This file was deleted.

0 comments on commit 023fabe

Please sign in to comment.