Can't believe this works

This commit is contained in:
Roberto Alsina 2023-07-14 11:51:03 -03:00
parent 9bdbff68fb
commit accf123cd1
4 changed files with 41 additions and 8 deletions

View File

@ -10,4 +10,8 @@ test: tests.so
cgreen-runner $^ cgreen-runner $^
debug: debug:
cgreen-debug tests.so cgreen-debug tests.so
%o: %c
$(CC) -g -c -o $@ $^
shortcodes.a: shortcodes.o
ar rcs $@ $^
.PHONY: test debug .PHONY: test debug

View File

@ -5,7 +5,8 @@
// and goes on for len characters. // and goes on for len characters.
struct chunk struct chunk
{ {
unsigned int start, len; unsigned int start;
unsigned int len;
}; };
typedef struct chunk chunk; typedef struct chunk chunk;

View File

@ -1,9 +1,11 @@
require "./spec_helper" require "./spec_helper"
describe Shortcodes do describe "Shortcodes" do
# TODO: Write tests # TODO: Write tests
it "works" do it "works" do
false.should eq(true) result = Shortcodes.parse("foo{{% bar %}}baz{{% /bar %}}qux");
p! result.sccount;
p! result.shortcodes[0].matching;
end end
end end

View File

@ -1,6 +1,32 @@
# TODO: Write documentation for `Shortcodes` @[Link(ldflags: "#{__DIR__}/../shortcodes.o")]
module Shortcodes lib Shortcodes
VERSION = "0.1.0"
# TODO: Put your code here struct Chunk
end start : UInt32
len : UInt32
end
struct ScError
position: UInt32
code : UInt32
end
struct Shortcode
whole : Chunk
name : Chunk
data : Chunk
matching : LibC::Char
argnames : Chunk[100]
argvals : Chunk[100]
argcount : UInt32
end
struct ScResult
shortcodes : Shortcode[100]
sccount : UInt32
errors : ScError[10]
errcount : UInt32
end
fun parse(input : Pointer(LibC::Char)) : ScResult;
end