tomhrr / dale

Lisp-flavoured C
BSD 3-Clause "New" or "Revised" License
1.03k stars 48 forks source link

Enable parsing files with dale-syntas at compile-time #99

Closed porky11 closed 8 years ago

porky11 commented 8 years ago

Include only works at toplevel so I'd like a function working like this:

;;;;example-file
a
(b)
"c"
;;;;my-program.dale
(parse-file "example-file") ;;returns (a (b) "c")
;;or
(some-parsing-macro "example-file") ;;may expand to (do a (b) "c")

I could save my shaders in seperate files, and read at compile-time then. (Edit: For just parsing strings, this is too complicated) Adding a single function, that takes a stream and returns a pointer to the next DNode, which is null, when error or end of file

tomhrr commented 8 years ago

On Wed, Sep 14, 2016 at 02:33:04AM -0700, Fabio Krapohl wrote:

Include only works at toplevel so I'd like a function working like this:

;;;;example-file a (b) "c"

;;;;my-program.dale (parse-file "example-file") ;;returns (a (b) "c") ;;or (some-parsing-macro "example-file") ;;may expand to (do a (b) "c")

I could save my shaders in seperate files, and read at compile-time then. Adding a single function, that takes a stream and returns a pointer to the next DNode, which is null, when error or end of file

'include' now works within procedures as well as at the toplevel, mainly because bringing it within the compiler allows for parsing error messages to be consistent with the existing ones. Please let me know if this is problematic.