Skip to content

Commit

Permalink
checkpoint, partly converted to latest hancho
Browse files Browse the repository at this point in the history
  • Loading branch information
aappleby committed Oct 19, 2024
1 parent ce803bb commit f7f6075
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 38 deletions.
26 changes: 12 additions & 14 deletions build.hancho
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
# matcheroni/build.hancho

import hancho
hancho.build_tag = "debug"
hancho.rules = hancho.load("symlinks/hancho/rules.hancho")
hancho.includes = [".", "{repo_dir}"]

hancho.Config.build_tag = "debug"
c_lexer = hancho.load("examples/c_lexer/c_lexer.hancho")
c_parser = hancho.load("examples/c_parser/c_parser.hancho", c_lexer = c_lexer)
json = hancho.load("examples/json/json.hancho")
#regex = hancho.load("examples/regex/regex.hancho")
#toml = hancho.load("examples/toml/toml.hancho")
#tests = hancho.load("tests/tests.hancho")
#tutorial = hancho.load("examples/tutorial/tutorial.hancho", c_lexer = c_lexer, c_parser = c_parser)

rules = hancho.load("symlinks/hancho/rules.hancho", exports)
rules.compile_cpp.includes = [".", "{repo_path}"]

c_lexer = hancho.load("examples/c_lexer/c_lexer.hancho", rules = rules)
c_parser = hancho.load("examples/c_parser/c_parser.hancho", rules = rules, c_lexer = c_lexer)
json = hancho.load("examples/json/json.hancho", rules = rules)
regex = hancho.load("examples/regex/regex.hancho", rules = rules)
toml = hancho.load("examples/toml/toml.hancho", rules = rules)
tests = hancho.load("tests/tests.hancho", rules = rules)
tutorial = hancho.load("examples/tutorial/tutorial.hancho", rules = rules, c_lexer = c_lexer, c_parser = c_parser)

ini = rules.cpp_lib(
ini = hancho(
hancho.rules.cpp_lib,
name = "ini_parser",
in_srcs = "examples/ini/ini_parser.cpp",
)
19 changes: 11 additions & 8 deletions examples/c_lexer/c_lexer.hancho
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
#-------------------------------------------------------------------------------
# Matcheroni C lexer demo

c_lexer = imports.rules.cpp_lib(
name = "c_lexer",
rules = hancho.pop('rules')

lib = hancho(
rules.cpp_lib,
name = "c_lexer.a",
in_srcs = ["CLexer.cpp", "CToken.cpp"],
)

imports.rules.c_test(
hancho(
rules.cpp_test,
name = "c_lexer_test",
in_srcs = "c_lexer_test.cpp",
in_libs = c_lexer,
in_libs = lib,
)

imports.rules.cpp_bin(
hancho(
rules.cpp_bin,
name = "c_lexer_benchmark",
in_srcs = "c_lexer_benchmark.cpp",
in_libs = c_lexer,
in_libs = lib,
)

exports.lib = c_lexer
13 changes: 8 additions & 5 deletions examples/c_parser/c_parser.hancho
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
#-------------------------------------------------------------------------------
# C parser example (not finished)

c_parser = imports.rules.cpp_lib(
rules = hancho.pop('rules')
c_lexer = hancho.pop('c_lexer')

lib = hancho(
rules.cpp_lib,
name = "c_parser",
in_srcs = ["CContext.cpp", "CNode.cpp", "CScope.cpp"],
)

imports.rules.cpp_bin(
hancho(
rules.cpp_bin,
name = "c_parser_benchmark",
in_srcs = "c_parser_benchmark.cpp",
in_libs = [imports.c_lexer.lib, c_parser],
in_libs = [c_lexer.lib, lib],
)

# Broken?
Expand All @@ -18,5 +23,3 @@ imports.rules.cpp_bin(
# "c_parser_test",
# libs = [c_lexer.c_lexer_lib, c_parser_lib],
#)

exports.lib = c_parser
27 changes: 16 additions & 11 deletions examples/json/json.hancho
Original file line number Diff line number Diff line change
@@ -1,33 +1,38 @@
#-------------------------------------------------------------------------------
# Matcheroni JSON parser example

json_parser = imports.rules.cpp_lib(
rules = hancho.pop('rules')

lib = hancho(
rules.cpp_lib,
name = "json_parser",
in_srcs = ["json_matcher.cpp", "json_parser.cpp"],
)

imports.rules.cpp_bin(
hancho(
rules.cpp_bin,
name = "json_conformance",
in_srcs = "json_conformance.cpp",
in_libs = json_parser,
in_libs = lib,
)

imports.rules.cpp_bin(
hancho(
rules.cpp_bin,
name = "json_benchmark",
in_srcs = "json_benchmark.cpp",
in_libs = json_parser,
in_libs = lib,
)

imports.rules.cpp_bin(
hancho(
rules.cpp_bin,
name = "json_demo",
in_srcs = "json_demo.cpp",
in_libs = json_parser,
in_libs = lib,
)

imports.rules.c_test(
hancho(
rules.cpp_test,
name = "json_test",
in_srcs = "json_test.cpp",
in_libs = json_parser,
in_libs = lib,
)

exports.lib = json_parser

0 comments on commit f7f6075

Please sign in to comment.