mirror of
https://github.com/RubyMetric/chsrc
synced 2026-01-10 16:01:57 +08:00
Update lib
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env raku
|
#!/usr/bin/env raku
|
||||||
# ---------------------------------------------------------------
|
# ---------------------------------------------------------------
|
||||||
# File Name : CGenerator.rakumod
|
# File Name : Generator.rakumod
|
||||||
# File Authors : Aoran Zeng <ccmywish@qq.com>
|
# File Authors : Aoran Zeng <ccmywish@qq.com>
|
||||||
# Contributors : Nul None <nul@none.org>
|
# Contributors : Nul None <nul@none.org>
|
||||||
# Created On : <2025-07-12>
|
# Created On : <2025-07-12>
|
||||||
@@ -9,11 +9,11 @@
|
|||||||
# Generates C code from raw string
|
# Generates C code from raw string
|
||||||
# ---------------------------------------------------------------
|
# ---------------------------------------------------------------
|
||||||
|
|
||||||
unit module CGenerator;
|
unit module Generator;
|
||||||
|
|
||||||
use ConfigParser;
|
use Parser;
|
||||||
|
|
||||||
class CStringConverter {
|
my class CStringConverter {
|
||||||
|
|
||||||
method convert-char($char, $mode) {
|
method convert-char($char, $mode) {
|
||||||
given $mode {
|
given $mode {
|
||||||
@@ -51,7 +51,7 @@ class CStringConverter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class CVariableNameGenerator {
|
my class CVariableNameGenerator {
|
||||||
|
|
||||||
method generate($global-config, $section-config, $title) {
|
method generate($global-config, $section-config, $title) {
|
||||||
|
|
||||||
@@ -95,7 +95,7 @@ class CVariableNameGenerator {
|
|||||||
|
|
||||||
|
|
||||||
#| 生成 .h 文件或/和 .c 文件,或存储到 @variables 中
|
#| 生成 .h 文件或/和 .c 文件,或存储到 @variables 中
|
||||||
class CVariableGenerator {
|
my class CVariableGenerator {
|
||||||
has @.variables;
|
has @.variables;
|
||||||
has $.c-header-filename;
|
has $.c-header-filename;
|
||||||
|
|
||||||
@@ -9,14 +9,12 @@
|
|||||||
# rawstr4c.md parsing
|
# rawstr4c.md parsing
|
||||||
# ---------------------------------------------------------------
|
# ---------------------------------------------------------------
|
||||||
|
|
||||||
unit module Rawstr4C;
|
unit module Parser;
|
||||||
|
|
||||||
# 不能用 Bool,只能用 Boolean
|
#| 不能用 Bool,只能用 Boolean
|
||||||
my enum ConfigValueType <String Mode Boolean>;
|
my enum ConfigValueType <String Mode Boolean>;
|
||||||
|
|
||||||
#
|
#| 配置项的值
|
||||||
# @brief 配置项的值
|
|
||||||
#
|
|
||||||
my class ConfigValue {
|
my class ConfigValue {
|
||||||
has ConfigValueType $.type;
|
has ConfigValueType $.type;
|
||||||
has $.raw-value;
|
has $.raw-value;
|
||||||
@@ -74,9 +72,8 @@ my class ConfigValue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#
|
|
||||||
# @brief 承载 config items 的容器
|
#| 包含所有 config items 的容器
|
||||||
#
|
|
||||||
my class Config {
|
my class Config {
|
||||||
|
|
||||||
has %.items;
|
has %.items;
|
||||||
@@ -100,9 +97,7 @@ my class Config {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
=begin comment
|
#|( 仅存在两个域:
|
||||||
|
|
||||||
仅存在两个域:
|
|
||||||
|
|
||||||
1. Global dom
|
1. Global dom
|
||||||
2. Section dom
|
2. Section dom
|
||||||
@@ -111,15 +106,14 @@ my class Config {
|
|||||||
|
|
||||||
因此,Parser 解析完毕后将包含:
|
因此,Parser 解析完毕后将包含:
|
||||||
- $global-config
|
- $global-config
|
||||||
- @sections
|
- @sections (多个 $section)
|
||||||
|
|
||||||
一个 section 包含:
|
一个 $section 是 Hash,其包含:
|
||||||
- title
|
- title
|
||||||
- level
|
- level
|
||||||
- raw-string
|
- raw-string
|
||||||
- config (Config 对象)
|
- config
|
||||||
|
)
|
||||||
=end comment
|
|
||||||
class Parser {
|
class Parser {
|
||||||
has $.global-config;
|
has $.global-config;
|
||||||
has @.sections;
|
has @.sections;
|
||||||
|
|||||||
Reference in New Issue
Block a user