diff --git a/src/Conversion/template.jl b/src/Conversion/template.jl index 419e1b1..858e10e 100644 --- a/src/Conversion/template.jl +++ b/src/Conversion/template.jl @@ -328,7 +328,7 @@ function register_parser_string_flag_macro(expr::Expr) push!( blk.args, :(Conversion.get_parser_from_flag(::Val{$flag_symbol})::TAbstractParser = $parser_symbol) - ) + ) end end diff --git a/src/Narsese/terms.jl b/src/Narsese/terms.jl index dfc1622..35d6812 100644 --- a/src/Narsese/terms.jl +++ b/src/Narsese/terms.jl @@ -193,7 +193,7 @@ abstract type AbstractCompound{type <: AbstractCompoundType} <: AbstractTerm end function terms end "[NAL-1]陈述词项の基石 | 协议:支持`terms`、`ϕ1`和`ϕ2`方法(无需绑定属性)" -abstract type AbstractStatement <: AbstractTerm end +abstract type AbstractStatement{type <: AbstractStatementType} <: AbstractTerm end function ϕ1 end; function ϕ2 end # 具体结构定义 @@ -749,7 +749,7 @@ begin "陈述词项" > (3)为了简化语言,「T \⇔ S」总是被表示为「S /⇔ T」,所以关联词「\⇔」实际上并不在Narsese语法中。 > - 译者注:此举与先前的「外延并/内涵并」类似 """ - struct Statement{type <: AbstractStatementType} <: AbstractStatement + struct Statement{type <: AbstractStatementType} <: AbstractStatement{type} ϕ1::AbstractTerm # subject 主词 ϕ2::AbstractTerm # predicate 谓词 diff --git a/test/test_narsese.jl b/test/test_narsese.jl index 403e765..099842e 100644 --- a/test/test_narsese.jl +++ b/test/test_narsese.jl @@ -17,6 +17,9 @@ # 构造 # include("test_construction.jl") + # 类型 # + include("test_types.jl") + # 词项与数组等可迭代对象的联动方法 # include("test_methods.jl") diff --git a/test/test_types.jl b/test/test_types.jl new file mode 100644 index 0000000..6a5948f --- /dev/null +++ b/test/test_types.jl @@ -0,0 +1,33 @@ +(@isdefined JuNarsese) || include("commons.jl") # 已在此中导入JuNarsese、Test + +@testset "types" begin + + # 测试各类「抽象类型」 + @test Intension <: AbstractEI >: Extension + @test And <: AbstractLogicOperation >: Or + @test Not <: AbstractLogicOperation + @test VTIndependent <: AbstractVariableType + @test Sequential <: AbstractTemporalRelation >: Parallel + + # 测试「原子词项」 + @test Word <: Atom <: Term + @test IVar <: Variable{VTIndependent} <: Var <: Variable <: Atom <: Term + + # 测试「复合词项类型」 + @test CompoundTypeTermProduct <: AbstractCompoundType + CompoundTypeTermImage{Extension} <: CompoundTypeTermImage + + @test TermProduct <: CommonCompound{CompoundTypeTermProduct} <: AbstractCompound{CompoundTypeTermProduct} <: AbstractCompound <: AbstractTerm + @test TermProduct <: CommonCompound{CompoundTypeTermProduct} <: CommonCompound <: AbstractCompound <: AbstractTerm + @test ExtImage <: TermImage{Extension} <: AbstractCompound{CompoundTypeTermImage{Extension}} <: AbstractCompound{CompoundTypeTermImage{Extension}} <: AbstractCompound + @test IntImage <: TermImage{Intension} <: TermImage <: AbstractCompound + + # 测试「陈述类型」 + @test STInheritance <: AbstractStatementType + @test STImplication <: StatementTypeImplication{Eternal} <: StatementTypeImplication <: AbstractStatementType + @test STEquivalence <: StatementTypeEquivalence{Eternal} <: StatementTypeEquivalence <: AbstractStatementType + + @test Inheritance <: Statement{STInheritance} <: AbstractStatement{StatementTypeInheritance} <: AbstractStatement <: AbstractTerm + @test Inheritance <: Statement{STInheritance} <: Statement <: AbstractStatement <: AbstractTerm + +end