├── .clang-format ├── .dockerignore ├── .github └── workflows │ └── build.yml ├── .gitignore ├── CMakeLists.txt ├── Changes ├── Dockerfile ├── LICENCE ├── README.md ├── bin └── size-check ├── doc ├── 1-1-introduction.md ├── 1-10-modules.md ├── 1-11-form-reference.md ├── 1-12-repl.md ├── 1-13-tools.md ├── 1-2-setup.md ├── 1-3-types.md ├── 1-4-variables.md ├── 1-5-functions.md ├── 1-6-control-flow.md ├── 1-7-macros.md ├── 1-8-init-destroy.md ├── 1-9-namespaces.md ├── 2-1-introspection.md ├── 2-10-utility.md ├── 2-11-derivations.md ├── 2-12-algorithms.md ├── 2-13-list.md ├── 2-14-vector.md ├── 2-15-set.md ├── 2-16-map.md ├── 2-17-array.md ├── 2-18-shared-ptr.md ├── 2-19-unique-ptr.md ├── 2-2-ctype.md ├── 2-20-operator-macros.md ├── 2-21-enum.md ├── 2-22-bitset-enum.md ├── 2-23-variant.md ├── 2-3-math.md ├── 2-4-macros.md ├── 2-5-stdlib.md ├── 2-6-assert.md ├── 2-7-concepts-core.md ├── 2-8-concept-defs.md ├── 2-9-concepts.md ├── 3-1-cerrno.md ├── 3-10-cstring.md ├── 3-11-cctype.md ├── 3-12-csetjmp.md ├── 3-2-cfloat.md ├── 3-3-clocale.md ├── 3-4-cmath.md ├── 3-5-csignal.md ├── 3-6-cstdio-core.md ├── 3-7-cstdio.md ├── 3-8-ctime.md ├── 3-9-cstdlib.md ├── all.md └── index.md ├── eg ├── dale-autowrap │ ├── c2dale.sh │ ├── dale-autowrap │ └── t │ │ ├── 001-headers.t │ │ ├── 002-casing.t │ │ ├── 003-namespace.t │ │ ├── 004-namespace-single.t │ │ ├── 005-casing-single.t │ │ ├── 006-type-with-use.t │ │ ├── 007-ns-type-with-use.t │ │ ├── 008-struct-members.t │ │ └── headers │ │ ├── casing.h │ │ ├── casing.h.dt │ │ ├── define.h │ │ ├── define.h.dt │ │ ├── enum.h │ │ ├── enum.h.dt │ │ ├── file.h │ │ ├── file.h.dt │ │ ├── fn-array-param.h │ │ ├── fn-array-param.h.dt │ │ ├── function.h │ │ ├── function.h.dt │ │ ├── namespace.h │ │ ├── namespace.h.dt │ │ ├── ns-type-with-use.h │ │ ├── ns-type-with-use.h.dt │ │ ├── original-first.h │ │ ├── original-first.h.dt │ │ ├── static.h │ │ ├── static.h.dt │ │ ├── struct-members.h │ │ ├── struct-members.h.dt │ │ ├── struct.h │ │ ├── struct.h.dt │ │ ├── type-with-use.h │ │ ├── type-with-use.h.dt │ │ ├── typedef-multiple.h │ │ ├── typedef-multiple.h.dt │ │ ├── typedef-struct.h │ │ ├── typedef-struct.h.dt │ │ ├── typedef.h │ │ ├── typedef.h.dt │ │ ├── union.h │ │ ├── union.h.dt │ │ ├── variable.h │ │ └── variable.h.dt ├── def-type │ └── def-type.dt ├── doc │ ├── anonymous-functions.dt │ ├── containers.dt │ ├── derivations.dt │ ├── error-reporting.dt │ ├── hello-name.dt │ ├── hello-world.dt │ ├── introspection.dt │ ├── macros.dt │ ├── overloading.dt │ ├── type-deduction.dt │ ├── typed-macros.dt │ └── variants.dt ├── github-107 │ └── github-107.dt ├── github-118 │ └── github-118.dt ├── glut-example │ └── glut-example.dt ├── maybe │ └── maybe.dt └── module-to-markdown │ └── module-to-markdown.dt ├── generate-docs ├── man ├── dalec.1.gz └── daleci.1.gz ├── modules ├── algorithms.dt ├── arithmetic.dt ├── array.dt ├── assert.dt ├── bitset-enum.dt ├── cctype.dt ├── cerrno.dt ├── cfloat.dt ├── clocale.dt ├── cmath.dt ├── concept-defs.dt ├── concepts-core.dt ├── concepts.dt ├── csetjmp.dt ├── csignal.dt ├── cstdio-core.dt ├── cstdio.dt ├── cstdlib.dt ├── cstring.dt ├── ctime.dt ├── ctype.dt ├── darwin │ ├── cerrno-arch.dt │ └── cstdio-arch.dt ├── derivations.dt ├── drt.dt ├── enum.dt ├── freebsd │ ├── cerrno-arch.dt │ └── cstdio-arch.dt ├── introspection.dt ├── linux │ ├── cerrno-arch.dt │ └── cstdio-arch.dt ├── list.dt ├── macros.dt ├── map.dt ├── math.dt ├── operator-macros.dt ├── pthread.dt ├── set.dt ├── shared-ptr.dt ├── stdlib.dt ├── unique-ptr.dt ├── unistd.dt ├── utility.dt ├── variant.dt └── vector.dt ├── run-tests ├── src ├── Doxyfile └── dale │ ├── Arch │ ├── Arch.cpp │ └── Arch.h │ ├── BaseType │ ├── BaseType.cpp │ └── BaseType.h │ ├── BasicTypes │ ├── BasicTypes.cpp │ └── BasicTypes.h │ ├── CommonDecl │ ├── CommonDecl.cpp │ └── CommonDecl.h │ ├── Config.h.in │ ├── Context │ ├── Context.cpp │ └── Context.h │ ├── ContextSavePoint │ ├── ContextSavePoint.cpp │ └── ContextSavePoint.h │ ├── CoreForms │ ├── CoreForms.cpp │ └── CoreForms.h │ ├── DNodeConverter │ ├── DNodeConverter.cpp │ └── DNodeConverter.h │ ├── Decoder │ ├── Decoder.cpp │ └── Decoder.h │ ├── DeferredGoto │ └── DeferredGoto.h │ ├── Error │ ├── Error.cpp │ └── Error.h │ ├── ErrorReporter │ ├── ErrorReporter.cpp │ └── ErrorReporter.h │ ├── ErrorType │ ├── ErrorType.cpp │ └── ErrorType.h │ ├── Form │ ├── Function │ │ ├── Function.cpp │ │ └── Function.h │ ├── Initialiser │ │ ├── Array │ │ │ ├── Array.cpp │ │ │ └── Array.h │ │ └── Struct │ │ │ ├── Struct.cpp │ │ │ └── Struct.h │ ├── Linkage │ │ ├── Linkage.cpp │ │ ├── Linkage.h │ │ └── Struct │ │ │ ├── Struct.cpp │ │ │ └── Struct.h │ ├── Literal │ │ ├── Literal.cpp │ │ └── Literal.h │ ├── Macro │ │ ├── ArrayDeref │ │ │ ├── ArrayDeref.cpp │ │ │ └── ArrayDeref.h │ │ ├── DerefStruct │ │ │ ├── DerefStruct.cpp │ │ │ └── DerefStruct.h │ │ ├── DerefStructDeref │ │ │ ├── DerefStructDeref.cpp │ │ │ └── DerefStructDeref.h │ │ ├── Setv │ │ │ ├── Setv.cpp │ │ │ └── Setv.h │ │ └── StructDeref │ │ │ ├── StructDeref.cpp │ │ │ └── StructDeref.h │ ├── Parameter │ │ ├── Parameter.cpp │ │ └── Parameter.h │ ├── Proc │ │ ├── AddressOf │ │ │ ├── AddressOf.cpp │ │ │ └── AddressOf.h │ │ ├── Alignmentof │ │ │ ├── Alignmentof.cpp │ │ │ └── Alignmentof.h │ │ ├── Aref │ │ │ ├── Aref.cpp │ │ │ └── Aref.h │ │ ├── ArrayOf │ │ │ ├── ArrayOf.cpp │ │ │ └── ArrayOf.h │ │ ├── Cast │ │ │ ├── Cast.cpp │ │ │ └── Cast.h │ │ ├── Def │ │ │ ├── Def.cpp │ │ │ └── Def.h │ │ ├── Dereference │ │ │ ├── Dereference.cpp │ │ │ └── Dereference.h │ │ ├── Do │ │ │ ├── Do.cpp │ │ │ └── Do.h │ │ ├── Funcall │ │ │ ├── Funcall.cpp │ │ │ └── Funcall.h │ │ ├── Goto │ │ │ ├── Goto.cpp │ │ │ └── Goto.h │ │ ├── If │ │ │ ├── If.cpp │ │ │ └── If.h │ │ ├── Include │ │ │ ├── Include.cpp │ │ │ └── Include.h │ │ ├── Inst │ │ │ ├── Inst.cpp │ │ │ └── Inst.h │ │ ├── Label │ │ │ ├── Label.cpp │ │ │ └── Label.h │ │ ├── Move │ │ │ ├── Move.cpp │ │ │ └── Move.h │ │ ├── NewScope │ │ │ ├── NewScope.cpp │ │ │ └── NewScope.h │ │ ├── Null │ │ │ ├── Null.cpp │ │ │ └── Null.h │ │ ├── NullPtr │ │ │ ├── NullPtr.cpp │ │ │ └── NullPtr.h │ │ ├── Offsetof │ │ │ ├── Offsetof.cpp │ │ │ └── Offsetof.h │ │ ├── PtrAdd │ │ │ ├── PtrAdd.cpp │ │ │ └── PtrAdd.h │ │ ├── PtrEquals │ │ │ ├── PtrEquals.cpp │ │ │ └── PtrEquals.h │ │ ├── PtrGreaterThan │ │ │ ├── PtrGreaterThan.cpp │ │ │ └── PtrGreaterThan.h │ │ ├── PtrLessThan │ │ │ ├── PtrLessThan.cpp │ │ │ └── PtrLessThan.h │ │ ├── PtrSubtract │ │ │ ├── PtrSubtract.cpp │ │ │ └── PtrSubtract.h │ │ ├── Quote │ │ │ ├── Quote.cpp │ │ │ └── Quote.h │ │ ├── Return │ │ │ ├── Return.cpp │ │ │ └── Return.h │ │ ├── Setf │ │ │ ├── Setf.cpp │ │ │ └── Setf.h │ │ ├── Sizeof │ │ │ ├── Sizeof.cpp │ │ │ └── Sizeof.h │ │ ├── Sref │ │ │ ├── Sref.cpp │ │ │ └── Sref.h │ │ ├── Token │ │ │ ├── Token.cpp │ │ │ └── Token.h │ │ ├── UsingNamespace │ │ │ ├── UsingNamespace.cpp │ │ │ └── UsingNamespace.h │ │ ├── VaArg │ │ │ ├── VaArg.cpp │ │ │ └── VaArg.h │ │ ├── VaEnd │ │ │ ├── VaEnd.cpp │ │ │ └── VaEnd.h │ │ └── VaStart │ │ │ ├── VaStart.cpp │ │ │ └── VaStart.h │ ├── ProcBody │ │ ├── ProcBody.cpp │ │ └── ProcBody.h │ ├── Struct │ │ ├── Struct.cpp │ │ └── Struct.h │ ├── TopLevel │ │ ├── Def │ │ │ ├── Def.cpp │ │ │ └── Def.h │ │ ├── Do │ │ │ ├── Do.cpp │ │ │ └── Do.h │ │ ├── Function │ │ │ ├── Function.cpp │ │ │ └── Function.h │ │ ├── GlobalVariable │ │ │ ├── GlobalVariable.cpp │ │ │ └── GlobalVariable.h │ │ ├── Import │ │ │ ├── Import.cpp │ │ │ └── Import.h │ │ ├── Include │ │ │ ├── Include.cpp │ │ │ └── Include.h │ │ ├── Inst │ │ │ ├── Inst.cpp │ │ │ └── Inst.h │ │ ├── Macro │ │ │ ├── Macro.cpp │ │ │ └── Macro.h │ │ ├── Module │ │ │ ├── Module.cpp │ │ │ └── Module.h │ │ ├── Namespace │ │ │ ├── Namespace.cpp │ │ │ └── Namespace.h │ │ ├── Struct │ │ │ ├── Struct.cpp │ │ │ └── Struct.h │ │ └── UsingNamespace │ │ │ ├── UsingNamespace.cpp │ │ │ └── UsingNamespace.h │ ├── Type │ │ ├── Type.cpp │ │ └── Type.h │ ├── Utils │ │ ├── Utils.cpp │ │ └── Utils.h │ └── Value │ │ ├── Value.cpp │ │ └── Value.h │ ├── Function │ ├── Function.cpp │ └── Function.h │ ├── FunctionProcessor │ ├── FunctionProcessor.cpp │ └── FunctionProcessor.h │ ├── Generator │ ├── Generator.cpp │ └── Generator.h │ ├── Introspection │ ├── Introspection.cpp │ └── Introspection.h │ ├── Label │ ├── Label.cpp │ └── Label.h │ ├── Lexer │ ├── Lexer.cpp │ └── Lexer.h │ ├── Linkage │ ├── Linkage.cpp │ └── Linkage.h │ ├── MacroProcessor │ ├── MacroProcessor.cpp │ └── MacroProcessor.h │ ├── Module │ ├── Reader │ │ ├── Reader.cpp │ │ └── Reader.h │ └── Writer │ │ ├── Writer.cpp │ │ └── Writer.h │ ├── Namespace │ ├── Namespace.cpp │ └── Namespace.h │ ├── NamespaceSavePoint │ ├── NamespaceSavePoint.cpp │ └── NamespaceSavePoint.h │ ├── NativeTypes │ ├── NativeTypes.cpp │ └── NativeTypes.h │ ├── Node │ ├── Node.cpp │ └── Node.h │ ├── Operation │ ├── Alignmentof │ │ ├── Alignmentof.cpp │ │ └── Alignmentof.h │ ├── Cast │ │ ├── Cast.cpp │ │ └── Cast.h │ ├── CloseScope │ │ ├── CloseScope.cpp │ │ └── CloseScope.h │ ├── Coerce │ │ ├── Coerce.cpp │ │ └── Coerce.h │ ├── Copy │ │ ├── Copy.cpp │ │ └── Copy.h │ ├── Destruct │ │ ├── Destruct.cpp │ │ └── Destruct.h │ ├── Move │ │ ├── Move.cpp │ │ └── Move.h │ ├── Offsetof │ │ ├── Offsetof.cpp │ │ └── Offsetof.h │ └── Sizeof │ │ ├── Sizeof.cpp │ │ └── Sizeof.h │ ├── ParseResult │ ├── ParseResult.cpp │ └── ParseResult.h │ ├── Parser │ ├── Parser.cpp │ └── Parser.h │ ├── Position │ ├── Position.cpp │ └── Position.h │ ├── REPL │ ├── REPL.cpp │ └── REPL.h │ ├── STL │ └── STL.h │ ├── SavePoint │ ├── SavePoint.cpp │ └── SavePoint.h │ ├── Serialise │ ├── Serialise.cpp │ └── Serialise.h │ ├── Struct │ ├── Struct.cpp │ └── Struct.h │ ├── Token │ ├── Token.cpp │ └── Token.h │ ├── TokenType │ ├── TokenType.cpp │ └── TokenType.h │ ├── Type │ ├── Type.cpp │ └── Type.h │ ├── TypeMap │ ├── TypeMap.cpp │ └── TypeMap.h │ ├── TypeRegister │ ├── TypeRegister.cpp │ └── TypeRegister.h │ ├── Unit │ ├── Unit.cpp │ └── Unit.h │ ├── Units │ ├── Units.cpp │ └── Units.h │ ├── Utils │ ├── Utils.cpp │ └── Utils.h │ ├── Variable │ ├── Variable.cpp │ └── Variable.h │ ├── dalec.cpp │ ├── daleci.cpp │ ├── incl.pl │ ├── llvmUtils │ ├── llvmUtils.cpp │ └── llvmUtils.h │ ├── llvm_AnalysisVerifier.h │ ├── llvm_AssemblyPrintModulePass.h │ ├── llvm_CallingConv.h │ ├── llvm_Function.h │ ├── llvm_IRBuilder.h │ ├── llvm_LLVMContext.h │ ├── llvm_LinkAll.h │ ├── llvm_Linker.h │ ├── llvm_Module.h │ ├── llvm_PassManager.h │ └── llvm_ValueSymbolTable.h ├── t ├── 001basic │ ├── 001empty-main.t │ ├── 002hello-world.t │ ├── 003main-with-args.t │ ├── 004hello-name.t │ ├── 005include.t │ ├── 006stack-vars.t │ ├── 007setf-stack-vars.t │ ├── 008pointers.t │ ├── 009labels-2.t │ ├── 010labels.t │ ├── 011struct.t │ ├── 012globals.t │ ├── 013bools.t │ ├── 014arrays.t │ ├── 015malloc.t │ ├── 016free.t │ ├── 017sr-struct.t │ ├── 018do.t │ ├── 019nested-ifs.t │ ├── 020varargs.t │ ├── 021implicit-return.t │ ├── 022once.t │ ├── 023char.t │ ├── 024ptr-math.t │ ├── 026tl-do.t │ ├── 027ptr-operations.t │ ├── 028fn-pointers.t │ ├── 029two-branches.t │ ├── 030fn-arg-collision.t │ ├── 031varargs-more.t │ ├── 032bitwise.t │ ├── 033intdefs.t │ ├── 034float-double.t │ ├── 035float-double-cast.t │ ├── 036int-proper.t │ ├── 037opaque-struct.t │ ├── 038opaque-struct-redef.t │ ├── 039opaque-struct-redef-2.t │ ├── 040mr-struct.t │ ├── 041mr-fn.t │ ├── 042md-arrays.t │ ├── 043sizeof-array.t │ ├── 044array-params.t │ ├── 045address-of-va-fn.t │ ├── 046array-address.t │ ├── 047struct-init.t │ ├── 048struct-literals.t │ ├── 049array-literal-md.t │ ├── 050array-literal-simple.t │ ├── 051files.t │ ├── 052hex-literals.t │ ├── 053void-fnptr.t │ ├── 054extern-c-coerce.t │ ├── 055float-problem.t │ ├── 056struct-rec-problem.t │ ├── 057sizeof-problem.t │ ├── 058sizeof-array-problem.t │ ├── 059ml-comment.t │ ├── 060nullptr.t │ ├── 061sref-on-fn.t │ ├── 062anon-fn.t │ ├── 063multiple.t │ ├── 064offsetof.t │ ├── 065gstruct-padding.t │ ├── 066gint.t │ ├── 067gstruct.t │ ├── 068gstring.t │ ├── 069if-struct.t │ ├── 070struct-casting.t │ ├── 071no-intern-init.t │ ├── 072ret-problem.t │ ├── 073array-literal-fc.t │ ├── 074implicit-funcall.t │ ├── 077struct-deref.t │ ├── 078link-bc.t │ ├── 079negative-fp.t │ ├── 080extern-var.t │ ├── 081anon-struct.t │ ├── 082long-double.t │ ├── 083anon-array-struct.t │ ├── 084global-ptr-sc.t │ ├── 085int-array-global.t │ ├── 086refs-basic.t │ ├── 087refs-const.t │ ├── 088refs-no-copy.t │ ├── 089retval-basic.t │ ├── 090retval-do.t │ ├── 091retval-unneeded.t │ ├── 092retval-nested.t │ ├── 093refs-fnptr.t │ ├── 094refs-fnptr-exp.t │ ├── 095retval-fnptr.t │ ├── 096retval-fnptr-refs.t │ ├── 097refs-pass.t │ ├── 098refs-no-copy-var.t │ ├── 099def-refs-implicit.t │ ├── 100implicit-no-copy.t │ ├── 101retval-setf.t │ ├── 102set-const-struct-member.t │ ├── 103const-ptrs.t │ ├── 104const-parameters.t │ ├── 105hello-samename.t │ ├── 106rv-refs-simple.t │ ├── 107rv-refs-use-simple.t │ ├── 108rv-refs-move.t │ ├── 109rv-refs-setf-move.t │ ├── 110rv-refs-no-copy.t │ ├── 111const-global.t │ ├── 112ml-comment-nested.t │ ├── 113void-if.t │ ├── 114if-branches-different.t │ ├── 116void-if-nested.t │ ├── 117modulus.t │ ├── 118aref-problem.t │ ├── 120intern-in-fn-explicit.t │ ├── 121intern-in-fn-explicit-expr.t │ ├── 122alignmentof.t │ ├── 123negative-array-indices.t │ ├── 124invoke-var.t │ ├── 125invoke-var-with-args.t │ ├── 126import-within-fn.t │ ├── 127include-all.t │ ├── 128void-return.t │ ├── 129array-of.t │ ├── 130init-array.t │ ├── 131struct-literal-array.t │ ├── 132no-op.t │ ├── 133proc-include.t │ ├── 134global-ptr-arbitrary.t │ ├── 135array-ref-params.t │ └── 136string-chars.t ├── 002macro │ ├── 001basic.t │ ├── 002reverse.t │ ├── 003varargs.t │ ├── 004qq-simple.t │ ├── 005qq-2.t │ ├── 007qq-4.t │ ├── 008tl-macro.t │ ├── 009qq-struct.t │ ├── 010arg-collision.t │ ├── 011qq-over-struct.t │ ├── 012null-macro.t │ ├── 013mqos-errors.t │ ├── 014malloc-simple.t │ ├── 015incf-and-decf.t │ ├── 016typed-macro.t │ ├── 018nested-qq.t │ ├── 019extra-parens.t │ ├── 020quote.t │ ├── 021cond.t │ ├── 022definition-order.t │ ├── 023qq-successive-uql.t │ ├── 024qq-null-nodes.t │ ├── 025qq-list-null-nodes.t │ ├── 026null-varargs-list.t │ └── 027map-nodes.t ├── 003control │ ├── 001while.t │ ├── 002implicit-branch.t │ ├── 003for.t │ ├── 004let.t │ ├── 005while-break.t │ ├── 006while-continue.t │ ├── 007for-multiple.t │ └── 008and-or.t ├── 004namespace │ ├── 001functions.t │ ├── 002macros.t │ ├── 003using.t │ ├── 004nested.t │ ├── 005new-scope.t │ ├── 006problem.t │ ├── 007qualified.defs.t │ ├── 008root-ns.t │ └── 009anonfn-scope.t ├── 005overload │ ├── 001basic.t │ ├── 002ns.t │ ├── 003ns-struct.t │ ├── 004fp.t │ ├── 005fp-address.t │ ├── 006override-core.t │ └── 007cross-ns.t ├── 006enum │ ├── 001basic.t │ ├── 002cmp.t │ ├── 006cast-to.t │ ├── 007problem.t │ ├── 008hex-problem.t │ ├── 009bitwise.t │ ├── 010unqualified.t │ └── 011global.t ├── 007assert │ ├── 001ok.t │ ├── 002not-ok.t │ └── 003disabled.t ├── 008compiler │ ├── 001exists-type.t │ ├── 002exists-fn.t │ ├── 003exists-macro.t │ ├── 004report-error.t │ ├── 005codomain-basic.t │ ├── 006arity.t │ ├── 007struct-mem-count.t │ ├── 008input-type.t │ ├── 009struct-member-type.t │ ├── 010struct-member-names.t │ ├── 011codomain-ns.t │ ├── 012exists-variable.t │ ├── 013proper-typeof.t │ ├── 014has-errors.t │ ├── 015eval-expression.t │ ├── 016is-lvalue.t │ └── 017eval-macro-call.t ├── 009module │ ├── 001dtm-fn-user.t │ ├── 002dtm-fn-user-macro.t │ ├── 003dtm-var-user.t │ ├── 004dtm-var-user-macro.t │ ├── 005dtm-struct-user.t │ ├── 006dtm-struct-user-macro.t │ ├── 007dtm-macro-user.t │ ├── 008dtm-enum-user.t │ ├── 009dtm-enum-user-macro.t │ ├── 010dtm-ns-user.t │ ├── 011dtm-inc-user.t │ ├── 012dtm-inc-pre-user.t │ ├── 013dtm-mulinc.t │ ├── 014dtm-rec.t │ ├── 015dtm-infile.t │ ├── 016dtm-opstruct.t │ ├── 017dtm-importforms.t │ ├── 018dtm-noimport.t │ ├── 019dtm-noimport-int.t │ ├── 020dtm-intover.t │ ├── 021dtm-importns.t │ ├── 022dtm-typemap.t │ ├── 023dash-M.t │ ├── 024dtm-retval.t │ └── 025dtm-preserve-imported.t ├── 010destructor │ ├── 001dtor-ns-close.t │ ├── 002dtor-whole-fn.t │ ├── 003dtor-goto-back.t │ ├── 004dtor-goto-fwd.t │ ├── 005dtor-array.t │ ├── 006dtor-md-array.t │ ├── 007dtor-struct.t │ ├── 008array-init.t │ ├── 009struct-member-init.t │ └── 010struct-recursive-init.t ├── 011concept │ ├── 001concept-1level.t │ ├── 002concept-2level.t │ ├── 003concept-nlevel.t │ ├── 004exists-concept.t │ ├── 005concept-force.t │ ├── 006concept-tree.t │ └── 007concept-impl-all-refs.t ├── 012sp │ ├── 001sp-make.t │ ├── 002sp-copy.t │ ├── 003sp-copy-fn.t │ ├── 004sp-copy-fn-ret.t │ ├── 005sp-copy-self.t │ ├── 006sp-copy-fn-ret-use.t │ ├── 007sp-copy-fn-ret-use2.t │ ├── 008sp-nested.t │ ├── 009sp-self-ref.t │ ├── 010sp-assign-other.t │ ├── 011sp-other-setf.t │ └── 012sp-destroy.t ├── 013up │ ├── 001up-make.t │ ├── 002up-move.t │ ├── 003up-move-fn.t │ ├── 004up-move-fn-rv-ref.t │ ├── 005up-move-fn-ret.t │ ├── 006up-move-self.t │ └── 007up-destroy.t ├── 014container │ ├── 001pair.t │ ├── 002triple.t │ ├── 003vector.t │ ├── 004vector-sm.t │ ├── 005vector-ins-erase.t │ ├── 006vector-clear.t │ ├── 007list.t │ ├── 008set-basic.t │ ├── 009set-erase-value.t │ ├── 010set-bounds.t │ ├── 011map-basic.t │ ├── 012array-basic.t │ ├── 013vector-in-ns.t │ ├── 014set-balanced.t │ ├── 015set-balanced-addmany.t │ ├── 016set-balanced-erasemany.t │ ├── 017vector-rv.t │ ├── 018list-rv.t │ ├── 019array-rv.t │ ├── 020set-rv.t │ ├── 021map-rv.t │ └── 022set-empty-find.t ├── 015algorithm │ ├── 001derivations.t │ ├── 001find.t │ ├── 001implied.t │ ├── 002find-if.t │ ├── 002sort-with-or.t │ ├── 003find-if-not.t │ ├── 004sort.t │ ├── 005binary-search.t │ ├── 006derivation-refs.t │ ├── 007derivation-struct-refs.t │ ├── 008find-refs.t │ ├── 009sort-refs.t │ ├── 010alg-refs.t │ ├── 011foldl.t │ ├── 012foldl-refs.t │ ├── 013sort-rv.t │ └── 014algorithm-rv.t ├── 016variant │ ├── 001basic.t │ ├── 002multiple.t │ ├── 003types.t │ ├── 004sizes.t │ ├── 005multiple-2.t │ └── 006recursive.t ├── 017bitset-enum │ ├── 001basic.t │ └── 002values.t ├── 018repl │ └── 001basic.t ├── 100external │ ├── 001pthread-basic.t │ ├── 002errno.t │ ├── 003ctype.t │ ├── 005locale.t │ ├── 006setjmp.t │ └── 007signal.t ├── 200combination │ ├── 001for-cont-and-anon.t │ ├── 002nested-loops.t │ ├── 003misc-globals.t │ ├── 004fibonacci.t │ ├── 005fn-bac.t │ ├── 006fn-by-name.t │ ├── 007arrays-to-ptrs.t │ ├── 008array-deref.t │ ├── 009chars.t │ ├── 010bitfields.t │ ├── 011zero-len-arrays.t │ ├── 012math-helpers.t │ ├── 013operator-macros.t │ ├── 014operator-macros-transitive.t │ ├── 015mfor-range.t │ ├── 016mfor-sum.t │ └── 017mif.t ├── 999last │ ├── 001compile-errors.t │ ├── 100github-33.t │ ├── 101github-74.t │ ├── 102github-93.t │ ├── 103github-105.t │ ├── 104github-103.t │ ├── 105github-108.t │ ├── 106github-106.t │ ├── 107github-137.t │ ├── 108github-141.t │ ├── 109github-119.t │ ├── 110github-142.t │ ├── 111github-147.t │ ├── 112github-148.t │ ├── 113github-160.txt │ ├── 114github-140.t │ ├── 115github-197.t │ ├── 116github-199.t │ ├── 117github-205.t │ ├── 117github-206.t │ └── 118github-213.t ├── error-src │ ├── address-of.dt │ ├── address-of.dt.errors │ ├── anonymous-scopes.dt │ ├── anonymous-scopes.dt.errors │ ├── aref-non-int.dt │ ├── aref-non-int.dt.errors │ ├── arity-atom.dt │ ├── arity-atom.dt.errors │ ├── attrs-match.dt │ ├── attrs-match.dt.errors │ ├── auto-linkage.dt │ ├── auto-linkage.dt.errors │ ├── bad-array.dt │ ├── bad-array.dt.errors │ ├── bad-attribute.dt │ ├── bad-attribute.dt.errors │ ├── bad-fp.dt │ ├── bad-fp.dt.errors │ ├── bad-integer.dt │ ├── bad-integer.dt.errors │ ├── bad-linkage.dt │ ├── bad-linkage.dt.errors │ ├── bad-mod-name.dt │ ├── bad-mod-name.dt.errors │ ├── concept-errors.dt │ ├── concept-errors.dt.errors │ ├── concept-not-implemented.dt │ ├── concept-not-implemented.dt.errors │ ├── cond.dt │ ├── cond.dt.errors │ ├── const-basic.dt │ ├── const-basic.dt.errors │ ├── const-init.dt │ ├── const-init.dt.errors │ ├── const-no-overload.dt │ ├── const-no-overload.dt.errors │ ├── const-refs.dt │ ├── const-refs.dt.errors │ ├── const-rv-2.dt │ ├── const-rv-2.dt.errors │ ├── const-rv.dt │ ├── const-rv.dt.errors │ ├── const-string.dt │ ├── const-string.dt.errors │ ├── const-struct.dt │ ├── const-struct.dt.errors │ ├── core-with-list.dt │ ├── core-with-list.dt.errors │ ├── cross-decl.dt │ ├── cross-decl.dt.errors │ ├── cto-addr-from-non-cto.dt │ ├── cto-addr-from-non-cto.dt.errors │ ├── cto-anon-from-non-cto.dt │ ├── cto-anon-from-non-cto.dt.errors │ ├── cto-from-non-cto.dt │ ├── cto-from-non-cto.dt.errors │ ├── empty-list-in-fn.dt │ ├── empty-list-in-fn.dt.errors │ ├── empty-list-in-macro.dt │ ├── empty-list-in-macro.dt.errors │ ├── enum-problem.dt │ ├── enum-problem.dt.errors │ ├── excess-var-arguments.dt │ ├── excess-var-arguments.dt.errors │ ├── expansion-error.dt │ ├── expansion-error.dt.errors │ ├── expected-int.dt │ ├── expected-int.dt.errors │ ├── expected-left-paren.dt │ ├── expected-left-paren.dt.errors │ ├── extern-plus-init.dt │ ├── extern-plus-init.dt.errors │ ├── fn-args.dt │ ├── fn-args.dt.errors │ ├── fn-overlap-mac.dt │ ├── fn-overlap-mac.dt.errors │ ├── for-loop.dt │ ├── for-loop.dt.errors │ ├── if-branches-different.dt │ ├── if-branches-different.dt.errors │ ├── implied-type.dt │ ├── implied-type.dt.errors │ ├── include-test.dt │ ├── include-test.dt.errors │ ├── include │ │ └── test.dt │ ├── invalid-cast.dt │ ├── invalid-cast.dt.errors │ ├── invalid-instantiation.dt │ ├── invalid-instantiation.dt.errors │ ├── invalid-intern-var.dt │ ├── invalid-intern-var.dt.errors │ ├── invalid-offsetof.dt │ ├── invalid-offsetof.dt.errors │ ├── invalid-type.dt │ ├── invalid-type.dt.errors │ ├── invoke-errors.dt │ ├── invoke-errors.dt.errors │ ├── let.dt │ ├── let.dt.errors │ ├── mac-overlap-fn.dt │ ├── mac-overlap-fn.dt.errors │ ├── macro-args.dt │ ├── macro-args.dt.errors │ ├── macro-error-checking.dt │ ├── macro-error-checking.dt.errors │ ├── macro-error-position.dt │ ├── macro-error-position.dt.errors │ ├── mfor.dt │ ├── mfor.dt.errors │ ├── missing-right-paren.dt │ ├── missing-right-paren.dt.errors │ ├── ml-comment-line-numbers.dt │ ├── ml-comment-line-numbers.dt.errors │ ├── ml-string-line-numbers.dt │ ├── ml-string-line-numbers.dt.errors │ ├── multiple-arg-inst.dt │ ├── multiple-arg-inst.dt.errors │ ├── multiple-instantiations.dt │ ├── multiple-instantiations.dt.errors │ ├── no-array-params.dt │ ├── no-array-params.dt.errors │ ├── no-array-ret-type.dt │ ├── no-array-ret-type.dt.errors │ ├── no-core-macro.dt │ ├── no-core-macro.dt.errors │ ├── no-lvalue-addresses.dt │ ├── no-lvalue-addresses.dt.errors │ ├── no-sort-array.dt │ ├── no-sort-array.dt.errors │ ├── no-sort-vector.dt │ ├── no-sort-vector.dt.errors │ ├── no-string.dt │ ├── no-string.dt.errors │ ├── no-vla.dt │ ├── no-vla.dt.errors │ ├── no-void-in-struct.dt │ ├── no-void-in-struct.dt.errors │ ├── non-ptr-fn.dt │ ├── non-ptr-fn.dt.errors │ ├── non-token-derivation.dt │ ├── non-token-derivation.dt.errors │ ├── not-in-scope.dt │ ├── not-in-scope.dt.errors │ ├── ns-deactivation-error.dt │ ├── ns-deactivation-error.dt.errors │ ├── ol-candidate-macro.dt │ ├── ol-candidate-macro.dt.errors │ ├── ol-candidate.dt │ ├── ol-candidate.dt.errors │ ├── ol-fn-setf.dt │ ├── ol-fn-setf.dt.errors │ ├── only-void.dt │ ├── only-void.dt.errors │ ├── operator-macro-need-three.dt │ ├── operator-macro-need-three.dt.errors │ ├── position.dt │ ├── position.dt.errors │ ├── qq-problems.dt │ ├── qq-problems.dt.errors │ ├── redecl-global-difftype.dt │ ├── redecl-global-difftype.dt.errors │ ├── redeclaration-extern-c-fn.dt │ ├── redeclaration-extern-c-fn.dt.errors │ ├── redeclaration-fn.dt │ ├── redeclaration-fn.dt.errors │ ├── redeclaration-labels.dt │ ├── redeclaration-labels.dt.errors │ ├── redeclaration.dt │ ├── redeclaration.dt.errors │ ├── refs-exclusive.dt │ ├── refs-exclusive.dt.errors │ ├── register-type.dt │ ├── register-type.dt.errors │ ├── requires-explicit-init.dt │ ├── requires-explicit-init.dt.errors │ ├── ret-type-fail-1.dt │ ├── ret-type-fail-1.dt.errors │ ├── ret-type-fail-2.dt │ ├── ret-type-fail-2.dt.errors │ ├── return-type.dt │ ├── return-type.dt.errors │ ├── same-names.dt │ ├── same-names.dt.errors │ ├── setf-const-string.dt │ ├── setf-const-string.dt.errors │ ├── setf-copy-disabled-inner.dt │ ├── setf-copy-disabled-inner.dt.errors │ ├── setf-copy-disabled-ref.dt │ ├── setf-copy-disabled-ref.dt.errors │ ├── setf-copy-disabled.dt │ ├── setf-copy-disabled.dt.errors │ ├── setf-needs-pointer.dt │ ├── setf-needs-pointer.dt.errors │ ├── sizeof-opaque-struct.dt │ ├── sizeof-opaque-struct.dt.errors │ ├── top-level-empty-list.dt │ ├── top-level-empty-list.dt.errors │ ├── two-modules.dt │ ├── two-modules.dt.errors │ ├── unsupported-literal.dt │ ├── unsupported-literal.dt.errors │ ├── unterminated.dt │ ├── unterminated.dt.errors │ ├── uq-problems.dt │ ├── uq-problems.dt.errors │ ├── variant-invalid-type.dt │ ├── variant-invalid-type.dt.errors │ ├── variant-member.dt │ ├── variant-member.dt.errors │ ├── variant-non-exhaustive.dt │ ├── variant-non-exhaustive.dt.errors │ ├── vector-rv-no-copy.dt │ └── vector-rv-no-copy.dt.errors ├── include │ ├── cycle1.dth │ ├── cycle2.dth │ └── cycle3.dth ├── lib │ └── Dale.pm └── src │ ├── address-of-va-fn.dt │ ├── alg-refs.dt │ ├── algorithm-rv.dt │ ├── alignmentof.dt │ ├── and-or.dt │ ├── anon-array-struct.dt │ ├── anon-fn.dt │ ├── anon-struct.dt │ ├── anonfn-scope.dt │ ├── aref-problem.dt │ ├── arity.dt │ ├── array-address.dt │ ├── array-basic.dt │ ├── array-deref.dt │ ├── array-init.dt │ ├── array-literal-fc.dt │ ├── array-literal-md.dt │ ├── array-literal-simple.dt │ ├── array-of.dt │ ├── array-params.dt │ ├── array-ref-params.dt │ ├── array-rv.dt │ ├── arrays-to-ptrs.dt │ ├── arrays.dt │ ├── assert-disabled.dt │ ├── assert-not-ok.dt │ ├── assert-ok.dt │ ├── assign-other.dt │ ├── binary-search.dt │ ├── bitfields.dt │ ├── bitset-enum-basic.dt │ ├── bitset-enum-values.dt │ ├── bitwise.dt │ ├── bools.dt │ ├── cf-for.dt │ ├── cf-while-break.dt │ ├── cf-while-continue.dt │ ├── cf-while.dt │ ├── char.dt │ ├── chars.dt │ ├── codomain-basic.dt │ ├── codomain-ns.dt │ ├── concept-1level.dt │ ├── concept-2level.dt │ ├── concept-force.dt │ ├── concept-impl-all-refs.dt │ ├── concept-nlevel.dt │ ├── concept-tree.dt │ ├── cond.dt │ ├── const-global.dt │ ├── const-parameters.dt │ ├── const-ptrs.dt │ ├── ctype.dt │ ├── def-refs-implicit.dt │ ├── definition-order.dt │ ├── derivation-refs.dt │ ├── derivation-struct-refs.dt │ ├── derivations.dt │ ├── dispatch.dt │ ├── do.dt │ ├── dtm-enum-user-macro.dt │ ├── dtm-enum-user.dt │ ├── dtm-enum.dt │ ├── dtm-fn-user-macro.dt │ ├── dtm-fn-user.dt │ ├── dtm-fn.dt │ ├── dtm-importforms-user.dt │ ├── dtm-importforms.dt │ ├── dtm-inc-pre-user.dt │ ├── dtm-inc-user.dt │ ├── dtm-inc.dt │ ├── dtm-intover-user.dt │ ├── dtm-macro-user.dt │ ├── dtm-macro.dt │ ├── dtm-mulinc.dt │ ├── dtm-noimport-int.dt │ ├── dtm-noimport-intover.dt │ ├── dtm-noimport-user.dt │ ├── dtm-noimport-user2.dt │ ├── dtm-noimport.dt │ ├── dtm-ns-user.dt │ ├── dtm-ns.dt │ ├── dtm-nsimport-user.dt │ ├── dtm-nsimport.dt │ ├── dtm-opstruct-user.dt │ ├── dtm-opstruct.dt │ ├── dtm-preserve-imported1.dt │ ├── dtm-preserve-imported2.dt │ ├── dtm-retval-user.dt │ ├── dtm-retval.dt │ ├── dtm-struct-user-macro.dt │ ├── dtm-struct-user.dt │ ├── dtm-struct.dt │ ├── dtm-typemap-dashm.dt │ ├── dtm-typemap-user-dashm.dt │ ├── dtm-typemap-user.dt │ ├── dtm-typemap.dt │ ├── dtm-var-user-macro.dt │ ├── dtm-var-user.dt │ ├── dtm-var.dt │ ├── dtm1.dt │ ├── dtm2.dt │ ├── dtor-array.dt │ ├── dtor-goto-back.dt │ ├── dtor-goto-fwd.dt │ ├── dtor-md-array.dt │ ├── dtor-ns-close.dt │ ├── dtor-struct.dt │ ├── dtor-whole-fn.dt │ ├── empty-lists.dt │ ├── empty-main.dt │ ├── enum-bitwise.dt │ ├── enum-cast-to.dt │ ├── enum-cmp.dt │ ├── enum-global.dt │ ├── enum-hex-problem.dt │ ├── enum-problem.dt │ ├── enum-unqualified.dt │ ├── enum.dt │ ├── errno.dt │ ├── eval-expression.dt │ ├── eval-macro-call.dt │ ├── exists-concept.dt │ ├── exists-fn.dt │ ├── exists-macro.dt │ ├── exists-type.dt │ ├── exists-variable.dt │ ├── extern-c-coerce.dt │ ├── extern-var.dt │ ├── extra-parens.dt │ ├── fibonacci.dt │ ├── files.dt │ ├── find-if-not.dt │ ├── find-if.dt │ ├── find-refs.dt │ ├── find.dt │ ├── first-element-list.dt │ ├── float-double-cast.dt │ ├── float-double.dt │ ├── float-problem.dt │ ├── fn-arg-collision.dt │ ├── fn-by-args-count.dt │ ├── fn-by-args-name.dt │ ├── fn-object-multi.dt │ ├── fn-object-simple.dt │ ├── fn-pointers.dt │ ├── foldl-refs.dt │ ├── foldl.dt │ ├── for-cont-and-anon.dt │ ├── for-multiple.dt │ ├── force-multiple-arg.dt │ ├── fp-at-compile-time.dt │ ├── fp-type-checking.dt │ ├── free.dt │ ├── gh-198.dt │ ├── gh-199.dt │ ├── gh-205.dt │ ├── gh-206.dt │ ├── gint-x86-64.dt │ ├── gint.dt │ ├── global-ptr-arbitrary.dt │ ├── global-ptr-sc.dt │ ├── globals.dt │ ├── gstring.dt │ ├── gstruct-padding.dt │ ├── gstruct-x86-64.dt │ ├── gstruct.dt │ ├── has-errors.dt │ ├── hello-name.dt │ ├── hello-samename.dt │ ├── hello-world.dt │ ├── hex-literals.dt │ ├── if-branches-different.dt │ ├── if-proper.dt │ ├── if-struct.dt │ ├── implicit-branch.dt │ ├── implicit-funcall.dt │ ├── implicit-no-copy.dt │ ├── implicit-return.dt │ ├── implied.dt │ ├── import-within-fn.dt │ ├── incf-and-decf.dt │ ├── include-non-toplevel-include.dt │ ├── include-non-toplevel.dt │ ├── include-test-2.dt │ ├── include-test.dt │ ├── include.dt │ ├── incorrect-cto-error.dt │ ├── init-array.dt │ ├── input-type-basic.dt │ ├── int-array-global-x86-64.dt │ ├── int-array-global.dt │ ├── intdefs.dt │ ├── intern-in-fn-explicit-expr.dt │ ├── intern-in-fn-explicit.dt │ ├── invoke-var-with-args.dt │ ├── invoke-var.dt │ ├── is-lvalue.dt │ ├── labels-2.dt │ ├── labels.dt │ ├── let.dt │ ├── lfc-problem.dt │ ├── libmod-importforms-nomacros.bc │ ├── libmod-importforms.bc │ ├── libmod-importforms.dtm │ ├── link-bc-1.dt │ ├── link-bc-2.dt │ ├── list-rv.dt │ ├── list.dt │ ├── locale.dt │ ├── long-double.dt │ ├── long-token-from-macro.dt │ ├── macro-arg-collision.dt │ ├── macros-basic.dt │ ├── macros-qq-2.dt │ ├── macros-qq-4.dt │ ├── macros-qq-over-struct.dt │ ├── macros-qq-simple.dt │ ├── macros-qq-struct.dt │ ├── macros-qq-successive-uql.dt │ ├── macros-reverse.dt │ ├── macros-varargs.dt │ ├── main-with-args.dt │ ├── malloc-simple.dt │ ├── malloc.dt │ ├── map-basic.dt │ ├── map-nodes.dt │ ├── map-rv.dt │ ├── math-helpers.dt │ ├── md-arrays.dt │ ├── mfor-range.dt │ ├── mfor-sum.dt │ ├── mif.dt │ ├── misc-globals.dt │ ├── ml-comment-nested.dt │ ├── ml-comment.dt │ ├── modc.dt │ ├── modp-infile-user.dt │ ├── modp-infile.dt │ ├── modp-user.dt │ ├── modp.dt │ ├── modp2.dt │ ├── modulus.dt │ ├── mqos-errors.dt │ ├── mr-fn.dt │ ├── mr-struct.dt │ ├── namespace-fns.dt │ ├── namespace-macs.dt │ ├── namespace-nested.dt │ ├── namespace-qualified-defs.dt │ ├── negative-array-indices.dt │ ├── negative-fp.dt │ ├── negative-hex.dt │ ├── nested-ifs-2.dt │ ├── nested-ifs.dt │ ├── nested-loops.dt │ ├── nested-qq.dt │ ├── new-scope.dt │ ├── no-intern-init.dt │ ├── no-op.dt │ ├── ns-problem.dt │ ├── ns2.dt │ ├── null-macro.dt │ ├── null-varargs-list.dt │ ├── nullptr.dt │ ├── offsetof.dt │ ├── once.dt │ ├── one.dt │ ├── opaque-struct-redef-2.dt │ ├── opaque-struct-redef.dt │ ├── opaque-struct.dt │ ├── operator-macro-problems.dt │ ├── operator-macros-transitive.dt │ ├── operator-macros.dt │ ├── other.dt │ ├── over-fp-address.dt │ ├── over-fp.dt │ ├── over-ns-struct.dt │ ├── over-ns.dt │ ├── over-simple.dt │ ├── overload-cross-ns.dt │ ├── override-core.dt │ ├── pair.dt │ ├── pointers.dt │ ├── preserve-imported3.dt │ ├── printf.dt │ ├── proc-include-test.dt │ ├── proc-include.dt │ ├── proper-typeof.dt │ ├── pthread-basic.dt │ ├── ptr-math.dt │ ├── ptr-operations.dt │ ├── quote.dt │ ├── refs-basic.dt │ ├── refs-const.dt │ ├── refs-fnptr-exp.dt │ ├── refs-fnptr.dt │ ├── refs-no-copy-var.dt │ ├── refs-no-copy.dt │ ├── refs-pass.dt │ ├── report-error.dt │ ├── ret-problem.dt │ ├── retval-basic.dt │ ├── retval-do.dt │ ├── retval-fnptr-refs.dt │ ├── retval-fnptr.dt │ ├── retval-nested.dt │ ├── retval-setf.dt │ ├── retval-unneeded.dt │ ├── root-ns.dt │ ├── rv-refs-move.dt │ ├── rv-refs-no-copy.dt │ ├── rv-refs-setf-move.dt │ ├── rv-refs-simple.dt │ ├── rv-refs-use-simple.dt │ ├── self-ref.dt │ ├── set-balanced-addmany.dt │ ├── set-balanced-erasemany.dt │ ├── set-balanced.dt │ ├── set-basic.dt │ ├── set-bounds.dt │ ├── set-const-struct-member.dt │ ├── set-empty-find.dt │ ├── set-erase-value.dt │ ├── set-rv.dt │ ├── setf-stack-vars.dt │ ├── setjmp.dt │ ├── signal.dt │ ├── sizeof-array-problem.dt │ ├── sizeof-array.dt │ ├── sizeof-problem.dt │ ├── sort-refs.dt │ ├── sort-rv.dt │ ├── sort-with-or.dt │ ├── sort.dt │ ├── sp-assign-other.dt │ ├── sp-copy-fn-ret-use.dt │ ├── sp-copy-fn-ret-use2.dt │ ├── sp-copy-fn-ret.dt │ ├── sp-copy-fn.dt │ ├── sp-copy-self.dt │ ├── sp-copy.dt │ ├── sp-destroy.dt │ ├── sp-make.dt │ ├── sp-nested.dt │ ├── sp-other-setf.dt │ ├── sp-self-ref.dt │ ├── sp-set-value.dt │ ├── sr-struct.dt │ ├── sref-on-fn.dt │ ├── stack-vars.dt │ ├── string-chars.dt │ ├── struct-casting.dt │ ├── struct-deref.dt │ ├── struct-init.dt │ ├── struct-literal-array.dt │ ├── struct-literals.dt │ ├── struct-member-count.dt │ ├── struct-member-init.dt │ ├── struct-member-names.dt │ ├── struct-member-type.dt │ ├── struct-rec-problem.dt │ ├── struct-recursive-init.dt │ ├── struct.dt │ ├── tl-do.dt │ ├── tl-macro.dt │ ├── triple.dt │ ├── two-branches.dt │ ├── two.dt │ ├── typed-macro.dt │ ├── unary-minus.dt │ ├── unquote-arbitrary.dt │ ├── unquote-first-null-nodes.dt │ ├── unquote-list-null-nodes.dt │ ├── unquote-null-nodes.dt │ ├── up-destroy.dt │ ├── up-make.dt │ ├── up-move-fn-ret.dt │ ├── up-move-fn-rv-ref.dt │ ├── up-move-fn.dt │ ├── up-move-self.dt │ ├── up-move.dt │ ├── used-ns-problem.dt │ ├── using-namespace.dt │ ├── varargs-more.dt │ ├── varargs.dt │ ├── variant-basic.dt │ ├── variant-multiple-2.dt │ ├── variant-multiple.dt │ ├── variant-recursive.dt │ ├── variant-sizes.dt │ ├── variant-types.dt │ ├── vector-clear.dt │ ├── vector-in-ns.dt │ ├── vector-ins-erase.dt │ ├── vector-rv.dt │ ├── vector.dt │ ├── void-fnptr.dt │ ├── void-if-nested.dt │ ├── void-if.dt │ ├── void-ptr-arithmetic.dt │ ├── void-return.dt │ └── zero-len-arrays.dt ├── verify-targets └── vim └── dale.vim /.clang-format: -------------------------------------------------------------------------------- 1 | BasedOnStyle: Google 2 | IndentWidth: 4 3 | ColumnLimit: 72 4 | AccessModifierOffset: 0 5 | -------------------------------------------------------------------------------- /.dockerignore: -------------------------------------------------------------------------------- 1 | .git 2 | Dockerfile 3 | .dockerignore 4 | CMakeFiles 5 | CMakeCache.txt 6 | dalec 7 | daleci 8 | *.so 9 | *.bc 10 | *.dtm 11 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.s 2 | *.o 3 | *.bc 4 | *.dtm 5 | *.so 6 | *.so.* 7 | *.swp 8 | *.gch 9 | src/dale/Config\.h 10 | dale-bindgen 11 | dalec 12 | daleci 13 | CMakeFiles 14 | CMakeCache 15 | CMakeCache.txt 16 | Makefile 17 | cmake_install.cmake 18 | install_manifest.txt 19 | build 20 | doc/html 21 | doc/2- 22 | doc/3- 23 | doc/drt.md 24 | a.out 25 | Config.h 26 | .ninja_deps 27 | .ninja_log 28 | build.ninja 29 | rules.ninja 30 | module-to-markdown 31 | src/doxygen_sqlite3.db 32 | src/html 33 | src/latex 34 | core 35 | *.core 36 | callgrind.out.* 37 | tags 38 | -------------------------------------------------------------------------------- /doc/1-13-tools.md: -------------------------------------------------------------------------------- 1 | # Dale 2 | 3 | [Previous](./1-12-repl.md) | [Next](./2-1-introspection.md) 4 | 5 | ## 1.13 Tools 6 | 7 | ### [dale-autowrap](../eg/dale-autowrap) 8 | 9 | Converts [c2ffi](https://github.com/rpav/c2ffi) output files into Dale 10 | program files, allowing for automatically generating bindings for C 11 | libraries. 12 | 13 | [Previous](./1-11-form-reference.md) | [Next](./2-1-introspection.md) 14 | -------------------------------------------------------------------------------- /eg/dale-autowrap/c2dale.sh: -------------------------------------------------------------------------------- 1 | for a in $@ 2 | do 3 | c2ffi $INCLUDE_PATH/$a.h | ./dale-autowrap $a > $a.dt 4 | done 5 | 6 | -------------------------------------------------------------------------------- /eg/dale-autowrap/t/headers/casing.h: -------------------------------------------------------------------------------- 1 | int first_test(int a, float b); 2 | int secondTest(void); 3 | int ThirdTest(void); 4 | -------------------------------------------------------------------------------- /eg/dale-autowrap/t/headers/casing.h.dt: -------------------------------------------------------------------------------- 1 | (def first_test (fn extern-c int ((a int) (b float)))) 2 | (def secondTest (fn extern-c int (void))) 3 | (def ThirdTest (fn extern-c int (void))) 4 | -------------------------------------------------------------------------------- /eg/dale-autowrap/t/headers/define.h: -------------------------------------------------------------------------------- 1 | #define FOO (1 << 2) 2 | -------------------------------------------------------------------------------- /eg/dale-autowrap/t/headers/define.h.dt: -------------------------------------------------------------------------------- 1 | (import stdlib) 2 | 3 | (def FOO (var intern (long-type) 4)) 4 | -------------------------------------------------------------------------------- /eg/dale-autowrap/t/headers/enum.h: -------------------------------------------------------------------------------- 1 | enum numbers { ZERO, ONE, TWO, THREE }; 2 | -------------------------------------------------------------------------------- /eg/dale-autowrap/t/headers/enum.h.dt: -------------------------------------------------------------------------------- 1 | (import enum) 2 | 3 | (def-enum numbers extern int ((ZERO 0) (ONE 1) (TWO 2) (THREE 3))) 4 | -------------------------------------------------------------------------------- /eg/dale-autowrap/t/headers/file.h: -------------------------------------------------------------------------------- 1 | #include "./casing.h" 2 | int test(void); 3 | -------------------------------------------------------------------------------- /eg/dale-autowrap/t/headers/file.h.dt: -------------------------------------------------------------------------------- 1 | (def test (fn extern-c int (void))) 2 | -------------------------------------------------------------------------------- /eg/dale-autowrap/t/headers/fn-array-param.h: -------------------------------------------------------------------------------- 1 | int test(int test[]); 2 | -------------------------------------------------------------------------------- /eg/dale-autowrap/t/headers/fn-array-param.h.dt: -------------------------------------------------------------------------------- 1 | (def test (fn extern-c int ((test (p int))))) 2 | -------------------------------------------------------------------------------- /eg/dale-autowrap/t/headers/function.h: -------------------------------------------------------------------------------- 1 | int main(void); 2 | -------------------------------------------------------------------------------- /eg/dale-autowrap/t/headers/function.h.dt: -------------------------------------------------------------------------------- 1 | (def main (fn extern-c int (void))) 2 | -------------------------------------------------------------------------------- /eg/dale-autowrap/t/headers/namespace.h: -------------------------------------------------------------------------------- 1 | int first_testfn1(int a, float b); 2 | int first_testfn2(void); 3 | int otherfn(void); 4 | -------------------------------------------------------------------------------- /eg/dale-autowrap/t/headers/namespace.h.dt: -------------------------------------------------------------------------------- 1 | (def first_testfn1 (fn extern-c int ((a int) (b float)))) 2 | (def first_testfn2 (fn extern-c int (void))) 3 | (def otherfn (fn extern-c int (void))) 4 | -------------------------------------------------------------------------------- /eg/dale-autowrap/t/headers/ns-type-with-use.h: -------------------------------------------------------------------------------- 1 | typedef struct { int a; } testStruct; 2 | typedef struct { testStruct b; } anotherStruct2; 3 | -------------------------------------------------------------------------------- /eg/dale-autowrap/t/headers/ns-type-with-use.h.dt: -------------------------------------------------------------------------------- 1 | (def testStruct (struct extern ((a int)))) 2 | (def anotherStruct2 (struct extern ((b testStruct)))) 3 | -------------------------------------------------------------------------------- /eg/dale-autowrap/t/headers/original-first.h: -------------------------------------------------------------------------------- 1 | int LIB_NAMESPACE1; 2 | typedef struct { int a; } LibX; 3 | int LIB_NAMESPACE2; 4 | int libFn(int a); 5 | int LIB_NAMESPACE3; 6 | -------------------------------------------------------------------------------- /eg/dale-autowrap/t/headers/original-first.h.dt: -------------------------------------------------------------------------------- 1 | (def LIB_NAMESPACE1 (var intern int)) 2 | (def LibX (struct extern ((a int)))) 3 | (def LIB_NAMESPACE2 (var intern int)) 4 | (def libFn (fn extern-c int ((a int)))) 5 | (def LIB_NAMESPACE3 (var intern int)) 6 | -------------------------------------------------------------------------------- /eg/dale-autowrap/t/headers/static.h: -------------------------------------------------------------------------------- 1 | int test; 2 | -------------------------------------------------------------------------------- /eg/dale-autowrap/t/headers/static.h.dt: -------------------------------------------------------------------------------- 1 | (def test (var intern int)) 2 | -------------------------------------------------------------------------------- /eg/dale-autowrap/t/headers/struct-members.h: -------------------------------------------------------------------------------- 1 | typedef struct { 2 | int firstElement; 3 | int secondElement; 4 | } testStruct; 5 | -------------------------------------------------------------------------------- /eg/dale-autowrap/t/headers/struct-members.h.dt: -------------------------------------------------------------------------------- 1 | (def testStruct (struct extern ((firstElement int) (secondElement int)))) 2 | -------------------------------------------------------------------------------- /eg/dale-autowrap/t/headers/struct.h: -------------------------------------------------------------------------------- 1 | struct test { 2 | int a; 3 | int b; 4 | float c; 5 | }; 6 | -------------------------------------------------------------------------------- /eg/dale-autowrap/t/headers/struct.h.dt: -------------------------------------------------------------------------------- 1 | (def test (struct extern ((a int) (b int) (c float)))) 2 | -------------------------------------------------------------------------------- /eg/dale-autowrap/t/headers/type-with-use.h: -------------------------------------------------------------------------------- 1 | typedef struct { int a; } testStruct; 2 | typedef struct { testStruct b; } testStruct2; 3 | -------------------------------------------------------------------------------- /eg/dale-autowrap/t/headers/type-with-use.h.dt: -------------------------------------------------------------------------------- 1 | (def testStruct (struct extern ((a int)))) 2 | (def testStruct2 (struct extern ((b testStruct)))) 3 | -------------------------------------------------------------------------------- /eg/dale-autowrap/t/headers/typedef-multiple.h: -------------------------------------------------------------------------------- 1 | typedef struct S { int x; } S; 2 | typedef union U { int x; } U; 3 | typedef enum E { x } E; 4 | -------------------------------------------------------------------------------- /eg/dale-autowrap/t/headers/typedef-multiple.h.dt: -------------------------------------------------------------------------------- 1 | (import enum) 2 | (import variant) 3 | 4 | (def S (struct extern ((x int)))) 5 | (def-variant U ((U-int ((value int))))) 6 | (def-enum E extern int ((x 0))) 7 | -------------------------------------------------------------------------------- /eg/dale-autowrap/t/headers/typedef-struct.h: -------------------------------------------------------------------------------- 1 | typedef struct { int a; } test; 2 | -------------------------------------------------------------------------------- /eg/dale-autowrap/t/headers/typedef-struct.h.dt: -------------------------------------------------------------------------------- 1 | (def test (struct extern ((a int)))) 2 | -------------------------------------------------------------------------------- /eg/dale-autowrap/t/headers/typedef.h: -------------------------------------------------------------------------------- 1 | typedef int Integer; 2 | -------------------------------------------------------------------------------- /eg/dale-autowrap/t/headers/typedef.h.dt: -------------------------------------------------------------------------------- 1 | (def Integer (struct extern ((a int)))) 2 | -------------------------------------------------------------------------------- /eg/dale-autowrap/t/headers/union.h: -------------------------------------------------------------------------------- 1 | union test { 2 | int a; 3 | char b; 4 | float c; 5 | }; 6 | -------------------------------------------------------------------------------- /eg/dale-autowrap/t/headers/union.h.dt: -------------------------------------------------------------------------------- 1 | (import variant) 2 | 3 | (def-variant test ((test-int ((value int))) (test-char ((value char))) (test-float ((value float))))) 4 | -------------------------------------------------------------------------------- /eg/dale-autowrap/t/headers/variable.h: -------------------------------------------------------------------------------- 1 | extern int test; 2 | -------------------------------------------------------------------------------- /eg/dale-autowrap/t/headers/variable.h.dt: -------------------------------------------------------------------------------- 1 | (def test (var extern int)) 2 | -------------------------------------------------------------------------------- /eg/doc/anonymous-functions.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | (import stdlib) 3 | 4 | (def main (fn extern-c int (void) 5 | (let ((anon-fn \ (fn int ((n int)) (* 2 n)))) 6 | (printf "%d\n" (anon-fn 5))))) 7 | -------------------------------------------------------------------------------- /eg/doc/error-reporting.dt: -------------------------------------------------------------------------------- 1 | (import introspection) 2 | (import stdlib) 3 | 4 | (using-namespace std.macros 5 | (def assert-is-struct (macro intern (st) 6 | (let ((count \ (struct-member-count mc st))) 7 | (and (= -1 count) 8 | (do (report-error mc st "struct type does not exist") 9 | true)) 10 | (return (nullptr DNode))))) 11 | 12 | (def main (fn extern-c int (void) 13 | (assert-is-struct Point) 14 | 0))) 15 | -------------------------------------------------------------------------------- /eg/doc/hello-name.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def main (fn extern-c int (void) 4 | (def name (var auto (p (const char)) "name")) 5 | (printf "hello, %s\n" name))) 6 | -------------------------------------------------------------------------------- /eg/doc/hello-world.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def main (fn extern-c int (void) 4 | (printf "hello, world\n"))) 5 | -------------------------------------------------------------------------------- /eg/doc/macros.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | (import stdlib) 3 | (import macros) 4 | 5 | (using-namespace std.macros 6 | (def unless (macro intern (condition statement) 7 | (qq do 8 | (and (not (uq condition)) 9 | (do (uq statement) true))))) 10 | 11 | (def main (fn extern-c int (void) 12 | (unless (= 1 2) 13 | (printf "1 does not equal 2\n")) 14 | (return 0)))) 15 | -------------------------------------------------------------------------------- /eg/doc/overloading.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | (import cstdlib) 3 | 4 | (def Point (struct intern ((x int) (y int)))) 5 | 6 | (def + (fn intern Point ((a Point) (b Point)) 7 | (let ((r Point ((x (+ (@: a x) (@: b x))) 8 | (y (+ (@: a y) (@: b y)))))) 9 | (return r)))) 10 | 11 | (def main (fn extern-c int (void) 12 | (let ((a Point ((x 1) (y 2))) 13 | (b Point ((x 3) (y 4))) 14 | (c Point (+ a b))) 15 | (printf "%d %d\n" (@: c x) (@: c y))))) 16 | -------------------------------------------------------------------------------- /eg/doc/type-deduction.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | (import stdlib) 3 | 4 | (def main (fn extern-c int (void) 5 | (let ((a \ 1) 6 | (b \ 2)) 7 | (printf "%d\n" (+ a b))))) 8 | -------------------------------------------------------------------------------- /eg/doc/typed-macros.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | (import macros) 3 | 4 | (using-namespace std.macros 5 | (def + (macro intern ((a int) (b int) (c int)) 6 | (qq do (+ (uq a) (+ (uq b) (uq c)))))) 7 | 8 | (def main (fn extern-c int (void) 9 | (printf "%d\n" (+ 1 2 3))))) 10 | -------------------------------------------------------------------------------- /eg/doc/variants.dt: -------------------------------------------------------------------------------- 1 | (import variant) 2 | (import cstdio) 3 | 4 | (def-variant Number ((Int ((a int))) 5 | (Float ((a float))))) 6 | 7 | (def main (fn extern-c int (void) 8 | (let ((ni Number (Int 1)) 9 | (nf Number (Float 2.0)) 10 | (na (array-of 2 Number) (array ni nf))) 11 | (for (i \ 0) (< i 2) (incv i) 12 | (let ((nc Number (@$ na i))) 13 | (case nc 14 | (Int (printf "Number is int (%d)\n" (@:@ nc a))) 15 | (Float (printf "Number is float (%f)\n" (@:@ nc a))))))) 16 | 0)) 17 | 18 | -------------------------------------------------------------------------------- /man/dalec.1.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomhrr/dale/458a543c0d2eb66564755875dd71fb8ab49dd88c/man/dalec.1.gz -------------------------------------------------------------------------------- /man/daleci.1.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomhrr/dale/458a543c0d2eb66564755875dd71fb8ab49dd88c/man/daleci.1.gz -------------------------------------------------------------------------------- /modules/arithmetic.dt: -------------------------------------------------------------------------------- 1 | (module arithmetic) 2 | -------------------------------------------------------------------------------- /modules/darwin/cerrno-arch.dt: -------------------------------------------------------------------------------- 1 | (module cerrno-arch) 2 | 3 | (import macros) 4 | 5 | (def __error 6 | (fn extern-c (p int) (void))) 7 | 8 | (def errno-arch 9 | (macro extern (void) (std.macros.qq @ (__error)))) 10 | -------------------------------------------------------------------------------- /modules/darwin/cstdio-arch.dt: -------------------------------------------------------------------------------- 1 | (module cstdio-arch) 2 | 3 | (import macros) 4 | 5 | (def stdin (var extern-c (p file) (nullptr file))) 6 | (def __stdinp (var extern-c (p file))) 7 | 8 | (def stdout (var extern-c (p file) (nullptr file))) 9 | (def __stdoutp (var extern-c (p file))) 10 | 11 | (def stderr (var extern-c (p file) (nullptr file))) 12 | (def __stderrp (var extern-c (p file))) 13 | 14 | (def init-channels 15 | (fn extern int (void) 16 | (setv stdin __stdinp) 17 | (setv stdout __stdoutp) 18 | (setv stderr __stderrp) 19 | 0)) 20 | -------------------------------------------------------------------------------- /modules/freebsd/cerrno-arch.dt: -------------------------------------------------------------------------------- 1 | (module cerrno-arch) 2 | 3 | (import macros) 4 | 5 | (def __error 6 | (fn extern-c (p int) (void))) 7 | 8 | (def errno-arch 9 | (macro extern (void) (std.macros.qq @ (__error)))) 10 | -------------------------------------------------------------------------------- /modules/freebsd/cstdio-arch.dt: -------------------------------------------------------------------------------- 1 | (module cstdio-arch) 2 | 3 | (import macros) 4 | 5 | (def stdin (var extern-c (p file) (nullptr file))) 6 | (def __stdinp (var extern-c (p file))) 7 | 8 | (def stdout (var extern-c (p file) (nullptr file))) 9 | (def __stdoutp (var extern-c (p file))) 10 | 11 | (def stderr (var extern-c (p file) (nullptr file))) 12 | (def __stderrp (var extern-c (p file))) 13 | 14 | (def init-channels 15 | (fn extern int (void) 16 | (setv stdin __stdinp) 17 | (setv stdout __stdoutp) 18 | (setv stderr __stderrp) 19 | 0)) 20 | -------------------------------------------------------------------------------- /modules/linux/cerrno-arch.dt: -------------------------------------------------------------------------------- 1 | (module cerrno-arch) 2 | 3 | (import macros) 4 | 5 | (def __errno_location 6 | (fn extern-c (p int) (void))) 7 | 8 | (def errno-arch 9 | (macro extern (void) (std.macros.qq @ (__errno_location)))) 10 | -------------------------------------------------------------------------------- /modules/linux/cstdio-arch.dt: -------------------------------------------------------------------------------- 1 | (module cstdio-arch) 2 | -------------------------------------------------------------------------------- /run-tests: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | if [ "$1" != "" ] 3 | then 4 | export DALE_TEST_DIR=$1 5 | else 6 | export DALE_TEST_DIR=. 7 | fi 8 | if [ "$DALE_TEST_ARGS" = "" ] 9 | then 10 | export DALE_TEST_ARGS=-O0 11 | fi 12 | PERL_DL_NONLAZY=1 HARNESS_OPTIONS=j4 /usr/bin/env perl "-MExtUtils::Command::MM" "-e" "test_harness(0)" ${DALE_TEST_DIR}/t/*/*.t 13 | -------------------------------------------------------------------------------- /src/dale/Arch/Arch.cpp: -------------------------------------------------------------------------------- 1 | #include "Arch.h" 2 | 3 | namespace dale { 4 | } 5 | -------------------------------------------------------------------------------- /src/dale/Arch/Arch.h: -------------------------------------------------------------------------------- 1 | #ifndef DALE_ARCH 2 | #define DALE_ARCH 3 | 4 | #define ARCH_COUNT 3 5 | 6 | namespace dale { 7 | /*! Arch 8 | 9 | Defines an enum for the supported architectures. 10 | */ 11 | namespace Arch { 12 | enum { 13 | X86, 14 | X86_64, 15 | AARCH64, 16 | ARM64_APPLE, 17 | PPC64LE 18 | }; 19 | } 20 | } 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /src/dale/Form/Linkage/Linkage.h: -------------------------------------------------------------------------------- 1 | #ifndef DALE_FORM_LINKAGE 2 | #define DALE_FORM_LINKAGE 3 | 4 | #include "../../Context/Context.h" 5 | #include "../../Node/Node.h" 6 | 7 | namespace dale { 8 | /*! Parse an enum linkage form. 9 | * @param ctx The context. 10 | * @param node The node containing the linkage. 11 | */ 12 | int FormLinkageParse(Context *ctx, Node *node); 13 | } 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /src/dale/Form/Linkage/Struct/Struct.h: -------------------------------------------------------------------------------- 1 | #ifndef DALE_FORM_LINKAGE_STRUCT 2 | #define DALE_FORM_LINKAGE_STRUCT 3 | 4 | #include "../../../Context/Context.h" 5 | #include "../../../Node/Node.h" 6 | 7 | namespace dale { 8 | /*! Parse a struct linkage form. 9 | * @param ctx The context. 10 | * @param node The node containing the linkage. 11 | */ 12 | int FormLinkageStructParse(Context *ctx, Node *node); 13 | } 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /src/dale/Form/Macro/ArrayDeref/ArrayDeref.h: -------------------------------------------------------------------------------- 1 | #ifndef DALE_FORM_MACRO_ARRAYDEREF 2 | #define DALE_FORM_MACRO_ARRAYDEREF 3 | 4 | #include "../../../Context/Context.h" 5 | #include "../../../Node/Node.h" 6 | 7 | namespace dale { 8 | /*! The array-dereference core macro form. 9 | * @param ctx The context. 10 | * @param node The node list. 11 | * 12 | * Expands (@$ array-ptr index) to (@ ($ array-ptr index)). 13 | */ 14 | Node *FormMacroArrayDerefParse(Context *ctx, Node *node); 15 | } 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /src/dale/Form/Macro/DerefStruct/DerefStruct.h: -------------------------------------------------------------------------------- 1 | #ifndef DALE_FORM_MACRO_DEREFSTRUCT 2 | #define DALE_FORM_MACRO_DEREFSTRUCT 3 | 4 | #include "../../../Context/Context.h" 5 | #include "../../../Node/Node.h" 6 | 7 | namespace dale { 8 | /*! The dereference-struct core macro form. 9 | * @param ctx The context. 10 | * @param node The node list. 11 | * 12 | * Expands (:@ struct-ptr element) to (: (@ struct-ptr) element). 13 | */ 14 | Node *FormMacroDerefStructParse(Context *ctx, Node *node); 15 | } 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /src/dale/Form/Macro/DerefStructDeref/DerefStructDeref.h: -------------------------------------------------------------------------------- 1 | #ifndef DALE_FORM_MACRO_DEREFSTRUCTDEREF 2 | #define DALE_FORM_MACRO_DEREFSTRUCTDEREF 3 | 4 | #include "../../../Context/Context.h" 5 | #include "../../../Node/Node.h" 6 | 7 | namespace dale { 8 | /*! The dereference-struct-dereference core macro form. 9 | * @param ctx The context. 10 | * @param node The node list. 11 | * 12 | * Expands (@:@ struct-ptr element) to (@ (: (@ struct-ptr) element)). 13 | */ 14 | Node *FormMacroDerefStructDerefParse(Context *ctx, Node *node); 15 | } 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /src/dale/Form/Macro/Setv/Setv.h: -------------------------------------------------------------------------------- 1 | #ifndef DALE_FORM_MACRO_SETV 2 | #define DALE_FORM_MACRO_SETV 3 | 4 | #include "../../../Context/Context.h" 5 | #include "../../../Node/Node.h" 6 | 7 | namespace dale { 8 | /*! The setv core macro form. 9 | * @param ctx The context. 10 | * @param node The node list. 11 | * 12 | * Expands (setv value new-value) to (setf (# value) new-value). 13 | */ 14 | Node *FormMacroSetvParse(Context *ctx, Node *node); 15 | } 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /src/dale/Form/Macro/StructDeref/StructDeref.h: -------------------------------------------------------------------------------- 1 | #ifndef DALE_FORM_MACRO_STRUCTDEREF 2 | #define DALE_FORM_MACRO_STRUCTDEREF 3 | 4 | #include "../../../Context/Context.h" 5 | #include "../../../Node/Node.h" 6 | 7 | namespace dale { 8 | /*! The struct-dereference core macro form. 9 | * @param ctx The context. 10 | * @param node The node list. 11 | * 12 | * Expands (@: struct element) to (@ (: struct element)). 13 | */ 14 | Node *FormMacroStructDerefParse(Context *ctx, Node *node); 15 | } 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /src/dale/Form/Proc/Include/Include.h: -------------------------------------------------------------------------------- 1 | #ifndef DALE_FORM_PROC_INCLUDE 2 | #define DALE_FORM_PROC_INCLUDE 3 | 4 | #include "../../../Units/Units.h" 5 | 6 | namespace dale { 7 | bool FormProcIncludeParse(Units *units, Function *fn, 8 | llvm::BasicBlock *block, Node *node, 9 | bool get_address, bool prefixed_with_core, 10 | ParseResult *pr); 11 | } 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /src/dale/Form/Struct/Struct.h: -------------------------------------------------------------------------------- 1 | #ifndef DALE_FORM_STRUCT 2 | #define DALE_FORM_STRUCT 3 | 4 | #include "../../Units/Units.h" 5 | 6 | namespace dale { 7 | /*! Parse a struct definition form. 8 | * @param units The units context. 9 | * @param node The node containing the definition. 10 | * @param name The name of the new struct type. 11 | */ 12 | bool FormStructParse(Units *units, Node *n, const char *name); 13 | } 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /src/dale/Form/TopLevel/Def/Def.h: -------------------------------------------------------------------------------- 1 | #ifndef DALE_FORM_TOPLEVEL_DEF 2 | #define DALE_FORM_TOPLEVEL_DEF 3 | 4 | #include "../../../Units/Units.h" 5 | 6 | namespace dale { 7 | /*! Parse a top-level def form. 8 | * @param units The units context. 9 | * @param node The node being parsed. 10 | */ 11 | bool FormTopLevelDefParse(Units *units, Node *node); 12 | } 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /src/dale/Form/TopLevel/Do/Do.h: -------------------------------------------------------------------------------- 1 | #ifndef DALE_FORM_TOPLEVEL_DO 2 | #define DALE_FORM_TOPLEVEL_DO 3 | 4 | #include "../../../Units/Units.h" 5 | 6 | namespace dale { 7 | /*! Parse a top-level do form. 8 | * @param units The units context. 9 | * @param node The node being parsed. 10 | */ 11 | bool FormTopLevelDoParse(Units *units, Node *node); 12 | } 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /src/dale/Form/TopLevel/Function/Function.cpp: -------------------------------------------------------------------------------- 1 | #include "Function.h" 2 | #include "../../../Node/Node.h" 3 | #include "../../../Units/Units.h" 4 | #include "../../Function/Function.h" 5 | #include "Config.h" 6 | 7 | namespace dale { 8 | bool FormTopLevelFunctionParse(Units *units, Node *node, 9 | const char *name) { 10 | return FormFunctionParse(units, node, name, NULL, Linkage::Null, 0); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/dale/Form/TopLevel/Function/Function.h: -------------------------------------------------------------------------------- 1 | #ifndef DALE_FORM_TOPLEVEL_FUNCTION 2 | #define DALE_FORM_TOPLEVEL_FUNCTION 3 | 4 | #include "../../../Units/Units.h" 5 | 6 | namespace dale { 7 | /*! Parse a top-level function form. 8 | * @param units The units context. 9 | * @param node The node being parsed. 10 | * @param name The unqualified name of the function being parsed. 11 | */ 12 | bool FormTopLevelFunctionParse(Units *units, Node *node, 13 | const char *name); 14 | } 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /src/dale/Form/TopLevel/GlobalVariable/GlobalVariable.h: -------------------------------------------------------------------------------- 1 | #ifndef DALE_FORM_TOPLEVEL_GLOBALVARIABLE 2 | #define DALE_FORM_TOPLEVEL_GLOBALVARIABLE 3 | 4 | #include "../../../Units/Units.h" 5 | 6 | namespace dale { 7 | /*! Parse a top-level global variable form. 8 | * @param units The units context. 9 | * @param node The node being parsed. 10 | * @param name The unqualified name of the variable being parsed. 11 | */ 12 | bool FormTopLevelGlobalVariableParse(Units *units, Node *node, 13 | const char *name); 14 | } 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /src/dale/Form/TopLevel/Import/Import.h: -------------------------------------------------------------------------------- 1 | #ifndef DALE_FORM_TOPLEVEL_IMPORT 2 | #define DALE_FORM_TOPLEVEL_IMPORT 3 | 4 | #include "../../../Units/Units.h" 5 | 6 | namespace dale { 7 | /*! Parse a top-level import form. 8 | * @param units The units context. 9 | * @param node The node containing the import form. 10 | */ 11 | bool FormTopLevelImportParse(Units *units, Node *node); 12 | } 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /src/dale/Form/TopLevel/Include/Include.h: -------------------------------------------------------------------------------- 1 | #ifndef DALE_FORM_TOPLEVEL_INCLUDE 2 | #define DALE_FORM_TOPLEVEL_INCLUDE 3 | 4 | #include "../../../Units/Units.h" 5 | 6 | namespace dale { 7 | /*! Parse a top-level include form. 8 | * @param units The units context. 9 | * @param node The node being parsed. 10 | */ 11 | bool FormTopLevelIncludeParse(Units *units, Node *node); 12 | } 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /src/dale/Form/TopLevel/Inst/Inst.h: -------------------------------------------------------------------------------- 1 | #ifndef DALE_FORM_TOPLEVEL_INST 2 | #define DALE_FORM_TOPLEVEL_INST 3 | 4 | #include "../../../Units/Units.h" 5 | 6 | namespace dale { 7 | /*! Parse an arbitrary top-level form. 8 | * @param units The units context. 9 | * @param block The node to be parsed. 10 | */ 11 | bool FormTopLevelInstParse(Units *units, Node *node); 12 | } 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /src/dale/Form/TopLevel/Macro/Macro.h: -------------------------------------------------------------------------------- 1 | #ifndef DALE_FORM_TOPLEVEL_MACRO 2 | #define DALE_FORM_TOPLEVEL_MACRO 3 | 4 | #include "../../../Units/Units.h" 5 | 6 | namespace dale { 7 | /*! Parse a top-level macro form. 8 | * @param units The units context. 9 | * @param node The node being parsed. 10 | * @param name The unqualified name of the macro being parsed. 11 | */ 12 | bool FormTopLevelMacroParse(Units *units, Node *node, const char *name); 13 | } 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /src/dale/Form/TopLevel/Module/Module.h: -------------------------------------------------------------------------------- 1 | #ifndef DALE_FORM_TOPLEVEL_MODULE 2 | #define DALE_FORM_TOPLEVEL_MODULE 3 | 4 | #include "../../../Units/Units.h" 5 | 6 | namespace dale { 7 | /*! Parse a top-level module form. 8 | * @param units The units context. 9 | * @param node The node being parsed. 10 | */ 11 | bool FormTopLevelModuleParse(Units *units, Node *node); 12 | } 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /src/dale/Form/TopLevel/Namespace/Namespace.h: -------------------------------------------------------------------------------- 1 | #ifndef DALE_FORM_TOPLEVEL_NAMESPACE 2 | #define DALE_FORM_TOPLEVEL_NAMESPACE 3 | 4 | #include "../../../Units/Units.h" 5 | 6 | namespace dale { 7 | /*! Parse a top-level namespace form. 8 | * @param units The units context. 9 | * @param node The node containing the namespace form. 10 | */ 11 | bool FormTopLevelNamespaceParse(Units *units, Node *node); 12 | } 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /src/dale/Form/TopLevel/Struct/Struct.h: -------------------------------------------------------------------------------- 1 | #ifndef DALE_FORM_TOPLEVEL_STRUCT 2 | #define DALE_FORM_TOPLEVEL_STRUCT 3 | 4 | #include "../../../Units/Units.h" 5 | 6 | namespace dale { 7 | /*! Parse a top-level struct form. 8 | * @param units The units context. 9 | * @param node The node being parsed. 10 | * @param name The unqualified name of the struct being parsed. 11 | */ 12 | bool FormTopLevelStructParse(Units *units, Node *n, const char *name); 13 | } 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /src/dale/Form/TopLevel/UsingNamespace/UsingNamespace.h: -------------------------------------------------------------------------------- 1 | #ifndef DALE_FORM_TOPLEVEL_USINGNAMESPACE 2 | #define DALE_FORM_TOPLEVEL_USINGNAMESPACE 3 | 4 | #include "../../../Units/Units.h" 5 | 6 | namespace dale { 7 | /*! Parse a top-level using-namespace form. 8 | * @param units The units context. 9 | * @param node The node being parsed. 10 | */ 11 | bool FormTopLevelUsingNamespaceParse(Units *units, Node *node); 12 | } 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /src/dale/Label/Label.cpp: -------------------------------------------------------------------------------- 1 | #include "Label.h" 2 | 3 | namespace dale { 4 | Label::Label(llvm::BasicBlock *block, Namespace *ns, int index) { 5 | this->index = index; 6 | this->block = block; 7 | this->ns = ns; 8 | } 9 | 10 | Label::~Label() {} 11 | } 12 | -------------------------------------------------------------------------------- /src/dale/Operation/Move/Move.cpp: -------------------------------------------------------------------------------- 1 | #include "Move.h" 2 | 3 | namespace dale { 4 | namespace Operation { 5 | bool Move(Context *ctx, Function *fn, ParseResult *pr, 6 | ParseResult *ret_pr) { 7 | pr->copyTo(ret_pr); 8 | ret_pr->value_is_lvalue = false; 9 | ret_pr->do_not_copy_with_setf = true; 10 | return true; 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/dale/incl.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | 3 | use warnings; 4 | use strict; 5 | 6 | my @paths = map { chomp; $_ } `find . -type f`; 7 | for my $path (@paths) { 8 | my $includes = `cat $path | grep '^#include' | wc -l`; 9 | chomp $includes; 10 | if ($includes > 10) { 11 | print "$path: $includes\n"; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/dale/llvm_AnalysisVerifier.h: -------------------------------------------------------------------------------- 1 | #include "Config.h" 2 | #if D_LLVM_VERSION_ORD <= 34 3 | #include "llvm/Analysis/Verifier.h" 4 | #else 5 | #include "llvm/IR/Verifier.h" 6 | #endif 7 | -------------------------------------------------------------------------------- /src/dale/llvm_AssemblyPrintModulePass.h: -------------------------------------------------------------------------------- 1 | #include "Config.h" 2 | #if D_LLVM_VERSION_ORD <= 34 3 | #include "llvm/Assembly/PrintModulePass.h" 4 | #else 5 | #include "llvm/IR/IRPrintingPasses.h" 6 | #endif 7 | -------------------------------------------------------------------------------- /src/dale/llvm_CallingConv.h: -------------------------------------------------------------------------------- 1 | #include "Config.h" 2 | #if D_LLVM_VERSION_ORD <= 32 3 | #include "llvm/CallingConv.h" 4 | #else 5 | #include "llvm/IR/CallingConv.h" 6 | #endif 7 | -------------------------------------------------------------------------------- /src/dale/llvm_Function.h: -------------------------------------------------------------------------------- 1 | #include "Config.h" 2 | #if D_LLVM_VERSION_ORD <= 32 3 | #include "llvm/Function.h" 4 | #else 5 | #include "llvm/IR/Function.h" 6 | #endif 7 | -------------------------------------------------------------------------------- /src/dale/llvm_IRBuilder.h: -------------------------------------------------------------------------------- 1 | #include "Config.h" 2 | #if D_LLVM_VERSION_ORD == 32 3 | #include "llvm/DataLayout.h" 4 | #include "llvm/IRBuilder.h" 5 | #include "llvm/TypeBuilder.h" 6 | #elif D_LLVM_VERSION_ORD <= 70 7 | #include "llvm/IR/DataLayout.h" 8 | #include "llvm/IR/IRBuilder.h" 9 | #include "llvm/IR/TypeBuilder.h" 10 | #else 11 | #include "llvm/IR/DataLayout.h" 12 | #include "llvm/IR/IRBuilder.h" 13 | #endif 14 | -------------------------------------------------------------------------------- /src/dale/llvm_LLVMContext.h: -------------------------------------------------------------------------------- 1 | #include "Config.h" 2 | #if D_LLVM_VERSION_ORD <= 32 3 | #include "llvm/LLVMContext.h" 4 | #else 5 | #include "llvm/IR/LLVMContext.h" 6 | #endif 7 | -------------------------------------------------------------------------------- /src/dale/llvm_LinkAll.h: -------------------------------------------------------------------------------- 1 | #include "Config.h" 2 | #if D_LLVM_VERSION_ORD <= 32 3 | #include "llvm/LinkAllVMCore.h" 4 | #else 5 | #include "llvm/LinkAllIR.h" 6 | #endif 7 | #include "llvm/CodeGen/LinkAllAsmWriterComponents.h" 8 | #include "llvm/CodeGen/LinkAllCodegenComponents.h" 9 | #include "llvm/LinkAllPasses.h" 10 | -------------------------------------------------------------------------------- /src/dale/llvm_Linker.h: -------------------------------------------------------------------------------- 1 | #include "Config.h" 2 | #if D_LLVM_VERSION_ORD <= 34 3 | #include "llvm/Linker.h" 4 | #else 5 | #include "llvm/Linker/Linker.h" 6 | #endif 7 | -------------------------------------------------------------------------------- /src/dale/llvm_Module.h: -------------------------------------------------------------------------------- 1 | #include "Config.h" 2 | #if D_LLVM_VERSION_ORD <= 32 3 | #include "llvm/Module.h" 4 | #else 5 | #include "llvm/IR/Module.h" 6 | #endif 7 | -------------------------------------------------------------------------------- /src/dale/llvm_PassManager.h: -------------------------------------------------------------------------------- 1 | #include "Config.h" 2 | #if D_LLVM_VERSION_ORD <= 35 3 | #include "llvm/PassManager.h" 4 | #else 5 | #include "llvm/IR/LegacyPassManager.h" 6 | #endif 7 | -------------------------------------------------------------------------------- /src/dale/llvm_ValueSymbolTable.h: -------------------------------------------------------------------------------- 1 | #include "Config.h" 2 | #if D_LLVM_VERSION_ORD <= 32 3 | #include "llvm/ValueSymbolTable.h" 4 | #else 5 | #include "llvm/IR/ValueSymbolTable.h" 6 | #endif 7 | -------------------------------------------------------------------------------- /t/001basic/132no-op.t: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | 3 | use warnings; 4 | use strict; 5 | $ENV{"DALE_TEST_ARGS"} ||= ""; 6 | my $test_dir = $ENV{"DALE_TEST_DIR"} || "."; 7 | $ENV{PATH} .= ":."; 8 | 9 | use Data::Dumper; 10 | use Test::More tests => 3; 11 | 12 | my @res = `dalec $ENV{"DALE_TEST_ARGS"} -lm $test_dir/t/src/no-op.dt -o no-op`; 13 | is(@res, 0, 'No compilation errors'); 14 | 15 | @res = `./no-op`; 16 | is($?, 0, 'Program executed successfully'); 17 | 18 | chomp for @res; 19 | is_deeply(\@res, ['1'], 'Got expected results'); 20 | 21 | `rm no-op`; 22 | 23 | 1; 24 | -------------------------------------------------------------------------------- /t/004namespace/009anonfn-scope.t: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | 3 | use warnings; 4 | use strict; 5 | $ENV{"DALE_TEST_ARGS"} ||= ""; 6 | my $test_dir = $ENV{"DALE_TEST_DIR"} || "."; 7 | $ENV{PATH} .= ":."; 8 | 9 | use Data::Dumper; 10 | use Test::More tests => 1; 11 | 12 | my $res = `dalec $ENV{"DALE_TEST_ARGS"} $test_dir/t/src/anonfn-scope.dt -o anonfn-scope`; 13 | is($res, "*Struct* exists\n*Struct* exists\n", "Got expected results"); 14 | 15 | `rm anonfn-scope`; 16 | 17 | 1; 18 | -------------------------------------------------------------------------------- /t/008compiler/016is-lvalue.t: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | 3 | use warnings; 4 | use strict; 5 | $ENV{"DALE_TEST_ARGS"} ||= ""; 6 | my $test_dir = $ENV{"DALE_TEST_DIR"} || "."; 7 | $ENV{PATH} .= ":."; 8 | 9 | use Data::Dumper; 10 | use Test::More tests => 1; 11 | 12 | my @res = `dalec $ENV{"DALE_TEST_ARGS"} $test_dir/t/src/is-lvalue.dt -o is-lvalue `; 13 | chomp for @res; 14 | is_deeply(\@res, [qw(0 1 1 1 1 1 0)], 'Got expected results'); 15 | `rm is-lvalue`; 16 | 17 | 1; 18 | -------------------------------------------------------------------------------- /t/008compiler/017eval-macro-call.t: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | 3 | use warnings; 4 | use strict; 5 | $ENV{"DALE_TEST_ARGS"} ||= ""; 6 | my $test_dir = $ENV{"DALE_TEST_DIR"} || "."; 7 | $ENV{PATH} .= ":."; 8 | 9 | use Data::Dumper; 10 | use Test::More tests => 1; 11 | 12 | my @res = `dalec $ENV{"DALE_TEST_ARGS"} $test_dir/t/src/eval-macro-call.dt -o eval-macro-call `; 13 | chomp for @res; 14 | is_deeply(\@res, ['(b)', '123', '(c)', '123', '(d)', '123', '123', '123'], 15 | 'Got expected results'); 16 | `rm eval-macro-call`; 17 | 18 | 1; 19 | -------------------------------------------------------------------------------- /t/999last/111github-147.t: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | 3 | use warnings; 4 | use strict; 5 | $ENV{"DALE_TEST_ARGS"} ||= ""; 6 | my $test_dir = $ENV{"DALE_TEST_DIR"} || "."; 7 | $ENV{PATH} .= ":."; 8 | 9 | use Data::Dumper; 10 | use Test::More tests => 1; 11 | 12 | my @res = `dalec $ENV{"DALE_TEST_ARGS"} -lm $test_dir/t/src/incorrect-cto-error.dt -o incorrect-cto-error`; 13 | is(@res, 0, 'No compilation errors'); 14 | 15 | `rm incorrect-cto-error`; 16 | 17 | 1; 18 | -------------------------------------------------------------------------------- /t/999last/115github-197.t: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | 3 | use warnings; 4 | use strict; 5 | $ENV{"DALE_TEST_ARGS"} ||= ""; 6 | my $test_dir = $ENV{"DALE_TEST_DIR"} || "."; 7 | $ENV{PATH} .= ":."; 8 | 9 | use Data::Dumper; 10 | use Test::More tests => 1; 11 | 12 | my @res = `dalec $ENV{"DALE_TEST_ARGS"} -c $test_dir/t/src/lfc-problem.dt -o lfc-problem`; 13 | is(@res, 0, 'No compilation errors'); 14 | 15 | `rm lfc-problem`; 16 | 17 | 1; 18 | -------------------------------------------------------------------------------- /t/999last/116github-199.t: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | 3 | use warnings; 4 | use strict; 5 | $ENV{"DALE_TEST_ARGS"} ||= ""; 6 | my $test_dir = $ENV{"DALE_TEST_DIR"} || "."; 7 | $ENV{PATH} .= ":."; 8 | 9 | use Data::Dumper; 10 | use Test::More tests => 2; 11 | 12 | my @res = `dalec $ENV{"DALE_TEST_ARGS"} -lm $test_dir/t/src/gh-199.dt -o gh-199`; 13 | is(@res, 0, 'No compilation errors'); 14 | 15 | @res = `./gh-199`; 16 | 17 | chomp for @res; 18 | is_deeply(\@res, ['1'], 19 | 'Got expected results'); 20 | 21 | `rm gh-199`; 22 | 23 | 1; 24 | -------------------------------------------------------------------------------- /t/999last/117github-205.t: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | 3 | use warnings; 4 | use strict; 5 | $ENV{"DALE_TEST_ARGS"} ||= ""; 6 | my $test_dir = $ENV{"DALE_TEST_DIR"} || "."; 7 | $ENV{PATH} .= ":."; 8 | 9 | use Data::Dumper; 10 | use Test::More tests => 3; 11 | 12 | my @res = `dalec $ENV{"DALE_TEST_ARGS"} -lm $test_dir/t/src/gh-205.dt -o gh-205`; 13 | is(@res, 0, 'No compilation errors'); 14 | 15 | @res = `./gh-205`; 16 | is($?, 0, 'Program executed successfully'); 17 | 18 | chomp for @res; 19 | is(@res, 1, 'Got one result'); 20 | 21 | `rm gh-205`; 22 | 23 | 1; 24 | -------------------------------------------------------------------------------- /t/error-src/address-of.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def myfn (fn intern int ((c char)) 0)) 4 | (def myfn (fn intern int ((# int)) 0)) 5 | 6 | (def main 7 | (fn extern-c int (void) 8 | (def n2 (var auto (p (fn int ((# int)))) (# myfn))) 9 | 0)) 10 | -------------------------------------------------------------------------------- /t/error-src/address-of.dt.errors: -------------------------------------------------------------------------------- 1 | ./t/error-src/address-of.dt:8:46: error: overloaded function/macro not in scope: 'myfn' (parameters are void, closest candidate expects char) 2 | -------------------------------------------------------------------------------- /t/error-src/anonymous-scopes.dt: -------------------------------------------------------------------------------- 1 | (import stdlib) 2 | 3 | (def main (fn extern-c void (void) 4 | (def var2 (var intern int 0)) ;if this is a global variable, it works 5 | (let ((fun \ (fn void (void) 6 | (incv var2) 7 | (return)))) 8 | (fun) 9 | (fun)))) 10 | -------------------------------------------------------------------------------- /t/error-src/anonymous-scopes.dt.errors: -------------------------------------------------------------------------------- 1 | ./t/error-src/anonymous-scopes.dt:6:17: error: variable not in scope or cannot be used as value: 'var2' (see macro at 6:11) 2 | -------------------------------------------------------------------------------- /t/error-src/aref-non-int.dt: -------------------------------------------------------------------------------- 1 | (def main (fn extern-c int (void) 2 | (def x (var auto (array-of 10 int))) 3 | (setf ($ x "asdf") 10) 4 | 0)) 5 | -------------------------------------------------------------------------------- /t/error-src/aref-non-int.dt.errors: -------------------------------------------------------------------------------- 1 | ./t/error-src/aref-non-int.dt:3:14: error: expected expression with type integer (got type (p (const char)) instead) 2 | -------------------------------------------------------------------------------- /t/error-src/arity-atom.dt: -------------------------------------------------------------------------------- 1 | (import introspection) 2 | (import macros) 3 | 4 | (using-namespace std.macros 5 | (def aritym (macro intern (F) 6 | (mnfv mc (arity mc F)))) 7 | 8 | (def main (fn extern-c int (void) 9 | (printf "%d\n" (aritym (q (bool + int int)))) 10 | (printf "%d\n" (aritym +)) 11 | 0))) 12 | -------------------------------------------------------------------------------- /t/error-src/arity-atom.dt.errors: -------------------------------------------------------------------------------- 1 | ./t/error-src/arity-atom.dt:9:27: error: expected atom for function name (got list instead) (see macro at 9:19) 2 | ./t/error-src/arity-atom.dt:9:19: error: macro expansion error (see previous) 3 | ./t/error-src/arity-atom.dt:10:27: error: arity may only be called with extern-c function names (see macro at 10:19) 4 | ./t/error-src/arity-atom.dt:10:19: error: macro expansion error (see previous) 5 | -------------------------------------------------------------------------------- /t/error-src/attrs-match.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | (import macros) 3 | 4 | (def main 5 | (fn extern-c int (void))) 6 | 7 | (def main 8 | (fn (attr inline) extern-c int (void) 9 | (let ((i \ 0) 10 | (j \ 0)) 11 | (printf "%d\n" j)) 12 | 0)) 13 | -------------------------------------------------------------------------------- /t/error-src/attrs-match.dt.errors: -------------------------------------------------------------------------------- 1 | ./t/error-src/attrs-match.dt:8:3: error: attributes for the declaration of function 'main' do not match the attributes for the definition 2 | -------------------------------------------------------------------------------- /t/error-src/auto-linkage.dt: -------------------------------------------------------------------------------- 1 | (def v1 (var auto int 100)) 2 | 3 | (namespace n 4 | (def v2 (var auto int 100))) 5 | -------------------------------------------------------------------------------- /t/error-src/auto-linkage.dt.errors: -------------------------------------------------------------------------------- 1 | t/error-src/auto-linkage.dt:1:14: error: auto linkage not permitted outside of function scope 2 | t/error-src/auto-linkage.dt:4:16: error: auto linkage not permitted outside of function scope 3 | -------------------------------------------------------------------------------- /t/error-src/bad-array.dt: -------------------------------------------------------------------------------- 1 | (def blah (var intern (array-of 10 20 int))) 2 | -------------------------------------------------------------------------------- /t/error-src/bad-array.dt.errors: -------------------------------------------------------------------------------- 1 | ./t/error-src/bad-array.dt:1:23: error: 'array-of' requires 2 arguments (got 3 instead) 2 | -------------------------------------------------------------------------------- /t/error-src/bad-attribute.dt: -------------------------------------------------------------------------------- 1 | (def test 2 | (fn (attr notexists) extern int (void))) 3 | -------------------------------------------------------------------------------- /t/error-src/bad-attribute.dt.errors: -------------------------------------------------------------------------------- 1 | ./t/error-src/bad-attribute.dt:2:13: error: invalid attribute 2 | -------------------------------------------------------------------------------- /t/error-src/bad-fp.dt: -------------------------------------------------------------------------------- 1 | (include 1.1.1) 2 | -------------------------------------------------------------------------------- /t/error-src/bad-fp.dt.errors: -------------------------------------------------------------------------------- 1 | ./t/error-src/bad-fp.dt:1:10: error: invalid floating point number 2 | -------------------------------------------------------------------------------- /t/error-src/bad-integer.dt: -------------------------------------------------------------------------------- 1 | (include 1aaaa) 2 | -------------------------------------------------------------------------------- /t/error-src/bad-integer.dt.errors: -------------------------------------------------------------------------------- 1 | ./t/error-src/bad-integer.dt:1:10: error: invalid integer 2 | -------------------------------------------------------------------------------- /t/error-src/bad-linkage.dt: -------------------------------------------------------------------------------- 1 | (def temp (macro blahblah blahblah)) 2 | -------------------------------------------------------------------------------- /t/error-src/bad-linkage.dt.errors: -------------------------------------------------------------------------------- 1 | ./t/error-src/bad-linkage.dt:1:18: error: expected extern/intern/auto/extern-c for linkage (got blahblah instead) 2 | -------------------------------------------------------------------------------- /t/error-src/bad-mod-name.dt: -------------------------------------------------------------------------------- 1 | (module !!!!!!!) 2 | -------------------------------------------------------------------------------- /t/error-src/bad-mod-name.dt.errors: -------------------------------------------------------------------------------- 1 | ./t/error-src/bad-mod-name.dt:1:9: error: module name '!!!!!!!' is invalid: module names may only comprise alphanumeric characters, periods, hyphens and underscores 2 | -------------------------------------------------------------------------------- /t/error-src/concept-errors.dt.errors: -------------------------------------------------------------------------------- 1 | ./t/error-src/concept-errors.dt:10:46: error: refinement concept does not exist (see macro at 10:1) 2 | ./t/error-src/concept-errors.dt:10:1: error: macro expansion error (see previous) 3 | ./t/error-src/concept-errors.dt:40:19: error: no applicable concept macro found (arguments implement the following concepts: Addable; current candidates accept: AddableAndSubtractable) (see macro at 40:1) 4 | ./t/error-src/concept-errors.dt:40:1: error: macro expansion error (see previous) 5 | -------------------------------------------------------------------------------- /t/error-src/concept-not-implemented.dt: -------------------------------------------------------------------------------- 1 | (import concepts-core) 2 | 3 | (using-namespace std.macros (using-namespace std.concepts 4 | (def-concept Addable (refines) (T) 5 | (if (exists-fn mc (qq bool + (uq T) (uq T))) 6 | true 7 | (do (report-error mc T "type does not implement Addable") 8 | false))) 9 | 10 | (def f (struct intern ((a char)))) 11 | 12 | (implement Addable f) 13 | )) 14 | 15 | (def main 16 | (fn extern-c int (void) 17 | 0)) 18 | -------------------------------------------------------------------------------- /t/error-src/concept-not-implemented.dt.errors: -------------------------------------------------------------------------------- 1 | ./t/error-src/concept-not-implemented.dt:12:20: error: type does not implement Addable (see macro at \d+:\d+) 2 | .*/concepts-core.dt:\d+:\d+: error: macro expansion error (see previous) (see macro at 12:1) 3 | -------------------------------------------------------------------------------- /t/error-src/cond.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | (import stdlib) 3 | 4 | (def main (fn extern-c int (void) 5 | (cond) 6 | (cond 1) 7 | (cond (true 1)) 8 | (cond (true 1) true) 9 | (cond (false) true) 10 | (cond (false false false) true) 11 | (cond (true 1) (false 0)) 12 | 0)) 13 | -------------------------------------------------------------------------------- /t/error-src/const-basic.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (using-namespace std 4 | 5 | (def main 6 | (fn extern-c int (void) 7 | (def n (var auto (const int) 100)) 8 | (def pn (var auto (const (p (const int))) (# n))) 9 | (setv n 200) 10 | (setv pn (# n)) 11 | (setf pn 200) 12 | 13 | 14 | 0)) 15 | 16 | 17 | ) 18 | -------------------------------------------------------------------------------- /t/error-src/const-basic.dt.errors: -------------------------------------------------------------------------------- 1 | ./t/error-src/const-basic.dt:9:5: error: cannot modify const variable 2 | ./t/error-src/const-basic.dt:10:5: error: cannot modify const variable 3 | ./t/error-src/const-basic.dt:11:5: error: cannot modify const variable 4 | -------------------------------------------------------------------------------- /t/error-src/const-init.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def main 4 | (fn extern-c int (void) 5 | (def n (var auto (const int))) 6 | (def pn (var auto (const (p (const int))))) 7 | (setv n 200) 8 | (setv pn (# n)) 9 | (setf pn 200) 10 | 0)) 11 | -------------------------------------------------------------------------------- /t/error-src/const-init.dt.errors: -------------------------------------------------------------------------------- 1 | ./t/error-src/const-init.dt:5:12: error: must have initialiser for variable with const type 2 | ./t/error-src/const-init.dt:6:13: error: must have initialiser for variable with const type 3 | ./t/error-src/const-init.dt:7:5: error: cannot modify const variable 4 | ./t/error-src/const-init.dt:8:5: error: cannot modify const variable 5 | ./t/error-src/const-init.dt:9:5: error: cannot modify const variable 6 | -------------------------------------------------------------------------------- /t/error-src/const-no-overload.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def testfn 4 | (fn extern int ((n int)) 5 | 102)) 6 | 7 | (def testfn 8 | (fn extern int ((n (const int))) 9 | 101)) 10 | 11 | (def main 12 | (fn extern-c int (void) 13 | (printf "%d\n" (testfn 100)) 14 | 0)) 15 | -------------------------------------------------------------------------------- /t/error-src/const-no-overload.dt.errors: -------------------------------------------------------------------------------- 1 | ./t/error-src/const-no-overload.dt:8:3: error: function/macro 'testfn' has already been defined in this scope 2 | -------------------------------------------------------------------------------- /t/error-src/const-refs.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def increment (fn extern int ((a (ref int))) 4 | (setf a (+ (@ a) 1)) 5 | (@ a))) 6 | 7 | (def main (fn extern-c int (void) 8 | (def x (var auto int 0)) 9 | (printf "%d\n" x) 10 | (increment x) 11 | (printf "%d\n" x) 12 | (increment 5) 13 | (printf "%d\n" x) 14 | 0)) 15 | -------------------------------------------------------------------------------- /t/error-src/const-refs.dt.errors: -------------------------------------------------------------------------------- 1 | ./t/error-src/const-refs.dt:12:3: error: overloaded function/macro not in scope: 'increment' (parameters are int, closest candidate expects (ref int)) 2 | -------------------------------------------------------------------------------- /t/error-src/const-rv-2.dt.errors: -------------------------------------------------------------------------------- 1 | ./t/error-src/const-rv-2.dt:27:3: error: copying is disabled for this type 2 | -------------------------------------------------------------------------------- /t/error-src/const-rv.dt.errors: -------------------------------------------------------------------------------- 1 | ./t/error-src/const-rv.dt:32:3: error: copying is disabled for this type 2 | ./t/error-src/const-rv.dt:33:3: error: overloaded function/macro not in scope: 'no-call' (parameters are (const mys), closest candidate expects (rv-ref mys)) 3 | ./t/error-src/const-rv.dt:34:3: error: overloaded function/macro not in scope: 'no-call' (parameters are (const mys), closest candidate expects (rv-ref mys)) 4 | -------------------------------------------------------------------------------- /t/error-src/const-string.dt: -------------------------------------------------------------------------------- 1 | (import cstring) 2 | 3 | (def myfn (fn intern bool ((str (p char))) 4 | true)) 5 | 6 | (def main (fn extern-c int (void) 7 | (def mystr (var auto (p (const char)) "asdf")) 8 | (myfn mystr) 9 | (def mystr2 (var auto (p char) "asdf")) 10 | 0)) 11 | -------------------------------------------------------------------------------- /t/error-src/const-string.dt.errors: -------------------------------------------------------------------------------- 1 | ./t/error-src/const-string.dt:8:3: error: overloaded function/macro not in scope: 'myfn' (parameters are (p (const char)), closest candidate expects (p char)) 2 | ./t/error-src/const-string.dt:9:3: error: expected expression with type (p char) (got type (p (const char)) instead) 3 | -------------------------------------------------------------------------------- /t/error-src/const-struct.dt.errors: -------------------------------------------------------------------------------- 1 | ./t/error-src/const-struct.dt:21:5: error: cannot modify const variable 2 | ./t/error-src/const-struct.dt:22:5: error: cannot modify const variable 3 | ./t/error-src/const-struct.dt:23:5: error: cannot modify const variable 4 | -------------------------------------------------------------------------------- /t/error-src/core-with-list.dt: -------------------------------------------------------------------------------- 1 | (def main (fn extern-c int (void) 2 | (core) 3 | (core (setf (# a) 10)) 4 | (core 1) 5 | 0)) 6 | -------------------------------------------------------------------------------- /t/error-src/core-with-list.dt.errors: -------------------------------------------------------------------------------- 1 | ./t/error-src/core-with-list.dt:2:3: error: 'core' requires at least 1 arguments (got 0 instead) 2 | ./t/error-src/core-with-list.dt:3:9: error: expected atom for core form name (got list instead) 3 | ./t/error-src/core-with-list.dt:4:9: error: expected symbol for core form name (got integer instead) 4 | -------------------------------------------------------------------------------- /t/error-src/cross-decl.dt.errors: -------------------------------------------------------------------------------- 1 | ./t/error-src/cross-decl.dt:6:7: error: this goto will cross a declaration 2 | ./t/error-src/cross-decl.dt:19:7: error: this goto will cross a declaration 3 | -------------------------------------------------------------------------------- /t/error-src/cto-addr-from-non-cto.dt: -------------------------------------------------------------------------------- 1 | (def mfn (fn (attr cto) intern int (void) 100)) 2 | 3 | (def main (fn extern-c int (void) 4 | (def x (var auto \ (# mfn))) 5 | 0)) 6 | -------------------------------------------------------------------------------- /t/error-src/cto-addr-from-non-cto.dt.errors: -------------------------------------------------------------------------------- 1 | ./t/error-src/cto-addr-from-non-cto.dt:4:22: error: can only take address of CTO function from macro or other CTO function 2 | -------------------------------------------------------------------------------- /t/error-src/cto-anon-from-non-cto.dt: -------------------------------------------------------------------------------- 1 | (def main (fn extern-c int (void) 2 | (def x (var auto \ (fn (attr cto) int (void) 100))) 3 | 0)) 4 | -------------------------------------------------------------------------------- /t/error-src/cto-anon-from-non-cto.dt.errors: -------------------------------------------------------------------------------- 1 | ./t/error-src/cto-anon-from-non-cto.dt:2:22: error: can only use anonymous CTO functions from macros or other CTO functions 2 | -------------------------------------------------------------------------------- /t/error-src/cto-from-non-cto.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def myfn (fn (attr cto) intern int ((n int)) 4 | (* 2 n))) 5 | 6 | (def main (fn extern-c int (void) 7 | (printf "%d\n" (myfn 2)) 8 | 0)) 9 | -------------------------------------------------------------------------------- /t/error-src/cto-from-non-cto.dt.errors: -------------------------------------------------------------------------------- 1 | cto-from-non-cto.dt:7:17: error: CTO functions may only be called from macros or other CTO functions 2 | -------------------------------------------------------------------------------- /t/error-src/empty-list-in-fn.dt: -------------------------------------------------------------------------------- 1 | (def main (fn extern-c int (void) ())) 2 | -------------------------------------------------------------------------------- /t/error-src/empty-list-in-fn.dt.errors: -------------------------------------------------------------------------------- 1 | ./t/error-src/empty-list-in-fn.dt:1:35: error: lists cannot be empty 2 | -------------------------------------------------------------------------------- /t/error-src/empty-list-in-macro.dt: -------------------------------------------------------------------------------- 1 | (import macros) 2 | 3 | (using-namespace std.macros 4 | (def def-type-alias (macro extern (new old) 5 | (qq def (uq new) (macro extern () 6 | (uq old)))))) 7 | 8 | (def b (var intern int 0)) 9 | 10 | (def-type-alias a b) 11 | -------------------------------------------------------------------------------- /t/error-src/empty-list-in-macro.dt.errors: -------------------------------------------------------------------------------- 1 | ./t/error-src/empty-list-in-macro.dt:5:36: error: lists cannot be empty (see macro at 10:1) 2 | -------------------------------------------------------------------------------- /t/error-src/enum-problem.dt: -------------------------------------------------------------------------------- 1 | (import enum) 2 | (def-enum myenum extern int (True False ((b int)))) 3 | -------------------------------------------------------------------------------- /t/error-src/enum-problem.dt.errors: -------------------------------------------------------------------------------- 1 | ./t/error-src/enum-problem.dt:2:29: error: two arguments required for enum element form (see macro at 2:1) 2 | ./t/error-src/enum-problem.dt:2:1: error: macro expansion error (see previous) 3 | -------------------------------------------------------------------------------- /t/error-src/excess-var-arguments.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | (import stdlib) 3 | 4 | (def x (var intern int 0 0)) 5 | (def y (var intern int 0)) 6 | 7 | (def main (fn extern-c int (void) 8 | (def x (var auto int 0 0)) 9 | (def y (var auto int 0)) 10 | (let ((m \ y y)) 11 | (printf "%d\n" m)) 12 | 0)) 13 | -------------------------------------------------------------------------------- /t/error-src/excess-var-arguments.dt.errors: -------------------------------------------------------------------------------- 1 | t/error-src/excess-var-arguments.dt:4:8: error: 'var' takes at most 3 arguments (got 4 instead) 2 | t/error-src/excess-var-arguments.dt:8:10: error: 'var' takes at most 3 arguments (got 4 instead) 3 | t/error-src/excess-var-arguments.dt:10:14: error: variable form has too many arguments (see macro at 10:3) 4 | t/error-src/excess-var-arguments.dt:10:3: error: macro expansion error (see previous) 5 | -------------------------------------------------------------------------------- /t/error-src/expansion-error.dt.errors: -------------------------------------------------------------------------------- 1 | ./t/error-src/expansion-error.dt:10:13: error: unquoting null node (see macro at 8:5) 2 | ./t/error-src/expansion-error.dt:13:1: error: macro expansion error (see previous) 3 | -------------------------------------------------------------------------------- /t/error-src/expected-int.dt: -------------------------------------------------------------------------------- 1 | (def v (var intern int (do (return "a")))) 2 | 3 | (def v (var intern int 1.10)) 4 | 5 | (def v (var intern int ())) 6 | -------------------------------------------------------------------------------- /t/error-src/expected-int.dt.errors: -------------------------------------------------------------------------------- 1 | ./t/error-src/expected-int.dt:1:28: error: expected return expression with type int (got type (p (const char)) instead) 2 | ./t/error-src/expected-int.dt:3:24: error: expected return expression with type int (got type float instead) 3 | ./t/error-src/expected-int.dt:5:24: error: lists cannot be empty 4 | -------------------------------------------------------------------------------- /t/error-src/expected-left-paren.dt: -------------------------------------------------------------------------------- 1 | asdf 2 | -------------------------------------------------------------------------------- /t/error-src/expected-left-paren.dt.errors: -------------------------------------------------------------------------------- 1 | ./t/error-src/expected-left-paren.dt:1:1: error: expected left parenthesis 2 | -------------------------------------------------------------------------------- /t/error-src/extern-plus-init.dt: -------------------------------------------------------------------------------- 1 | (def main 2 | (fn extern-c int (void) 3 | (def x (var extern int 10)) 4 | 0)) 5 | -------------------------------------------------------------------------------- /t/error-src/extern-plus-init.dt.errors: -------------------------------------------------------------------------------- 1 | ./t/error-src/extern-plus-init.dt:3:12: error: a function-scoped variable cannot have extern linkage as well as an initialiser 2 | -------------------------------------------------------------------------------- /t/error-src/fn-args.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | (import macros) 3 | 4 | (def inet_aton 5 | (fn extern-c int ((addr (p (const char))) (num uint32)))) 6 | 7 | (def main 8 | (fn extern-c int (void) 9 | (inet_aton "1.2.3.4") 10 | 0)) 11 | -------------------------------------------------------------------------------- /t/error-src/fn-args.dt.errors: -------------------------------------------------------------------------------- 1 | ./t/error-src/fn-args.dt:9:5: error: function not in scope: 'inet_aton' (parameters are (p (const char)), function expects (p (const char)) uint32) 2 | -------------------------------------------------------------------------------- /t/error-src/fn-overlap-mac.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def mytemp 4 | (fn extern int ((a int) (b int)) 5 | (printf "%d %d\n" a b) 6 | 0)) 7 | 8 | (def mytemp 9 | (macro extern ((a int) (b int)) 10 | (printf "%p %p\n" a b) 11 | (nullptr DNode))) 12 | 13 | (def main 14 | (fn extern-c int (void) 15 | (mytemp 1 2) 16 | 0)) 17 | -------------------------------------------------------------------------------- /t/error-src/fn-overlap-mac.dt.errors: -------------------------------------------------------------------------------- 1 | ./t/error-src/fn-overlap-mac.dt:9:3: error: macro 'mytemp' has same parameters as an existing function of that name 2 | -------------------------------------------------------------------------------- /t/error-src/for-loop.dt: -------------------------------------------------------------------------------- 1 | (import macros) 2 | (import cstdio) 3 | 4 | (def main 5 | (fn extern-c int (void) 6 | (for true true true asdf) 7 | 0)) 8 | -------------------------------------------------------------------------------- /t/error-src/for-loop.dt.errors: -------------------------------------------------------------------------------- 1 | ./t/error-src/for-loop.dt:6:25: error: variable not in scope or cannot be used as value: 'asdf' (see macro at 6:5) 2 | -------------------------------------------------------------------------------- /t/error-src/if-branches-different.dt: -------------------------------------------------------------------------------- 1 | (def main (fn extern-c int (void) 2 | (def mys (var auto \ (if true 0 "asdf"))) 3 | 0)) 4 | -------------------------------------------------------------------------------- /t/error-src/if-branches-different.dt.errors: -------------------------------------------------------------------------------- 1 | ./t/error-src/if-branches-different.dt:2:22: error: type void cannot be used, because it is not a first-class type 2 | -------------------------------------------------------------------------------- /t/error-src/implied-type.dt: -------------------------------------------------------------------------------- 1 | (def main 2 | (fn extern-c int (void) 3 | (def v (var auto \)) 4 | 0)) 5 | 6 | -------------------------------------------------------------------------------- /t/error-src/implied-type.dt.errors: -------------------------------------------------------------------------------- 1 | ./t/error-src/implied-type.dt:3:12: error: must have initialiser for variable with implied type 2 | -------------------------------------------------------------------------------- /t/error-src/include-test.dt: -------------------------------------------------------------------------------- 1 | (include "include/test.dt") 2 | 3 | (def main (fn extern-c int (void) 4 | (def x y (var auto int 0)) 5 | 0)) 6 | -------------------------------------------------------------------------------- /t/error-src/include-test.dt.errors: -------------------------------------------------------------------------------- 1 | t/error-src/include/test.dt:2:2: error: 'def' requires 2 arguments (got 3 instead) 2 | t/error-src/include-test.dt:4:3: error: 'def' requires 2 arguments (got 3 instead) 3 | -------------------------------------------------------------------------------- /t/error-src/include/test.dt: -------------------------------------------------------------------------------- 1 | 2 | (def var v (var intern int 100)) 3 | 4 | -------------------------------------------------------------------------------- /t/error-src/invalid-cast.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def main (fn extern-c int (void) 4 | (def x (var auto (array-of 2 int) (array 0 0))) 5 | (def y (var auto (array-of 2 int) (cast x (array-of 2 int)))) 6 | (printf "%d %d\n" (@$ x 0) (@$ x 1)) 7 | (printf "%d %d\n" (@$ y 0) (@$ y 1)) 8 | (return))) 9 | -------------------------------------------------------------------------------- /t/error-src/invalid-cast.dt.errors: -------------------------------------------------------------------------------- 1 | ./t/error-src/invalid-cast.dt:5:37: error: unable to cast from type (p int) to type (array-of 2 int) 2 | -------------------------------------------------------------------------------- /t/error-src/invalid-instantiation.dt: -------------------------------------------------------------------------------- 1 | (import concepts) 2 | 3 | (std.concepts.instantiate Vector my-struct) 4 | (def my-struct (struct intern ((x 1)))) 5 | 6 | (def main (fn extern-c int (void) 0)) 7 | -------------------------------------------------------------------------------- /t/error-src/invalid-instantiation.dt.errors: -------------------------------------------------------------------------------- 1 | ./t/error-src/invalid-instantiation.dt:3:27: error: concept not found (see macro at 3:1) 2 | ./t/error-src/invalid-instantiation.dt:3:1: error: macro expansion error (see previous) 3 | ./t/error-src/invalid-instantiation.dt:4:35: error: single parameter type must be symbol (got integer instead) 4 | ./t/error-src/invalid-instantiation.dt:4:32: error: invalid type 5 | -------------------------------------------------------------------------------- /t/error-src/invalid-intern-var.dt: -------------------------------------------------------------------------------- 1 | (import macros) 2 | 3 | (def main (fn extern-c int (void) 4 | (def asdf (var auto int 0)) 5 | (def testvar (var intern int asdf)) 6 | (printf "%d\n" testvar) 7 | 0)) 8 | -------------------------------------------------------------------------------- /t/error-src/invalid-intern-var.dt.errors: -------------------------------------------------------------------------------- 1 | t/error-src/invalid-intern-var.dt:5:32: error: variable not in scope or cannot be used as value: 'asdf' 2 | t/error-src/invalid-intern-var.dt:6:17: error: variable not in scope or cannot be used as value: 'testvar' 3 | -------------------------------------------------------------------------------- /t/error-src/invalid-offsetof.dt: -------------------------------------------------------------------------------- 1 | (def myn (struct intern ((a int) (b int)))) 2 | 3 | (def main (fn extern-c int (void) 4 | (offsetof myn (1 2 3)) 5 | 0)) 6 | -------------------------------------------------------------------------------- /t/error-src/invalid-offsetof.dt.errors: -------------------------------------------------------------------------------- 1 | ./t/error-src/invalid-offsetof.dt:4:17: error: 'offsetof' requires an atom for argument 2 (got a list instead) 2 | -------------------------------------------------------------------------------- /t/error-src/invalid-type.dt: -------------------------------------------------------------------------------- 1 | (def foo (macro extern ((name (p char)) (t DNODE)))) 2 | -------------------------------------------------------------------------------- /t/error-src/invalid-type.dt.errors: -------------------------------------------------------------------------------- 1 | ./t/error-src/invalid-type.dt:1:44: error: type not in scope: 'DNODE' 2 | -------------------------------------------------------------------------------- /t/error-src/invoke-errors.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def invoke 4 | (macro intern ((a int) (b int) (c int)) 5 | (printf "called\n") 6 | (return a))) 7 | 8 | (def invoke 9 | (fn intern void ((a int)) 10 | (printf "called\n") 11 | (return))) 12 | 13 | (def main (fn extern-c int (void) 14 | (def x (var auto int 0)) 15 | (def y (var auto float 0.0)) 16 | (x) 17 | (x 1) 18 | (y) 19 | 0)) 20 | -------------------------------------------------------------------------------- /t/error-src/invoke-errors.dt.errors: -------------------------------------------------------------------------------- 1 | t/error-src/invoke-errors.dt:17:4: error: overloaded function/macro not in scope: 'invoke' (parameters are int int, closest candidate expects int int int) 2 | t/error-src/invoke-errors.dt:18:3: error: not in scope: 'y' 3 | -------------------------------------------------------------------------------- /t/error-src/let.dt: -------------------------------------------------------------------------------- 1 | (import stdlib) 2 | 3 | (def main (fn extern-c int (void) 4 | (let n (var auto int 1) 0))) 5 | -------------------------------------------------------------------------------- /t/error-src/let.dt.errors: -------------------------------------------------------------------------------- 1 | t/error-src/let.dt:4:8: error: variable forms must be a list (see macro at 4:3) 2 | t/error-src/let.dt:4:3: error: macro expansion error (see previous) 3 | -------------------------------------------------------------------------------- /t/error-src/mac-overlap-fn.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def mytemp 4 | (fn extern int ((a int) (b int)) 5 | (printf "%d %d\n" a b) 6 | 0)) 7 | 8 | (def mytemp 9 | (macro extern ((a int) (b int)) 10 | (printf "%p %p\n" a b) 11 | (nullptr DNode))) 12 | 13 | (def main 14 | (fn extern-c int (void) 15 | (mytemp 1 2) 16 | 0)) 17 | -------------------------------------------------------------------------------- /t/error-src/mac-overlap-fn.dt.errors: -------------------------------------------------------------------------------- 1 | ./t/error-src/mac-overlap-fn.dt:9:3: error: macro 'mytemp' has same parameters as an existing function of that name 2 | -------------------------------------------------------------------------------- /t/error-src/macro-args.dt: -------------------------------------------------------------------------------- 1 | (def blah (macro 1)) 2 | -------------------------------------------------------------------------------- /t/error-src/macro-args.dt.errors: -------------------------------------------------------------------------------- 1 | ./t/error-src/macro-args.dt:1:11: error: 'macro' requires at least 2 arguments (got 1 instead) 2 | -------------------------------------------------------------------------------- /t/error-src/macro-error-checking.dt: -------------------------------------------------------------------------------- 1 | (import macros) (import stdlib) 2 | 3 | (def main (fn extern-c int (void) 4 | (for 1 2 3) 5 | (while 1) 6 | (mfor 1 2) 7 | (mfor 1 2 3) 8 | (let (1)) 9 | (let (1) 1) 10 | (let ((1)) 1) 11 | (let ((1)) 1) 12 | 0)) 13 | -------------------------------------------------------------------------------- /t/error-src/macro-error-position.dt: -------------------------------------------------------------------------------- 1 | (import macros) 2 | (import cstdio) 3 | (import introspection) 4 | 5 | (using-namespace std.macros 6 | (def def-type-macro (macro extern (new linkage old) 7 | (qq using-namespace std.macros 8 | (def (uq new) (macro (uq linkage) (void) 9 | (qq uq (uq old)))))))) 10 | 11 | (def-type-macro cstring extern (p (const char))) 12 | 13 | (def main (fn extern-c void (void) 14 | (def a-string (var auto (cstring) "Yo dude")) 15 | (printf "string: %s\n" a-string))) 16 | -------------------------------------------------------------------------------- /t/error-src/macro-error-position.dt.errors: -------------------------------------------------------------------------------- 1 | ./t/error-src/macro-error-position.dt:9:13: error: invalid type (see macro at 14:27) 2 | ./t/error-src/macro-error-position.dt:15:25: error: variable not in scope or cannot be used as value: 'a-string' 3 | -------------------------------------------------------------------------------- /t/error-src/mfor.dt: -------------------------------------------------------------------------------- 1 | (import stdlib) 2 | 3 | (def main (fn extern-c int (void) 4 | (mfor' N (range 0 5 6) 5 | (printf "%d\n" N)) 6 | 0)) 7 | -------------------------------------------------------------------------------- /t/error-src/mfor.dt.errors: -------------------------------------------------------------------------------- 1 | mfor.dt:4:13: error: not in scope: 'range' (see macro at 4:3) 2 | mfor.dt:4:3: error: macro expansion error (see previous) 3 | -------------------------------------------------------------------------------- /t/error-src/missing-right-paren.dt: -------------------------------------------------------------------------------- 1 | (asdf 2 | -------------------------------------------------------------------------------- /t/error-src/missing-right-paren.dt.errors: -------------------------------------------------------------------------------- 1 | ./t/error-src/missing-right-paren.dt:2:1: error: missing right parenthesis 2 | -------------------------------------------------------------------------------- /t/error-src/ml-comment-line-numbers.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | #| asdf |# 4 | 5 | #| asdf 6 | |# 7 | 8 | #| 9 | asdf 10 | |# 11 | 12 | #| 13 | 14 | asdf 15 | 16 | |# 17 | 18 | (def main (fn extern-c int (void) 19 | asdf 20 | 0)) 21 | -------------------------------------------------------------------------------- /t/error-src/ml-comment-line-numbers.dt.errors: -------------------------------------------------------------------------------- 1 | ./t/error-src/ml-comment-line-numbers.dt:19:3: error: variable not in scope or cannot be used as value: 'asdf' 2 | -------------------------------------------------------------------------------- /t/error-src/ml-string-line-numbers.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def myvar (var intern (p (const char)) "asdf")) 4 | 5 | (def myvar2 (var intern (p (const char)) "asdf 6 | ")) 7 | 8 | (def myvar3 (var intern (p (const char)) " 9 | 10 | asdf 11 | 12 | ")) 13 | 14 | (def main (fn extern-c int (void) 15 | asdf 16 | 0)) 17 | -------------------------------------------------------------------------------- /t/error-src/ml-string-line-numbers.dt.errors: -------------------------------------------------------------------------------- 1 | ./t/error-src/ml-string-line-numbers.dt:15:3: error: variable not in scope or cannot be used as value: 'asdf' 2 | -------------------------------------------------------------------------------- /t/error-src/multiple-arg-inst.dt.errors: -------------------------------------------------------------------------------- 1 | ./t/error-src/multiple-arg-inst.dt:31:19: error: multiple instantiations found: (Subtractable Addable), (Addable Subtractable) (see macro at 31:1) 2 | ./t/error-src/multiple-arg-inst.dt:31:1: error: macro expansion error (see previous) 3 | -------------------------------------------------------------------------------- /t/error-src/multiple-instantiations.dt.errors: -------------------------------------------------------------------------------- 1 | ./t/error-src/multiple-instantiations.dt:31:19: error: multiple instantiations found: (Subtractable), (Addable) (see macro at 31:1) 2 | ./t/error-src/multiple-instantiations.dt:31:1: error: macro expansion error (see previous) 3 | -------------------------------------------------------------------------------- /t/error-src/no-array-params.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def testfn 4 | (fn extern int ((thing (array-of 5 int))) 5 | 0)) 6 | 7 | (def main 8 | (fn extern-c int (void) 9 | 0)) 10 | -------------------------------------------------------------------------------- /t/error-src/no-array-params.dt.errors: -------------------------------------------------------------------------------- 1 | ./t/error-src/no-array-params.dt:4:19: error: arrays cannot be function parameters; use a pointer instead 2 | -------------------------------------------------------------------------------- /t/error-src/no-array-ret-type.dt: -------------------------------------------------------------------------------- 1 | ; ignore the fact that it is returning an array with 2 | ; automatic storage allocation :) 3 | 4 | (def test 5 | (fn extern (array-of 5 int) ((n int)) 6 | (let ((n (array-of 5 int))) 7 | n))) 8 | -------------------------------------------------------------------------------- /t/error-src/no-array-ret-type.dt.errors: -------------------------------------------------------------------------------- 1 | ./t/error-src/no-array-ret-type.dt:5:14: error: return types cannot be arrays (use a pointer instead) 2 | -------------------------------------------------------------------------------- /t/error-src/no-core-macro.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | (import macros) 3 | 4 | (def label 5 | (macro intern (a b c) a)) 6 | 7 | (def label 8 | (fn intern int ((a int)) 9 | 0)) 10 | -------------------------------------------------------------------------------- /t/error-src/no-core-macro.dt.errors: -------------------------------------------------------------------------------- 1 | ./t/error-src/no-core-macro.dt:5:3: error: core form names cannot be used as macro names 2 | ./t/error-src/no-core-macro.dt:8:3: error: this core form cannot be overridden 3 | -------------------------------------------------------------------------------- /t/error-src/no-lvalue-addresses.dt: -------------------------------------------------------------------------------- 1 | (def myfn (fn extern int (void) 10)) 2 | 3 | (def main 4 | (fn extern-c int (void) 5 | (# (myfn)) 6 | 0)) 7 | -------------------------------------------------------------------------------- /t/error-src/no-lvalue-addresses.dt.errors: -------------------------------------------------------------------------------- 1 | ./t/error-src/no-lvalue-addresses.dt:5:8: error: cannot take address of non-lvalue 2 | -------------------------------------------------------------------------------- /t/error-src/no-sort-array.dt: -------------------------------------------------------------------------------- 1 | (import macros) 2 | (import array) 3 | (import algorithms) 4 | (import concepts) 5 | 6 | (def mys (struct intern ((a int)))) 7 | (std.concepts.implement MoveConstructible mys) 8 | 9 | (std.concepts.instantiate Array mys 10) 10 | (std.concepts.instantiate sort (Iterator (Array mys 10))) 11 | -------------------------------------------------------------------------------- /t/error-src/no-sort-array.dt.errors: -------------------------------------------------------------------------------- 1 | algorithms.dt:149:19: error: type does not implement concept LessThanComparable (see macro at 19:19) 2 | algorithms.dt:19:19: error: macro expansion error (see previous) 3 | -------------------------------------------------------------------------------- /t/error-src/no-sort-vector.dt: -------------------------------------------------------------------------------- 1 | (import macros) 2 | (import vector) 3 | (import algorithms) 4 | (import concepts) 5 | 6 | (def mys (struct intern ((a int)))) 7 | (std.concepts.implement MoveConstructible mys) 8 | 9 | (std.concepts.instantiate Vector mys) 10 | (std.concepts.instantiate sort (Iterator (Vector mys))) 11 | -------------------------------------------------------------------------------- /t/error-src/no-sort-vector.dt.errors: -------------------------------------------------------------------------------- 1 | algorithms.dt:149:19: error: type does not implement concept LessThanComparable (see macro at 19:19) 2 | algorithms.dt:19:19: error: macro expansion error (see previous) 3 | -------------------------------------------------------------------------------- /t/error-src/no-string.dt: -------------------------------------------------------------------------------- 1 | (import macros) 2 | (import cstdio) 3 | 4 | (def testmac 5 | (macro extern (void) 6 | (std.macros.mnfv mc ""))) 7 | 8 | (def main 9 | (fn extern-c int (void) 10 | (printf "pre null\n") 11 | (testmac) 12 | (printf "post null\n") 13 | 0)) 14 | 15 | -------------------------------------------------------------------------------- /t/error-src/no-string.dt.errors: -------------------------------------------------------------------------------- 1 | :0:0: error: DNode returned by macro is an atom but has no string 2 | ./t/error-src/no-string.dt:11:5: error: macro expansion error (see previous) 3 | -------------------------------------------------------------------------------- /t/error-src/no-vla.dt: -------------------------------------------------------------------------------- 1 | (def main (fn extern-c int (void) 2 | (def x (var auto int 100)) 3 | (def y (var auto (array-of x int))) 4 | 0)) 5 | -------------------------------------------------------------------------------- /t/error-src/no-vla.dt.errors: -------------------------------------------------------------------------------- 1 | ./t/error-src/no-vla.dt:3:30: error: variable not in scope or cannot be used as value: 'x' 2 | -------------------------------------------------------------------------------- /t/error-src/no-void-in-struct.dt: -------------------------------------------------------------------------------- 1 | (def mys (struct extern ((# void)))) 2 | -------------------------------------------------------------------------------- /t/error-src/no-void-in-struct.dt.errors: -------------------------------------------------------------------------------- 1 | ./t/error-src/no-void-in-struct.dt:1:26: error: 'void' fields are not allowed in structs 2 | -------------------------------------------------------------------------------- /t/error-src/non-ptr-fn.dt: -------------------------------------------------------------------------------- 1 | (def myfn (fn extern int ((# (fn int ((# int))))))) 2 | -------------------------------------------------------------------------------- /t/error-src/non-ptr-fn.dt.errors: -------------------------------------------------------------------------------- 1 | ./t/error-src/non-ptr-fn.dt:1:27: error: all function parameters must be pointers to functions 2 | -------------------------------------------------------------------------------- /t/error-src/non-token-derivation.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | (import concepts) 3 | (import derivations) 4 | 5 | (def mys (struct intern ((a (p int))))) 6 | (std.concepts.implement Type mys) 7 | (std.concepts.implement Struct mys) 8 | 9 | (std.concepts.instantiate < mys) 10 | 11 | (def main (fn extern-c int (void) 0)) 12 | -------------------------------------------------------------------------------- /t/error-src/non-token-derivation.dt.errors: -------------------------------------------------------------------------------- 1 | ./t/error-src/non-token-derivation.dt:9:29: error: < not defined on struct member (type Pi, name a) (see macro at \d+:\d+) 2 | error: macro expansion error (see previous) (see macro at 9:1) 3 | -------------------------------------------------------------------------------- /t/error-src/not-in-scope.dt: -------------------------------------------------------------------------------- 1 | (import cerrno) 2 | 3 | (def main 4 | (fn extern-c int (void) 5 | (QWER) 6 | 0)) 7 | -------------------------------------------------------------------------------- /t/error-src/not-in-scope.dt.errors: -------------------------------------------------------------------------------- 1 | ./t/error-src/not-in-scope.dt:5:6: error: not in scope: 'QWER' 2 | -------------------------------------------------------------------------------- /t/error-src/ns-deactivation-error.dt: -------------------------------------------------------------------------------- 1 | (namespace a) 2 | 3 | (def main (fn extern-c int (void) 4 | (using-namespace a 5 | (printf "%d\n" 0)) 6 | 0)) 7 | -------------------------------------------------------------------------------- /t/error-src/ns-deactivation-error.dt.errors: -------------------------------------------------------------------------------- 1 | ./t/error-src/ns-deactivation-error.dt:5:6: error: not in scope: 'printf' 2 | -------------------------------------------------------------------------------- /t/error-src/ol-candidate-macro.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def mytemp 4 | (macro extern ((a int) (b int)) 5 | (printf "%p %p\n" a b) 6 | (nullptr DNode))) 7 | 8 | (def main 9 | (fn extern-c int (void) 10 | (mytemp 1) 11 | 0)) 12 | -------------------------------------------------------------------------------- /t/error-src/ol-candidate-macro.dt.errors: -------------------------------------------------------------------------------- 1 | ./t/error-src/ol-candidate-macro.dt:10:5: error: overloaded function/macro not in scope: 'mytemp' (parameters are int, closest candidate expects int int) 2 | -------------------------------------------------------------------------------- /t/error-src/ol-candidate.dt: -------------------------------------------------------------------------------- 1 | 2 | (import cstdio) 3 | 4 | (def inet_aton 5 | (fn extern int ((a (p (const char))) (b uint32)) 6 | 0)) 7 | 8 | (def main 9 | (fn extern-c int (void) 10 | (inet_aton "asdf") 11 | 0)) 12 | -------------------------------------------------------------------------------- /t/error-src/ol-candidate.dt.errors: -------------------------------------------------------------------------------- 1 | ./t/error-src/ol-candidate.dt:10:5: error: overloaded function/macro not in scope: 'inet_aton' (parameters are (p (const char)), closest candidate expects (p (const char)) uint32) 2 | -------------------------------------------------------------------------------- /t/error-src/ol-fn-setf.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def inet_aton 4 | (fn extern int ((a (p char)) (b uint32)) 5 | 0)) 6 | 7 | (def main 8 | (fn extern-c int (void) 9 | (def v (var auto (p (fn int ((a (p char)) (b (p char))))) 10 | (# inet_aton))) 11 | (setv v (# inet_aton)) 12 | 0)) 13 | -------------------------------------------------------------------------------- /t/error-src/ol-fn-setf.dt.errors: -------------------------------------------------------------------------------- 1 | ./t/error-src/ol-fn-setf.dt:9:5: error: expected expression with type (p (fn int ((p char) (p char))) (got type (p (fn int ((p char) uint32)) instead) 2 | ./t/error-src/ol-fn-setf.dt:11:13: error: expected expression with type (p (fn int ((p char) (p char))) (got type (p (fn int ((p char) uint32)) instead) 3 | -------------------------------------------------------------------------------- /t/error-src/only-void.dt: -------------------------------------------------------------------------------- 1 | (def blah (macro extern (1 2 3 4 void))) 2 | -------------------------------------------------------------------------------- /t/error-src/only-void.dt.errors: -------------------------------------------------------------------------------- 1 | ./t/error-src/only-void.dt:1:25: error: 'void' must be the only parameter 2 | -------------------------------------------------------------------------------- /t/error-src/operator-macro-need-three.dt: -------------------------------------------------------------------------------- 1 | (import operator-macros) 2 | 3 | (import stdlib) 4 | (import macros) 5 | 6 | (def main (fn extern-c int (void) 7 | (printf "%d\n" (+ 4 3 2)) 8 | (printf "%d\n" (< 4 3 2)) 9 | (printf "%d\n" (+ 4 (cast 3 size) 2)) 10 | (printf "%d\n" (< 4 (cast 3 size) 2)) 11 | (printf "%d\n" (and 1 true true)) 12 | (printf "%d\n" (+ 4 (cast 3 size))) 13 | (printf "%d\n" (< 4 (cast 3 size))) 14 | (printf "%d\n" (and 1 true)) 15 | 0)) 16 | 17 | -------------------------------------------------------------------------------- /t/error-src/position.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | (import macros) 3 | (import utility) 4 | 5 | (def tm 6 | (macro extern (T T2) 7 | (std.macros.qq ++ (uq T) (+++ asdf asdf)))) 8 | 9 | (def main 10 | (fn extern-c int (void) 11 | (tm (+ 1 2) 1) 12 | 0)) 13 | 14 | -------------------------------------------------------------------------------- /t/error-src/position.dt.errors: -------------------------------------------------------------------------------- 1 | :7:20: error: not in scope: '\+\+' (see macro at 11:5) 2 | -------------------------------------------------------------------------------- /t/error-src/redecl-global-difftype.dt: -------------------------------------------------------------------------------- 1 | ; This used to cause a segmentation fault. 2 | (def x (var intern int 0)) 3 | (def x (var intern char #\a)) 4 | -------------------------------------------------------------------------------- /t/error-src/redecl-global-difftype.dt.errors: -------------------------------------------------------------------------------- 1 | ./t/error-src/redecl-global-difftype.dt:3:8: error: variable 'x' has already been defined in this scope 2 | -------------------------------------------------------------------------------- /t/error-src/redeclaration-extern-c-fn.dt: -------------------------------------------------------------------------------- 1 | (def fn (fn extern-c int ((n int)))) 2 | (def fn (fn extern-c int ((n (p char))))) 3 | 4 | (def fn2 (fn extern-c int ((n int)) 0)) 5 | (def fn2 (fn extern-c int ((n int)) 0)) 6 | -------------------------------------------------------------------------------- /t/error-src/redeclaration-extern-c-fn.dt.errors: -------------------------------------------------------------------------------- 1 | ./t/error-src/redeclaration-extern-c-fn.dt:2:9: error: function/macro 'fn' has already been defined in this scope 2 | ./t/error-src/redeclaration-extern-c-fn.dt:5:10: error: function/macro 'fn2' has already been defined in this scope 3 | -------------------------------------------------------------------------------- /t/error-src/redeclaration-fn.dt: -------------------------------------------------------------------------------- 1 | (def fn (fn extern int ((# int)) 0)) 2 | (def fn (fn extern int ((# int)))) 3 | -------------------------------------------------------------------------------- /t/error-src/redeclaration-fn.dt.errors: -------------------------------------------------------------------------------- 1 | ./t/error-src/redeclaration-fn.dt:2:9: error: function/macro 'fn' has already been defined in this scope 2 | -------------------------------------------------------------------------------- /t/error-src/redeclaration-labels.dt: -------------------------------------------------------------------------------- 1 | (def main 2 | (fn extern-c int (void) 3 | (label a) 4 | (label a) 5 | (label a))) 6 | -------------------------------------------------------------------------------- /t/error-src/redeclaration-labels.dt.errors: -------------------------------------------------------------------------------- 1 | ./t/error-src/redeclaration-labels.dt:4:5: error: label 'a' has already been defined in this scope 2 | ./t/error-src/redeclaration-labels.dt:5:5: error: label 'a' has already been defined in this scope 3 | -------------------------------------------------------------------------------- /t/error-src/redeclaration.dt: -------------------------------------------------------------------------------- 1 | (def a (var intern int 0)) 2 | (def a (var intern int 0)) 3 | (def a (var intern int 0)) 4 | -------------------------------------------------------------------------------- /t/error-src/redeclaration.dt.errors: -------------------------------------------------------------------------------- 1 | ./t/error-src/redeclaration.dt:2:8: error: variable 'a' has already been defined in this scope 2 | ./t/error-src/redeclaration.dt:3:8: error: variable 'a' has already been defined in this scope 3 | -------------------------------------------------------------------------------- /t/error-src/refs-exclusive.dt.errors: -------------------------------------------------------------------------------- 1 | ./t/error-src/refs-exclusive.dt:9:13: error: function/macro 'ref-fn' has already been defined in this scope 2 | ./t/error-src/refs-exclusive.dt:15:15: error: function/macro 'ref-fn-1' has already been defined in this scope 3 | ./t/error-src/refs-exclusive.dt:18:15: error: function/macro 'ref-fn-1' has already been defined in this scope 4 | -------------------------------------------------------------------------------- /t/error-src/register-type.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | (import macros) 3 | (import utility) 4 | 5 | (std.concepts.instantiate Pair int int) 6 | 7 | (def main 8 | (fn extern-c int (void) 9 | (let ((p (Pair int int))) 10 | (+ p p)) 11 | 0)) 12 | 13 | -------------------------------------------------------------------------------- /t/error-src/register-type.dt.errors: -------------------------------------------------------------------------------- 1 | ./t/error-src/register-type.dt:10:7: error: overloaded function/macro not in scope: '\+' (parameters are (Pair int int) (Pair int int), closest candidate expects (const int) (const int)) (see macro at 9:5) 2 | -------------------------------------------------------------------------------- /t/error-src/requires-explicit-init.dt: -------------------------------------------------------------------------------- 1 | (def x (struct intern ((a int) (b int)))) 2 | 3 | (def requires-explicit-init (fn intern void ((val (ref x))))) 4 | 5 | (def main (fn extern-c int (void) 6 | (def myx (var auto x)) 7 | 0)) 8 | -------------------------------------------------------------------------------- /t/error-src/requires-explicit-init.dt.errors: -------------------------------------------------------------------------------- 1 | requires-explicit-init.dt:6:12: error: must have initialiser for variable of this type 2 | -------------------------------------------------------------------------------- /t/error-src/ret-type-fail-1.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | (import macros) 3 | 4 | (def main 5 | (fn extern-c int (void) 6 | (return "asdf"))) 7 | -------------------------------------------------------------------------------- /t/error-src/ret-type-fail-1.dt.errors: -------------------------------------------------------------------------------- 1 | ./t/error-src/ret-type-fail-1.dt:6:5: error: expected return expression with type int (got type (p (const char)) instead) 2 | -------------------------------------------------------------------------------- /t/error-src/ret-type-fail-2.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | (import macros) 3 | 4 | (def main 5 | (fn extern-c int (void) 6 | "asdf")) 7 | -------------------------------------------------------------------------------- /t/error-src/ret-type-fail-2.dt.errors: -------------------------------------------------------------------------------- 1 | ./t/error-src/ret-type-fail-2.dt:6:5: error: expected return expression with type int (got type (p (const char)) instead) 2 | -------------------------------------------------------------------------------- /t/error-src/return-type.dt: -------------------------------------------------------------------------------- 1 | (def main 2 | (fn extern-c int (void) 3 | "asdf")) 4 | -------------------------------------------------------------------------------- /t/error-src/return-type.dt.errors: -------------------------------------------------------------------------------- 1 | ./t/error-src/return-type.dt:3:5: error: expected return expression with type int (got type (p (const char)) instead) 2 | -------------------------------------------------------------------------------- /t/error-src/same-names.dt: -------------------------------------------------------------------------------- 1 | (def a (var intern int 1)) 2 | (def a (fn intern int (void) 1)) 3 | 4 | (def b (fn intern int (void) 1)) 5 | (def b (var intern int 1)) 6 | 7 | (def c (var intern int 1)) 8 | (def c (macro intern (void) (nullptr DNode))) 9 | 10 | (def d (macro intern (void) (nullptr DNode))) 11 | (def d (var intern int 1)) 12 | -------------------------------------------------------------------------------- /t/error-src/same-names.dt.errors: -------------------------------------------------------------------------------- 1 | ./t/error-src/same-names.dt:2:8: error: 'a' redeclared as different kind of symbol 2 | ./t/error-src/same-names.dt:5:8: error: 'b' redeclared as different kind of symbol 3 | ./t/error-src/same-names.dt:8:8: error: 'c' redeclared as different kind of symbol 4 | ./t/error-src/same-names.dt:11:8: error: 'd' redeclared as different kind of symbol 5 | -------------------------------------------------------------------------------- /t/error-src/setf-const-string.dt: -------------------------------------------------------------------------------- 1 | (def myfn (fn intern int (void) 2 | (def mystr (var auto (p char))) 3 | (setv mystr "") 4 | 0)) 5 | -------------------------------------------------------------------------------- /t/error-src/setf-const-string.dt.errors: -------------------------------------------------------------------------------- 1 | ./t/error-src/setf-const-string.dt:3:15: error: expected expression with type (p char) (got type (p (const char)) instead) 2 | -------------------------------------------------------------------------------- /t/error-src/setf-copy-disabled-inner.dt.errors: -------------------------------------------------------------------------------- 1 | error: copying is disabled for this type (see macro at 18:7) 2 | -------------------------------------------------------------------------------- /t/error-src/setf-copy-disabled-ref.dt.errors: -------------------------------------------------------------------------------- 1 | ./t/error-src/setf-copy-disabled-ref.dt:28:3: error: copying is disabled for this type 2 | -------------------------------------------------------------------------------- /t/error-src/setf-copy-disabled.dt.errors: -------------------------------------------------------------------------------- 1 | ./t/error-src/setf-copy-disabled.dt:59:25: error: copying is disabled for this type 2 | ./t/error-src/setf-copy-disabled.dt:66:3: error: copying is disabled for this type 3 | ./t/error-src/setf-copy-disabled.dt:68:3: error: copying is disabled for this type 4 | ./t/error-src/setf-copy-disabled.dt:69:16: error: copying is disabled for this type 5 | -------------------------------------------------------------------------------- /t/error-src/setf-needs-pointer.dt: -------------------------------------------------------------------------------- 1 | (def main 2 | (fn extern-c int (void) 3 | (def x (var auto int 0)) 4 | (setf x 0))) 5 | -------------------------------------------------------------------------------- /t/error-src/setf-needs-pointer.dt.errors: -------------------------------------------------------------------------------- 1 | ./t/error-src/setf-needs-pointer.dt:4:11: error: 'setf' requires a pointer for argument 1 (got a value instead) 2 | -------------------------------------------------------------------------------- /t/error-src/sizeof-opaque-struct.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def x (struct opaque ((a int)))) 4 | 5 | (def main (fn extern-c int (void) 6 | (printf "%d\n" (sizeof x)) 7 | 0)) 8 | -------------------------------------------------------------------------------- /t/error-src/sizeof-opaque-struct.dt.errors: -------------------------------------------------------------------------------- 1 | sizeof-opaque-struct.dt:6:17: error: cannot instantiate opaque struct 2 | -------------------------------------------------------------------------------- /t/error-src/top-level-empty-list.dt: -------------------------------------------------------------------------------- 1 | () 2 | -------------------------------------------------------------------------------- /t/error-src/top-level-empty-list.dt.errors: -------------------------------------------------------------------------------- 1 | ./t/error-src/top-level-empty-list.dt:1:1: error: lists cannot be empty 2 | -------------------------------------------------------------------------------- /t/error-src/two-modules.dt: -------------------------------------------------------------------------------- 1 | (module x) 2 | (module y) 3 | -------------------------------------------------------------------------------- /t/error-src/two-modules.dt.errors: -------------------------------------------------------------------------------- 1 | ./t/error-src/two-modules.dt:2:1: error: a 'module' form may only appear once 2 | -------------------------------------------------------------------------------- /t/error-src/unsupported-literal.dt: -------------------------------------------------------------------------------- 1 | (def mys (struct extern ((# int)))) 2 | 3 | (namespace temp 4 | (def mys (struct extern ((# int)))) 5 | (namespace temp2 6 | (namespace temp3 7 | (def mys (struct extern ((# int))))))) 8 | 9 | (def n (var intern mys 100.0)) 10 | (def n (var intern temp.temp2.temp3.mys 100.0)) 11 | (def n (var intern temp.mys 100.0)) 12 | -------------------------------------------------------------------------------- /t/error-src/unsupported-literal.dt.errors: -------------------------------------------------------------------------------- 1 | ./t/error-src/unsupported-literal.dt:9:24: error: expected return expression with type mys (got type float instead) 2 | ./t/error-src/unsupported-literal.dt:10:41: error: expected return expression with type temp.temp2.temp3.mys (got type float instead) 3 | ./t/error-src/unsupported-literal.dt:11:29: error: expected return expression with type temp.mys (got type float instead) 4 | -------------------------------------------------------------------------------- /t/error-src/unterminated.dt: -------------------------------------------------------------------------------- 1 | " 2 | -------------------------------------------------------------------------------- /t/error-src/unterminated.dt.errors: -------------------------------------------------------------------------------- 1 | ./t/error-src/unterminated.dt:1:1: error: unterminated string literal 2 | -------------------------------------------------------------------------------- /t/error-src/uq-problems.dt: -------------------------------------------------------------------------------- 1 | (import macros) 2 | (import introspection) 3 | 4 | (using-namespace std.macros 5 | (def top (macro extern (node) 6 | (def str (var auto \ (@:@ node token-str))) 7 | (qq using-namespace std.macros 8 | (def nested (macro extern (void) 9 | (mnfv mc (uq (@:@ node token-str))))))))) 10 | 11 | (top foo-bar) 12 | -------------------------------------------------------------------------------- /t/error-src/uq-problems.dt.errors: -------------------------------------------------------------------------------- 1 | ./t/error-src/uq-problems.dt:9:22: error: only DNodes may be unquoted (see macro at 7:5) 2 | ./t/error-src/uq-problems.dt:7:5: error: macro expansion error (see previous) 3 | ./t/error-src/uq-problems.dt:11:2: error: not in scope: 'top' 4 | -------------------------------------------------------------------------------- /t/error-src/variant-invalid-type.dt: -------------------------------------------------------------------------------- 1 | (import variant) 2 | (import cstdio) 3 | 4 | (using-namespace std.macros 5 | 6 | (def-variant Direction (Left Right)) 7 | 8 | (def main (fn extern-c int (void) 9 | (let ((left Direction (Left)) 10 | (right Direction (Right))) 11 | (case right 12 | (Direction (printf "Left (unexpected)\n")) 13 | (true (printf "Right (expected)\n"))) 14 | (case left 15 | (Left (printf "Left (expected)\n"))) 16 | 0))) 17 | 18 | ) 19 | -------------------------------------------------------------------------------- /t/error-src/variant-invalid-type.dt.errors: -------------------------------------------------------------------------------- 1 | ./t/error-src/variant-invalid-type.dt:12:8: error: invalid variant type (see macro at 11:5) 2 | ./t/error-src/variant-invalid-type.dt:11:5: error: macro expansion error (see previous) (see macro at 9:3) 3 | -------------------------------------------------------------------------------- /t/error-src/variant-member.dt: -------------------------------------------------------------------------------- 1 | (import variant) 2 | (import macros) 3 | 4 | (using-namespace std.macros 5 | (def def-ordered-variant (macro intern (name cons) 6 | (qq def-variant (uq name) cons)))) 7 | 8 | (def-ordered-variant Instr 9 | ((Doge ((a int))) 10 | Soge 11 | (Quoge ((a int) (b int))))) 12 | 13 | (def main (fn extern-c 14 | int 15 | ((argc int) 16 | (argv (p (p char)))) 17 | (return 0))) 18 | -------------------------------------------------------------------------------- /t/error-src/variant-member.dt.errors: -------------------------------------------------------------------------------- 1 | variant-member.dt:8:22: error: list required for variant members (see macro at 6:9) 2 | variant-member.dt:6:9: error: macro expansion error (see previous) (see macro at 8:1) 3 | -------------------------------------------------------------------------------- /t/error-src/variant-non-exhaustive.dt: -------------------------------------------------------------------------------- 1 | (import variant) 2 | (import cstdio) 3 | 4 | (using-namespace std.macros 5 | 6 | (def-variant Direction (Left Right)) 7 | 8 | (def main (fn extern-c int (void) 9 | (let ((left Direction (Left)) 10 | (right Direction (Right))) 11 | (case right 12 | (Left (printf "Left (unexpected)\n")) 13 | (true (printf "Right (expected)\n"))) 14 | (case left 15 | (Left (printf "Left (expected)\n"))) 16 | 0))) 17 | 18 | ) 19 | -------------------------------------------------------------------------------- /t/error-src/variant-non-exhaustive.dt.errors: -------------------------------------------------------------------------------- 1 | ./t/error-src/variant-non-exhaustive.dt:14:11: error: case is non-exhaustive (see macro at 14:5) 2 | ./t/error-src/variant-non-exhaustive.dt:14:5: error: macro expansion error (see previous) (see macro at 9:3) 3 | 4 | -------------------------------------------------------------------------------- /t/error-src/vector-rv-no-copy.dt.errors: -------------------------------------------------------------------------------- 1 | ./t/error-src/vector-rv-no-copy.dt:45:7: error: copying is disabled for this type (see macro at 32:5) 2 | -------------------------------------------------------------------------------- /t/include/cycle1.dth: -------------------------------------------------------------------------------- 1 | (once cycle1) 2 | 3 | (include "t/include/cycle2.dth") 4 | 5 | (def cycle1fn (fn extern int (void) 22)) 6 | -------------------------------------------------------------------------------- /t/include/cycle2.dth: -------------------------------------------------------------------------------- 1 | (once cycle2) 2 | 3 | (include "t/include/cycle3.dth") 4 | 5 | (def cycle2fn (fn extern int (void) 33)) 6 | -------------------------------------------------------------------------------- /t/include/cycle3.dth: -------------------------------------------------------------------------------- 1 | (once cycle3) 2 | 3 | (include "t/include/cycle1.dth") 4 | 5 | (def cycle3fn (fn extern int (void) 33)) 6 | -------------------------------------------------------------------------------- /t/src/alignmentof.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def main (fn extern-c int (void) 4 | (printf "%d\n" (alignmentof char)) 5 | (printf "%d\n" (alignmentof uint16)) 6 | (printf "%d\n" (alignmentof int)) 7 | 0)) 8 | -------------------------------------------------------------------------------- /t/src/anon-array-struct.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | (import macros) 3 | 4 | (def m 5 | (struct extern 6 | ((a int) 7 | (b (array-of 5 (struct ((a int) (b char))))) 8 | (c int)))) 9 | 10 | (def main 11 | (fn extern-c int (void) 12 | (def mym (var auto m)) 13 | (setf (:@ ($ (@: mym b) 0) a) 10) 14 | (setf (:@ ($ (@: mym b) 1) b) #\c) 15 | (setf (:@ ($ (@: mym b) 4) a) 100) 16 | (printf "%d %c %d\n" 17 | (@:@ ($ (@: mym b) 0) a) 18 | (@:@ ($ (@: mym b) 1) b) 19 | (@:@ ($ (@: mym b) 4) a)) 20 | 0)) 21 | -------------------------------------------------------------------------------- /t/src/anon-fn.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def test 4 | (fn extern int ((fn (p (fn int ((a int))))) 5 | (val int)) 6 | (funcall fn val))) 7 | 8 | (def main 9 | (fn extern-c int (void) 10 | (printf "%d\n" (test (fn int ((a int)) (* 2 a)) 10)) 11 | 0)) 12 | -------------------------------------------------------------------------------- /t/src/anon-struct.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def m 4 | (struct extern ((a int) (b char) (c (struct ((a int) (b char))))))) 5 | 6 | (def main 7 | (fn extern-c int (void) 8 | (def n (var auto m)) 9 | (setf (: (@: n c) a) 10) 10 | (printf "%d\n" (@: (@: n c) a)) 11 | 0)) 12 | -------------------------------------------------------------------------------- /t/src/anonfn-scope.dt: -------------------------------------------------------------------------------- 1 | (import macros) 2 | 3 | (using-namespace std.macros 4 | (def check-struct (macro intern (void) 5 | (if (exists-type mc (mnfv mc "*Struct*")) 6 | (printf "*Struct* exists\n") 7 | (printf "*Struct* does not exist\n")) 8 | (nullptr DNode)))) 9 | 10 | (def main (fn extern-c int (void) 11 | (def *Struct* (struct intern ((a int)))) 12 | (check-struct) 13 | (def anon-func (var auto \ (fn void (void) 14 | (check-struct)))) 15 | 0)) 16 | 17 | -------------------------------------------------------------------------------- /t/src/aref-problem.dt: -------------------------------------------------------------------------------- 1 | (import macros) 2 | (import cstdio) 3 | 4 | (def obj (struct intern ((val (array-of 2 int))))) 5 | 6 | (using-namespace std.macros 7 | (def val (macro intern (obj) 8 | (qq : (uq obj) val))) 9 | ) 10 | 11 | (def obj (var intern obj)) 12 | 13 | (def main (fn extern-c int (void) 14 | (setf (val obj) (array 1 2)) ;;works 15 | (printf "%d\n" (@ ($ (@ (: obj val)) 1))) 16 | (printf "%d\n" (@ ($ (@ (val obj)) 1))) ;;does not work, even if it works when calling it directly with the macroexpansion 17 | 0)) 18 | -------------------------------------------------------------------------------- /t/src/arity.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | (import macros) 3 | 4 | (def get-arity 5 | (macro intern (fn) 6 | (let ((n int (arity mc fn)) 7 | (str (array-of 10 char))) 8 | (sprintf str "%d" n) 9 | (std.macros.mnfv mc str)))) 10 | 11 | (def main 12 | (fn extern-c int (void) 13 | (printf "%d\n" (get-arity malloc)) 14 | (printf "%d\n" (get-arity printf)) 15 | (printf "%d\n" (get-arity memcpy)) 16 | 0)) 17 | 18 | -------------------------------------------------------------------------------- /t/src/array-address.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def main 4 | (fn extern-c int (void) 5 | (def thing (var auto (array-of 10 int))) 6 | (def ptr (var auto (p (array-of 10 int)) (# thing))) 7 | (def ptr2 (var auto (p int) ($ thing 0))) 8 | 0)) 9 | -------------------------------------------------------------------------------- /t/src/array-deref.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | (import macros) 3 | 4 | (def main 5 | (fn extern-c int (void) 6 | (let ((n (array-of 3 int) (array 1 2 3)) 7 | (i \ 0)) 8 | (for true (< i 3) (incv i) 9 | (printf "%d\n" (@$ n i))) 10 | 0))) 11 | -------------------------------------------------------------------------------- /t/src/array-init.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def fvar (var intern float 0.0)) 4 | 5 | (def init (fn intern void ((n (ref float))) 6 | (setf n fvar) 7 | (setv fvar (+ fvar 1.0)) 8 | (return))) 9 | 10 | (def main (fn extern-c int (void) 11 | (let ((n (array-of 10 float)) 12 | (i \ 0)) 13 | (for true (< i 10) (incv i) 14 | (printf "%d\n" (cast (@$ n i) int))) 15 | 0))) 16 | -------------------------------------------------------------------------------- /t/src/array-literal-fc.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def myfn 4 | (fn extern int ((n (p int))) 5 | (printf "%d %d\n" (@ ($ n 0)) (@ ($ n 1))) 6 | 0)) 7 | 8 | (def main 9 | (fn extern-c int (void) 10 | (myfn (array-of 2 int (array 1 2))) 11 | 0)) 12 | -------------------------------------------------------------------------------- /t/src/array-literal-md.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def main 4 | (fn extern-c int (void) 5 | (def v (var auto (array-of 2 (array-of 2 int)) 6 | (array (array 1 2) (array 3 4)))) 7 | 8 | (printf "%d %d %d %d\n" 9 | (@ ($ (@ ($ v 0)) 0)) 10 | (@ ($ (@ ($ v 0)) 1)) 11 | (@ ($ (@ ($ v 1)) 0)) 12 | (@ ($ (@ ($ v 1)) 1))) 13 | 14 | 0)) 15 | -------------------------------------------------------------------------------- /t/src/array-literal-simple.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def main 4 | (fn extern-c int (void) 5 | (def v (var auto (array-of 10 int) (array 1 2 3 4 5 6 7 8 9 10))) 6 | 7 | (printf "%d\n" (@ ($ v 0))) 8 | (printf "%d\n" (@ ($ v 1))) 9 | (printf "%d\n" (@ ($ v 2))) 10 | (printf "%d\n" (@ ($ v 3))) 11 | (printf "%d\n" (@ ($ v 4))) 12 | (printf "%d\n" (@ ($ v 5))) 13 | (printf "%d\n" (@ ($ v 6))) 14 | (printf "%d\n" (@ ($ v 7))) 15 | (printf "%d\n" (@ ($ v 8))) 16 | (printf "%d\n" (@ ($ v 9))) 17 | 18 | 0)) 19 | -------------------------------------------------------------------------------- /t/src/array-of.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def main (fn extern-c int (void) 4 | (def x (var auto \ (array-of 2 float (array 0.1 0.2)))) 5 | (printf "%f %f\n" (@$ x 0) (@$ x 1)) 6 | (return 0))) 7 | -------------------------------------------------------------------------------- /t/src/array-ref-params.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def myfn (fn intern int ((a (ref (array-of 2 float)))) 4 | 1234)) 5 | 6 | (def main (fn extern-c int (void) 7 | (def n (var auto (array-of 2 float) (array 1.0 2.0))) 8 | (printf "%d\n" (myfn n)) 9 | 0)) 10 | -------------------------------------------------------------------------------- /t/src/assert-disabled.dt: -------------------------------------------------------------------------------- 1 | (import assert) 2 | (import cstdio) 3 | 4 | (std.disable-assertions) 5 | 6 | (def main 7 | (fn extern-c int (void) 8 | (std.assert (= 0 1)) 9 | (printf "hello\n") 10 | 0)) 11 | -------------------------------------------------------------------------------- /t/src/assert-not-ok.dt: -------------------------------------------------------------------------------- 1 | (import assert) 2 | (import cstdio) 3 | 4 | (def main 5 | (fn extern-c int (void) 6 | (std.assert (= 0 1)) 7 | (printf "hello\n") 8 | 0)) 9 | -------------------------------------------------------------------------------- /t/src/assert-ok.dt: -------------------------------------------------------------------------------- 1 | (import assert) 2 | (import cstdio) 3 | 4 | (def main 5 | (fn extern-c int (void) 6 | (std.assert (= 1 1)) 7 | (printf "hello\n") 8 | 0)) 9 | -------------------------------------------------------------------------------- /t/src/bitset-enum-basic.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | (import bitset-enum) 3 | 4 | (def-bitset-enum myenum intern int (a b c d e)) 5 | 6 | (def main (fn extern-c int (void) 7 | (printf "%d\n" a) 8 | (printf "%d\n" b) 9 | (printf "%d\n" c) 10 | (printf "%d\n" d) 11 | (printf "%d\n" e) 12 | 0)) 13 | -------------------------------------------------------------------------------- /t/src/bitset-enum-values.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | (import bitset-enum) 3 | 4 | (def-bitset-enum myenum intern int ((a 2) b (c 0x10) d)) 5 | 6 | (def main (fn extern-c int (void) 7 | (printf "%d\n" a) 8 | (printf "%d\n" b) 9 | (printf "%d\n" c) 10 | (printf "%d\n" d) 11 | 0)) 12 | -------------------------------------------------------------------------------- /t/src/bitwise.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def main 4 | (fn extern-c int (void) 5 | (def n (var auto uint 1)) 6 | (def one (var auto uint 1)) 7 | (printf "%u\n" (& n one)) 8 | (printf "%u\n" (| n one)) 9 | (printf "%u\n" (^ n one)) 10 | (printf "%u\n" (<< one 1)) 11 | (printf "%u\n" (<< (<< one 1) 1)) 12 | (printf "%u\n" (>> (<< (<< one 1) 1) 1)) 13 | (printf "%u\n" (~ (cast 0 uint))) 14 | 0)) 15 | -------------------------------------------------------------------------------- /t/src/bools.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def my!= 4 | (fn intern bool ((num1 int) (num2 int)) 5 | (return 6 | (if (= num1 num2) false true)))) 7 | 8 | (def main 9 | (fn extern-c int (void) 10 | 11 | (printf "1 != 2? %d\n" (if (my!= 1 2) 1 0)) 12 | (printf "1 != 1? %d\n" (if (my!= 1 1) 1 0)) 13 | 14 | (return 0))) 15 | -------------------------------------------------------------------------------- /t/src/cf-for.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | (import macros) 3 | 4 | (def main 5 | (fn extern-c int (void) 6 | (def n (var auto int)) 7 | 8 | (for (setv n 10) (> n 0) (decv n) 9 | (printf "n is %d\n" n)) 10 | 11 | (printf "Finished\n") 12 | (return 0))) 13 | -------------------------------------------------------------------------------- /t/src/cf-while-break.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | (import macros) 3 | 4 | (def main 5 | (fn extern-c int (void) 6 | (def n (var auto int 10)) 7 | 8 | (while (> n 0) 9 | (printf "n is %d\n" n) 10 | (if (< n 5) 11 | (break) 12 | (setv n (- n 1)))) 13 | 14 | (printf "Finished\n") 15 | (return 0))) 16 | -------------------------------------------------------------------------------- /t/src/cf-while-continue.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | (import macros) 3 | 4 | (def main 5 | (fn extern-c int (void) 6 | (def n (var auto int 10)) 7 | 8 | (while (> n 0) 9 | (printf "n is %d\n" n) 10 | (if (= (/ n 2) 4) 11 | (do (setv n (- n 2)) (continue)) 12 | 0) 13 | (setv n (- n 1)) 14 | (continue)) 15 | 16 | (printf "Finished\n") 17 | (return 0))) 18 | -------------------------------------------------------------------------------- /t/src/cf-while.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | (import macros) 3 | 4 | (def main 5 | (fn extern-c int (void) 6 | (def n (var auto int 10)) 7 | 8 | (while (> n 0) 9 | (printf "n is %d\n" n) 10 | (setv n (- n 1))) 11 | 12 | (printf "Finished\n") 13 | (return 0))) 14 | -------------------------------------------------------------------------------- /t/src/char.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def main 4 | (fn extern-c int (void) 5 | (def str (var auto (array-of 10 char))) 6 | 7 | (printf "%c" #\SPACE) 8 | (printf "%c" #\a) 9 | (printf "%c" #\TAB) 10 | (printf "%c" #\Z) 11 | (printf "%c" #\NEWLINE) 12 | (printf "%c" #\\) 13 | (printf "%c" #\NULL) 14 | 15 | (setf ($ str 0) #\A) 16 | (setf ($ str 1) #\z) 17 | (setf ($ str 2) #\NEWLINE) 18 | (setf ($ str 3) #\NULL) 19 | 20 | (printf "%s" str) 21 | 0)) 22 | -------------------------------------------------------------------------------- /t/src/cond.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | (import stdlib) 3 | 4 | (def test-fn (fn intern int ((n int)) 5 | (cond ((= n 1) 2) 6 | ((= n 2) 3) 7 | (true 4)))) 8 | 9 | (def main (fn extern-c int (void) 10 | (printf "%d\n" (test-fn 1)) 11 | (printf "%d\n" (test-fn 2)) 12 | (printf "%d\n" (test-fn 3)) 13 | (printf "%d\n" (test-fn 4)) 14 | 0)) 15 | -------------------------------------------------------------------------------- /t/src/const-global.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def n (var intern (const int) 100)) 4 | 5 | (def main (fn extern-c int (void) 6 | (printf "%d\n" n) 7 | 0)) 8 | -------------------------------------------------------------------------------- /t/src/const-ptrs.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def main (fn extern-c int (void) 4 | (let ((pn (p int)) 5 | (n int 10) 6 | (pn2 (const (p int)) (# n))) 7 | (setv pn (p+ (p- pn2 1) 1)) 8 | (printf "%d\n" (@ pn))) 9 | 0)) 10 | -------------------------------------------------------------------------------- /t/src/def-refs-implicit.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def mys (struct intern ((a int) (b int) (c int)))) 4 | 5 | (def def-refs (fn intern void ((a (ref mys))) 6 | (def mya (var auto \ (@ a))) 7 | (printf "%d\n" (@: mya c)) 8 | (return))) 9 | 10 | (def main (fn extern-c int (void) 11 | (def a (var auto mys)) 12 | (setf (: a c) 3) 13 | (def-refs a) 14 | 0)) 15 | -------------------------------------------------------------------------------- /t/src/definition-order.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def x (fn intern int ((a int)) (printf "int\n") a)) 4 | (def x (macro intern (a) (printf "other\n") a)) 5 | 6 | (def y (macro intern (a) (printf "other\n") a)) 7 | (def y (fn intern int ((a int)) (printf "int\n") a)) 8 | 9 | (def main (fn extern-c int (void) 10 | (x 1) 11 | (x "a") 12 | (y 1) 13 | (y "a") 14 | 0)) 15 | -------------------------------------------------------------------------------- /t/src/do.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def main 4 | (fn extern-c int (void) 5 | (def temp (var auto int)) 6 | (setv temp (do (printf "Setting temp\n") 7 | (printf "Not just yet though\n") 8 | (printf "OK now!\n") 9 | 1)) 10 | (printf "Temp is %d\n" temp) 11 | (return 0))) 12 | -------------------------------------------------------------------------------- /t/src/dtm-enum-user-macro.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | (import macros) 3 | (import dtm-enum-macro) 4 | 5 | (def m 6 | (macro intern (void) 7 | (printf "%d %d %d %d %d %d %d %d %d %d %d\n" 8 | a b c d e f g h i j k) 9 | (nullptr DNode))) 10 | 11 | (m) 12 | 13 | (def main 14 | (fn extern-c int (void) 15 | 0)) 16 | -------------------------------------------------------------------------------- /t/src/dtm-enum-user.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | (import dtm-enum) 3 | 4 | (def main 5 | (fn extern-c int (void) 6 | (printf "%d %d %d %d %d %d %d %d %d %d %d\n" 7 | a b c d e f g h i j k ) 0)) 8 | -------------------------------------------------------------------------------- /t/src/dtm-enum.dt: -------------------------------------------------------------------------------- 1 | (import enum) 2 | (def-enum thing extern int (a b c (d 1) e (f 0) (g -1) h i j k)) 3 | -------------------------------------------------------------------------------- /t/src/dtm-fn-user-macro.dt: -------------------------------------------------------------------------------- 1 | (import dtm-fn-macro) 2 | (import cstdio) 3 | (import macros) 4 | 5 | (def m 6 | (macro intern (void) 7 | (printf "%d\n" (dtm-module-function)) 8 | (nullptr DNode))) 9 | 10 | (m) 11 | 12 | (def main 13 | (fn extern-c int (void) 14 | 0)) 15 | -------------------------------------------------------------------------------- /t/src/dtm-fn-user.dt: -------------------------------------------------------------------------------- 1 | (import dtm-fn) 2 | (import cstdio) 3 | 4 | (def main 5 | (fn extern-c int (void) 6 | (printf "%d\n" (dtm-module-function)) 7 | 0)) 8 | -------------------------------------------------------------------------------- /t/src/dtm-fn.dt: -------------------------------------------------------------------------------- 1 | (def dtm-module-function 2 | (fn extern int (void) 3 | 100)) 4 | -------------------------------------------------------------------------------- /t/src/dtm-importforms-user.dt: -------------------------------------------------------------------------------- 1 | (import mod-importforms (fun var str enu d)) 2 | (import cstdio) 3 | 4 | (def main 5 | (fn extern-c int (void) 6 | (printf "%d\n" (fun)) 7 | (printf "%d\n" var) 8 | (def x (var auto str ((a 10) (b 20)))) 9 | (def y (var auto enu d)) 10 | (printf "%d %d %d\n" 11 | (@: x a) 12 | (@: x b) 13 | y) 14 | 0)) 15 | -------------------------------------------------------------------------------- /t/src/dtm-importforms.dt: -------------------------------------------------------------------------------- 1 | (module mod-importforms) 2 | 3 | (import enum) 4 | 5 | (def fun (fn extern int (void) 100)) 6 | 7 | (def var (var extern int 1000)) 8 | 9 | (def str (struct extern ((a int) (b int)))) 10 | 11 | (def-enum enu extern int (a b c d)) 12 | -------------------------------------------------------------------------------- /t/src/dtm-inc-pre-user.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | (import dtm-inc-pre) 3 | 4 | (def main 5 | (fn extern-c int (void) 6 | (printf "Hello\n") 7 | (mod-fn) 8 | 0)) 9 | -------------------------------------------------------------------------------- /t/src/dtm-inc-user.dt: -------------------------------------------------------------------------------- 1 | (import dtm-inc) 2 | (import cstdio) 3 | 4 | (def main 5 | (fn extern-c int (void) 6 | (printf "Hello\n") 7 | (mod-fn) 8 | 0)) 9 | -------------------------------------------------------------------------------- /t/src/dtm-inc.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def mod-fn 4 | (fn extern-c int (void) 5 | (printf "Hello\n") 6 | 0)) 7 | -------------------------------------------------------------------------------- /t/src/dtm-intover-user.dt: -------------------------------------------------------------------------------- 1 | (import dtm-noimport-intover (x y)) 2 | (import cstdio) 3 | 4 | (def z (var extern int 1000)) 5 | 6 | (def main 7 | (fn extern-c int (void) 8 | (printf "%d %d %d\n" x y z) 9 | 0)) 10 | -------------------------------------------------------------------------------- /t/src/dtm-macro-user.dt: -------------------------------------------------------------------------------- 1 | (import dtm-macro) 2 | 3 | (dtm-module-macro) 4 | 5 | (def main 6 | (fn extern-c int (void) 7 | 0)) 8 | -------------------------------------------------------------------------------- /t/src/dtm-macro.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | (import macros) 3 | 4 | (def dtm-module-macro 5 | (macro extern (void) 6 | (printf "Macro action\n") 7 | (nullptr DNode))) 8 | -------------------------------------------------------------------------------- /t/src/dtm-mulinc.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | (import mod1) 3 | (import mod2) 4 | 5 | (def main 6 | (fn extern-c int (void) 7 | (printf "hello\n") 8 | 0)) 9 | -------------------------------------------------------------------------------- /t/src/dtm-noimport-int.dt: -------------------------------------------------------------------------------- 1 | (module dtm-noimport-int) 2 | 3 | (def x (var extern int 100)) 4 | (def y (var extern int 200)) 5 | (def z (var intern int 300)) 6 | -------------------------------------------------------------------------------- /t/src/dtm-noimport-intover.dt: -------------------------------------------------------------------------------- 1 | (module dtm-noimport-intover) 2 | 3 | (def x (var extern int 100)) 4 | (def y (var extern int 200)) 5 | (def z (var intern int 300)) 6 | -------------------------------------------------------------------------------- /t/src/dtm-noimport-user.dt: -------------------------------------------------------------------------------- 1 | (import dtm-noimport (x)) 2 | (import cstdio) 3 | 4 | (def main 5 | (fn extern-c int (void) 6 | (def myvar (var auto int x)) 7 | (printf "%d\n" myvar) 8 | (printf "%d\n" y) 9 | 0)) 10 | -------------------------------------------------------------------------------- /t/src/dtm-noimport-user2.dt: -------------------------------------------------------------------------------- 1 | (import dtm-noimport-int (z zz)) 2 | -------------------------------------------------------------------------------- /t/src/dtm-noimport.dt: -------------------------------------------------------------------------------- 1 | (module dtm-noimport) 2 | 3 | (def x (var extern int 100)) 4 | (def y (var extern int 200)) 5 | (def z (var intern int 300)) 6 | -------------------------------------------------------------------------------- /t/src/dtm-ns-user.dt: -------------------------------------------------------------------------------- 1 | (import dtm-ns) 2 | 3 | (def main 4 | (fn extern-c int (void) 5 | (printf "%d\n" (x.f)) 6 | (printf "%d\n" 2) 7 | (let ((thing x.s ((a 10) (b #\c))) 8 | (e-val x.e x.a)) 9 | (printf "%d %c %d\n" (@: thing a) 10 | (@: thing b) 11 | e-val)) 12 | 0)) 13 | -------------------------------------------------------------------------------- /t/src/dtm-ns.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | (import macros) 3 | (import enum) 4 | 5 | (namespace x 6 | (def f 7 | (fn extern int (void) 100)) 8 | (def s 9 | (struct extern((a int) (b char)))) 10 | (def-enum e extern int (a b c))) 11 | -------------------------------------------------------------------------------- /t/src/dtm-nsimport-user.dt: -------------------------------------------------------------------------------- 1 | (import dtm-nsimport (one two.my two.myfn)) 2 | (import cstdio) 3 | 4 | (def main 5 | (fn extern-c int (void) 6 | (using-namespace one 7 | (printf "%d %d\n" x y)) 8 | (using-namespace two 9 | (def mine (var auto two.my ((a 100) (b #\a)))) 10 | (printf "%d %c %d\n" 11 | (@: mine a) 12 | (@: mine b) 13 | (myfn))) 14 | 0)) 15 | -------------------------------------------------------------------------------- /t/src/dtm-nsimport.dt: -------------------------------------------------------------------------------- 1 | (module dtm-nsimport) 2 | 3 | (namespace one 4 | (def x (var extern int 100)) 5 | (def y (var extern int 200))) 6 | 7 | (namespace two 8 | (def my (struct extern ((a int) (b char)))) 9 | (def myfn (fn extern int (void) 5000))) 10 | -------------------------------------------------------------------------------- /t/src/dtm-opstruct-user.dt: -------------------------------------------------------------------------------- 1 | (import dtm-opstruct) 2 | 3 | (def a (var intern opstruct)) 4 | (def b (var intern (p opstruct))) 5 | (def c (var intern instruct)) 6 | (def d (var intern (p instruct))) 7 | -------------------------------------------------------------------------------- /t/src/dtm-opstruct.dt: -------------------------------------------------------------------------------- 1 | (module dtm-opstruct) 2 | 3 | (def opstruct (struct opaque ((a int) (b int)))) 4 | (def instruct (struct intern ((a int) (b int)))) 5 | -------------------------------------------------------------------------------- /t/src/dtm-preserve-imported1.dt: -------------------------------------------------------------------------------- 1 | (module dtm-preserve-imported1) 2 | 3 | (def mfn1 (fn extern int (void) 100)) 4 | (def mfn2 (fn extern int (void) 200)) 5 | -------------------------------------------------------------------------------- /t/src/dtm-preserve-imported2.dt: -------------------------------------------------------------------------------- 1 | (module dtm-preserve-imported2) 2 | 3 | (import dtm-preserve-imported1 (mfn1)) 4 | -------------------------------------------------------------------------------- /t/src/dtm-retval-user.dt: -------------------------------------------------------------------------------- 1 | (import modretval) 2 | 3 | (def main (fn extern-c int (void) 4 | (myfn))) 5 | -------------------------------------------------------------------------------- /t/src/dtm-retval.dt: -------------------------------------------------------------------------------- 1 | (module modretval) 2 | 3 | (def myfn (fn extern (retval int) (void) 10)) 4 | -------------------------------------------------------------------------------- /t/src/dtm-struct-user-macro.dt: -------------------------------------------------------------------------------- 1 | (import dtm-struct-macro) 2 | (import cstdio) 3 | (import macros) 4 | 5 | (def m 6 | (macro extern (void) 7 | (let ((m dtm-module-struct ((a 10) (b #\c) (c 20)))) 8 | (printf "%d %c %d\n" 9 | (@: m a) 10 | (@: m b) 11 | (@: m c)) 12 | (nullptr DNode)))) 13 | 14 | (m) 15 | 16 | (def main 17 | (fn extern-c int (void) 18 | 0)) 19 | -------------------------------------------------------------------------------- /t/src/dtm-struct-user.dt: -------------------------------------------------------------------------------- 1 | (import dtm-struct) 2 | (import cstdio) 3 | (import macros) 4 | 5 | (def main 6 | (fn extern-c int (void) 7 | (let ((m dtm-module-struct ((a 10) (b #\c) (c 20)))) 8 | (printf "%d %c %d\n" 9 | (@: m a) 10 | (@: m b) 11 | (@: m c)) 12 | 0))) 13 | -------------------------------------------------------------------------------- /t/src/dtm-struct.dt: -------------------------------------------------------------------------------- 1 | (def dtm-module-struct (struct extern ((a int) (b char) (c int)))) 2 | -------------------------------------------------------------------------------- /t/src/dtm-typemap-dashm.dt: -------------------------------------------------------------------------------- 1 | (module pairintint-dashm) 2 | 3 | (import cstdio) 4 | (import macros) 5 | (import utility) 6 | (import concepts) 7 | 8 | (std.concepts.instantiate Pair int int) 9 | -------------------------------------------------------------------------------- /t/src/dtm-typemap-user-dashm.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | (import macros) 3 | (import pairintint-dashm) 4 | 5 | (def myfn 6 | (fn extern int ((a (Pair int int))) 7 | 0)) 8 | 9 | (def main 10 | (fn extern-c int (void) 11 | (myfn 100) 12 | 0)) 13 | -------------------------------------------------------------------------------- /t/src/dtm-typemap-user.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | (import macros) 3 | (import pairintint) 4 | 5 | (def myfn 6 | (fn extern int ((a (Pair int int))) 7 | 0)) 8 | 9 | (def main 10 | (fn extern-c int (void) 11 | (myfn 100) 12 | 0)) 13 | -------------------------------------------------------------------------------- /t/src/dtm-typemap.dt: -------------------------------------------------------------------------------- 1 | (module pairintint) 2 | 3 | (import cstdio) 4 | (import macros) 5 | (import utility) 6 | (import concepts) 7 | 8 | (std.concepts.instantiate Pair int int) 9 | -------------------------------------------------------------------------------- /t/src/dtm-var-user-macro.dt: -------------------------------------------------------------------------------- 1 | (import dtm-var-macro) 2 | (import cstdio) 3 | (import macros) 4 | 5 | (def m 6 | (macro intern (void) 7 | (printf "%d\n" dtm-module-variable) 8 | (incv dtm-module-variable) 9 | (printf "%d\n" dtm-module-variable) 10 | (nullptr DNode))) 11 | 12 | (m) 13 | 14 | (def main 15 | (fn extern-c int (void) 16 | (printf "%d\n" dtm-module-variable) 17 | 0)) 18 | -------------------------------------------------------------------------------- /t/src/dtm-var-user.dt: -------------------------------------------------------------------------------- 1 | (import dtm-var) 2 | (import cstdio) 3 | 4 | (def main 5 | (fn extern-c int (void) 6 | (printf "%d\n" dtm-module-variable) 7 | 0)) 8 | -------------------------------------------------------------------------------- /t/src/dtm-var.dt: -------------------------------------------------------------------------------- 1 | (def dtm-module-variable (var extern int 100)) 2 | -------------------------------------------------------------------------------- /t/src/dtm1.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | -------------------------------------------------------------------------------- /t/src/dtm2.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | -------------------------------------------------------------------------------- /t/src/dtor-array.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | (import macros) 3 | 4 | (using-namespace std 5 | 6 | (def destroy 7 | (fn extern void ((n (ref float))) 8 | (printf "destroying %f\n" (@ n)) 9 | (return))) 10 | 11 | (def main 12 | (fn extern-c int (void) 13 | (def x (var auto (array-of 10 float))) 14 | (let ((i \ 0)) 15 | (for true (< i 10) (incv i) 16 | (setf ($ x i) (cast i float)))) 17 | 0)) 18 | 19 | ) 20 | -------------------------------------------------------------------------------- /t/src/dtor-goto-back.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def destroy 4 | (fn extern void ((n (ref float))) 5 | (fprintf stdout "destroying %f\n" (@ n)) 6 | (return))) 7 | 8 | (using-namespace std 9 | 10 | (def main 11 | (fn extern-c int (void) 12 | (def i (var auto int 0)) 13 | (label mylabel) 14 | (def x (var auto float (cast i float))) 15 | (if (< i 10) 16 | (do (incv i) 17 | (goto mylabel)) 18 | 0) 19 | 0)) 20 | 21 | ) 22 | -------------------------------------------------------------------------------- /t/src/dtor-goto-fwd.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def destroy 4 | (fn extern void ((n (ref float))) 5 | (printf "destroying %f\n" (@ n)) 6 | (return))) 7 | 8 | (def main 9 | (fn extern-c int (void) 10 | (def i (var auto int 0)) 11 | (label mylabel) 12 | (def x (var auto float (cast i float))) 13 | (if (< i 10) 14 | (do (incv i) 15 | (printf "Moving to mylabel2\n") 16 | (goto mylabel2)) 17 | 0) 18 | 19 | (label mylabel2) 20 | (printf "Got to mylabel2\n") 21 | 0)) 22 | -------------------------------------------------------------------------------- /t/src/dtor-md-array.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | (import macros) 3 | 4 | (using-namespace std 5 | 6 | (def destroy 7 | (fn extern void ((n (ref float))) 8 | (printf "destroying %f\n" (@ n)) 9 | (return))) 10 | 11 | (def main 12 | (fn extern-c int (void) 13 | (def x (var auto (array-of 3 (array-of 3 float)))) 14 | (let ((i \ 0)) 15 | (for true (< i 3) (incv i) 16 | (let ((j \ 0)) 17 | (for true (< j 3) (incv j) 18 | (setf ($ (@ ($ x i)) j) (cast (* i j) float)))))) 19 | 0)) 20 | 21 | ) 22 | -------------------------------------------------------------------------------- /t/src/dtor-ns-close.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def destroy 4 | (fn extern void ((n (ref float))) 5 | (fprintf stdout "destroying %f\n" (@ n)) 6 | (return))) 7 | 8 | (using-namespace std 9 | 10 | (def main 11 | (fn extern-c int (void) 12 | (let ((a \ 10) (b \ 1.0) (c \ 20)) 13 | (let ((x \ 30) (y \ 40) (z \ 1.0)) 14 | (printf "%d\n" 100))) 15 | 0)) 16 | 17 | ) 18 | -------------------------------------------------------------------------------- /t/src/dtor-whole-fn.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def destroy 4 | (fn extern void ((n (ref float))) 5 | (printf "destroying %f\n" (@ n)) 6 | (return))) 7 | 8 | (using-namespace std 9 | 10 | (def main 11 | (fn extern-c int (void) 12 | (def p (var auto \ 7.0)) 13 | (def q (var auto float 8.0)) 14 | (def r (var auto float 9.0)) 15 | (let ((a \ 10) (b \ 1.0) (c \ 20)) 16 | (let ((x \ 30) (y \ 40) (z \ 1.0)) 17 | (printf "%d\n" 100))) 18 | 0)) 19 | 20 | ) 21 | -------------------------------------------------------------------------------- /t/src/empty-lists.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (using-namespace std.macros 4 | (def mym (macro intern (a b) 5 | (print b) 6 | (printf "\n") 7 | a))) 8 | 9 | (def main (fn extern-c int (void) 10 | (printf "%d\n" (mym 1 ())) 11 | 0)) 12 | -------------------------------------------------------------------------------- /t/src/empty-main.dt: -------------------------------------------------------------------------------- 1 | (def main 2 | (fn extern-c int (void) 3 | (return 0))) 4 | 5 | -------------------------------------------------------------------------------- /t/src/enum-bitwise.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | (import macros) 3 | (import enum) 4 | 5 | (def-enum thing intern int (a b c d e f g h)) 6 | 7 | (def main 8 | (fn extern-c int (void) 9 | (let ((n thing b) 10 | (m thing d) 11 | (o thing (& n m)) 12 | (p thing (| n m)) 13 | (q thing (^ n m))) 14 | (printf "%d %d %d %d %d\n" n m o p q) 15 | 0))) 16 | -------------------------------------------------------------------------------- /t/src/enum-cast-to.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | (import enum) 3 | 4 | (def-enum thing extern int (a b c d e f g h i)) 5 | 6 | (def main 7 | (fn extern-c int (void) 8 | (printf "%d %d %d %d %d %d %lld %lld %d\n" 9 | (cast (value a) int8) 10 | (cast (value b) uint8) 11 | (cast (value c) int16) 12 | (cast (value d) uint16) 13 | (cast (value e) int32) 14 | (cast (value f) uint32) 15 | (cast (value g) int64) 16 | (cast (value h) uint64) 17 | (cast (value i) uint)) 18 | 0)) 19 | 20 | -------------------------------------------------------------------------------- /t/src/enum-cmp.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | (import enum) 3 | 4 | (def-enum language extern int (english spanish french)) 5 | 6 | (def print 7 | (fn extern int ((a language)) 8 | (if (= a english) (printf "English\n") 9 | (if (= a spanish) (printf "Spanish\n") 10 | (if (= a french) (printf "French\n") 11 | (printf "Unknown\n")))))) 12 | 13 | (def main 14 | (fn extern-c int (void) 15 | (print english) 16 | (print spanish) 17 | (print french) 18 | 0)) 19 | 20 | -------------------------------------------------------------------------------- /t/src/enum-global.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | (import enum) 3 | 4 | (def-enum a intern int (x y z)) 5 | (def myenum (var intern a z)) 6 | (def main (fn extern-c int (void) 7 | (printf "%d\n" myenum) 8 | 0)) 9 | -------------------------------------------------------------------------------- /t/src/enum-hex-problem.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | (import enum) 3 | 4 | (def-enum en extern uint32 ((a 0x1) (b 0x2))) 5 | 6 | (def main 7 | (fn extern-c int (void) 8 | (printf "%u\n%u\n" a b) 9 | 0)) 10 | -------------------------------------------------------------------------------- /t/src/enum-problem.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | (import macros) 3 | (import enum) 4 | 5 | (def-enum e extern int (ONE TWO THREE)) 6 | 7 | (def main 8 | (fn extern-c int (void) 9 | (let ((a e ONE) 10 | (b e TWO) 11 | (c e a)) 12 | (printf "%d %d %d\n" a b c) 13 | 0))) 14 | -------------------------------------------------------------------------------- /t/src/enum-unqualified.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | (import enum) 3 | 4 | (def-enum thing extern int (a b c (d 1) e (f 0) (g -1) h i j k)) 5 | 6 | (def main (fn extern-c int (void) 7 | (printf "%d %d %d %d %d %d %d %d %d %d %d\n" a b c d e f g h i j k) 8 | 0)) 9 | -------------------------------------------------------------------------------- /t/src/enum.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | (import enum) 3 | 4 | (def-enum thing extern int (a b c (d 1) e (f 0) (g -1) h i j k)) 5 | 6 | (def main 7 | (fn extern-c int (void) 8 | (printf "%d %d %d %d %d %d %d %d %d %d %d\n" 9 | (value a) 10 | (value b) 11 | (value c) 12 | (value d) 13 | (value e) 14 | (value f) 15 | (value g) 16 | (value h) 17 | (value i) 18 | (value j) 19 | (value k)) 20 | 0)) 21 | -------------------------------------------------------------------------------- /t/src/errno.dt: -------------------------------------------------------------------------------- 1 | (import cerrno) 2 | (import cstdio) 3 | 4 | (def main 5 | (fn extern-c int (void) 6 | (fopen "/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p" "rw") 7 | (fprintf stderr "%d\n" (errno)) 8 | (perror "asdf") 9 | 0)) 10 | -------------------------------------------------------------------------------- /t/src/exists-variable.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | (import macros) 3 | 4 | (def var-exists 5 | (macro extern (frm) 6 | (if (exists-variable mc frm) 7 | (do (printf "variable exists!\n")) 8 | (do (printf "variable does not exist\n"))) 9 | (nullptr DNode))) 10 | 11 | (def global (var intern int 100)) 12 | 13 | (def main 14 | (fn extern-c int (void) 15 | (def n (var auto int 100)) 16 | (var-exists n) 17 | (var-exists nn) 18 | (var-exists global) 19 | (var-exists stdout) 20 | (var-exists stdout2) 21 | 0)) 22 | 23 | -------------------------------------------------------------------------------- /t/src/extern-var.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | (include "./t/src/other.dt") 3 | 4 | (def main 5 | (fn extern-c int (void) 6 | (printf "%d\n" other-var) 7 | 0)) 8 | -------------------------------------------------------------------------------- /t/src/extra-parens.dt: -------------------------------------------------------------------------------- 1 | (import macros) 2 | 3 | ; For confirming that a macro may return a form like ((second)), where 4 | ; (second) expands in turn to some other form. 5 | 6 | (using-namespace std.macros 7 | (def first (macro intern (void) (qq (second)))) 8 | (def second (macro intern (void) (mnfv mc "third"))) 9 | (def third (fn intern int (void) (printf "extra parens\n"))) 10 | (def main (fn extern-c int (void) (first) 0))) 11 | -------------------------------------------------------------------------------- /t/src/fibonacci.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def fib 4 | (fn intern int ((a int)) 5 | (if (< a 2) 6 | 1 7 | (+ (fib (- a 1)) (fib (- a 2)))))) 8 | 9 | (def main 10 | (fn extern-c int (void) 11 | (def i (var auto int 0)) 12 | 13 | (label begin-loop) 14 | (printf "%d " (fib i)) 15 | (setv i (+ i 1)) 16 | (if (= i 10) 17 | (goto end-loop) 18 | (goto begin-loop)) 19 | 20 | (label end-loop) 21 | (printf "Finished\n") 22 | (return 0))) 23 | -------------------------------------------------------------------------------- /t/src/first-element-list.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def main (fn extern-c int (void) 4 | (def x (var auto \ ((identity +) 1 2))) 5 | (printf "%d\n" x) 6 | (def y (var auto \ ((# + int int) 3 4))) 7 | (printf "%d\n" y) 8 | 0)) 9 | -------------------------------------------------------------------------------- /t/src/float-double-cast.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def main 4 | (fn extern-c int (void) 5 | (def f (var auto float 0.0)) 6 | (def d (var auto double 0.0)) 7 | (def u (var auto uint64 100)) 8 | (setv f (+ f 10.0)) 9 | (setv f (+ f (cast 10 float))) 10 | (setv d (+ d (cast f double))) 11 | (printf "%f\n" f) 12 | (printf "%f\n" d) 13 | (setv d (+ d (cast (* (cast -1 float) f) double))) 14 | (printf "%f\n" d) 15 | (setv d (+ d (cast u double))) 16 | (printf "%f\n" d) 17 | 18 | 0)) 19 | -------------------------------------------------------------------------------- /t/src/float-double.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def main 4 | (fn extern-c int (void) 5 | (def f (var auto float 10.0)) 6 | (def d (var auto float 20.0)) 7 | (printf "%f\n" f) 8 | (printf "%f\n" d) 9 | (printf "%f %f\n" d f) 10 | (printf "%f %f\n" f d) 11 | 0)) 12 | -------------------------------------------------------------------------------- /t/src/float-problem.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def main 4 | (fn extern-c int (void) 5 | (def f (var auto float (/ 1.0 2.0))) 6 | (def n (var auto int (cast (* (cast 2 float) f) int))) 7 | (printf "%d\n" n) 8 | 0)) 9 | -------------------------------------------------------------------------------- /t/src/fn-arg-collision.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def mac1 4 | (fn intern int ((a int)) 5 | (def int1 (var auto int 0)) 6 | (setv int1 a) 7 | (printf "%d\n" int1) 8 | (return 0))) 9 | 10 | (def mac2 11 | (fn intern int ((a int)) 12 | (def int1 (var auto int 0)) 13 | (setv int1 a) 14 | (printf "%d\n" int1) 15 | (return 0))) 16 | 17 | (def main 18 | (fn extern-c int (void) 19 | (mac1 1) 20 | (mac2 2) 21 | (return 0))) 22 | -------------------------------------------------------------------------------- /t/src/fn-object-multi.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def adder 4 | (struct extern((apply (p (fn int ((self (p adder)) (n int))))) 5 | (n int)))) 6 | 7 | (def add1 8 | (fn extern int ((self (p adder)) (n int)) 9 | (setf (:@ self n) (+ n (@ (:@ self n)))) 10 | (return (@ (:@ self n))))) 11 | 12 | (def main 13 | (fn extern-c int (void) 14 | (def m (var auto adder ((apply (# add1)) (n 0)))) 15 | (m 1) 16 | (m 2) 17 | (m 3) 18 | (m 4) 19 | (m 5) 20 | (m 6) 21 | (printf "%d\n" (m 7)) 22 | 0)) 23 | -------------------------------------------------------------------------------- /t/src/fn-object-simple.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def adder 4 | (struct extern((apply (p (fn int ((self (p adder)))))) 5 | (n int)))) 6 | 7 | (def add1 8 | (fn extern int ((self (p adder))) 9 | (setf (:@ self n) (+ 1 (@ (:@ self n)))) 10 | (return (@ (:@ self n))))) 11 | 12 | (def main 13 | (fn extern-c int (void) 14 | (def m (var auto adder ((apply (# add1 (p adder))) (n 0)))) 15 | (m) 16 | (m) 17 | (m) 18 | (m) 19 | (m) 20 | (m) 21 | (printf "%d\n" (m)) 22 | 0)) 23 | -------------------------------------------------------------------------------- /t/src/foldl.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | (import concepts) 3 | (import algorithms) 4 | (import vector) 5 | 6 | (using-namespace std.concepts 7 | 8 | (instantiate Vector int) 9 | (instantiate foldl (Iterator (Vector int))) 10 | 11 | (def main (fn extern-c int (void) 12 | (let ((vec (Vector int))) 13 | (push-back vec 1) 14 | (push-back vec 2) 15 | (push-back vec 3) 16 | (push-back vec 4) 17 | (let ((res \ (foldl (# + int int) 0 (begin vec) (end vec)))) 18 | (printf "%d\n" res))) 19 | 20 | 0)) 21 | ) 22 | -------------------------------------------------------------------------------- /t/src/for-multiple.dt: -------------------------------------------------------------------------------- 1 | (import stdlib) 2 | 3 | (def main (fn extern-c int (void) 4 | (for ((i \ 0) (j \ 0)) 5 | (and (< i 10) (< j 10)) 6 | (do (incv i) (incv j)) 7 | (printf "%d %d\n" i j)) 8 | 0)) 9 | -------------------------------------------------------------------------------- /t/src/force-multiple-arg.dt: -------------------------------------------------------------------------------- 1 | (import array) 2 | 3 | (using-namespace std.concepts 4 | (instantiate Array (force Type float) 2)) 5 | 6 | (def main (fn extern-c int (void) 7 | (def fs (var auto (Array float 2))) 8 | (setf ($ fs 0) 1.0) 9 | (setf ($ fs 1) 2.0) 10 | (printf "%f %f\n" (@$ fs 0) (@$ fs 1)) 11 | 0)) 12 | -------------------------------------------------------------------------------- /t/src/fp-at-compile-time.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def fun (fn intern int (void) 4 | (return 123))) 5 | 6 | (def fun-ptr (var intern (p (fn int (void))) (# fun))) 7 | 8 | (def main (fn extern-c int (void) 9 | (printf "%d %d\n" (fun) (fun-ptr)) 10 | 0)) 11 | -------------------------------------------------------------------------------- /t/src/fp-type-checking.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def testfn (fn intern int ((f (p (fn int ((a int) (b int))))) 4 | (a int) 5 | (b int)) 6 | (f a b))) 7 | 8 | (def main (fn extern-c int (void) 9 | (printf "%d\n" (testfn (# + int int) 1 2)) 10 | 0)) 11 | 12 | -------------------------------------------------------------------------------- /t/src/free.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def main 4 | (fn extern-c int (void) 5 | (def intp (var auto (p int))) 6 | 7 | (setv intp (cast (malloc (* (cast 100 size) (sizeof int))) (p int))) 8 | (setf ($ intp 0) 0) 9 | (setf ($ intp 1) 1) 10 | (setf ($ intp 99) 99) 11 | 12 | (printf "%d %d %d\n" 13 | (@ ($ intp 0)) 14 | (@ ($ intp 1)) 15 | (@ ($ intp 99))) 16 | 17 | (printf "%d\n" (@ intp)) 18 | 19 | (free (cast intp (p void))) 20 | 21 | (return 0))) 22 | -------------------------------------------------------------------------------- /t/src/gh-198.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def main (fn extern-c int (void) 4 | (def sum (var auto \ 0)) 5 | (for (i \ 0) (< i 500000000) (incv i) 6 | (setv sum (+ sum i))) 7 | (printf "%d\n" sum) 8 | 0)) 9 | -------------------------------------------------------------------------------- /t/src/gh-199.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | (def f (fn (attr cto) intern bool (void) 3 | true)) 4 | (def main (fn extern-c int (void) 5 | (printf "%d\n" (mif (f) 1 2)))) 6 | -------------------------------------------------------------------------------- /t/src/gh-205.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def x (var intern (p char) (nullptr char))) 4 | 5 | (def main (fn extern-c int (void) 6 | (printf "%p\n" x) 7 | 0)) 8 | -------------------------------------------------------------------------------- /t/src/gint.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def a (var intern int8 127)) 4 | (def b (var intern uint8 255)) 5 | (def c (var intern int16 32767)) 6 | (def d (var intern uint16 65535)) 7 | (def e (var intern int32 2147483647)) 8 | (def f (var intern uint32 4294967295)) 9 | (def g (var intern int64 9223372036854775807)) 10 | (def h (var intern uint64 18446744073709551615)) 11 | 12 | (def main 13 | (fn extern-c int (void) 14 | (printf "%x\n%x\n%x\n%x\n%x\n%x\n%llx\n%llx\n" 15 | a b c d e f g h) 16 | 0)) 17 | -------------------------------------------------------------------------------- /t/src/global-ptr-arbitrary.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def myv (var intern int 100)) 4 | (def mys (struct intern ((a int) (b (p int))))) 5 | (def mysi (var intern mys ((a 10) (b (# myv))))) 6 | 7 | (def mprint (macro intern (void) 8 | (printf "%d\n" (@: mysi a)) 9 | (printf "%d\n" (@ (@: mysi b))) 10 | (nullptr DNode))) 11 | 12 | (mprint) 13 | 14 | (def main (fn extern-c int (void) 15 | (printf "%d\n" (@: mysi a)) 16 | (printf "%d\n" (@ (@: mysi b))) 17 | 0)) 18 | -------------------------------------------------------------------------------- /t/src/global-ptr-sc.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def x (var intern int 5)) 4 | (def y (var intern (p int) (# x))) 5 | 6 | (def main 7 | (fn extern-c int (void) 8 | (printf "%d %d\n" x (@ y)) 9 | (setv x 100) 10 | (printf "%d %d\n" x (@ y)) 11 | 0 12 | )) 13 | -------------------------------------------------------------------------------- /t/src/globals.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def my-struct (struct extern((a int) (b int) (c (p (const char))) (d int)))) 4 | (def num (var intern int 1000)) 5 | 6 | (def main 7 | (fn extern-c int (void) 8 | 9 | (def thing (var auto my-struct)) 10 | 11 | (setf (: thing a) num) 12 | (setf (: thing b) num) 13 | (setf (: thing c) "qwer") 14 | (setf (: thing d) 20) 15 | 16 | (printf "%d %d %s %d\n" 17 | (@ (: thing a)) 18 | (@ (: thing b)) 19 | (@ (: thing c)) 20 | (@ (: thing d))) 21 | 22 | (return 0))) 23 | -------------------------------------------------------------------------------- /t/src/gstring.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def s 4 | (var intern (p (const char)) "asdf")) 5 | 6 | (def stype 7 | (struct extern ((a (p (const char)))))) 8 | 9 | (def mys 10 | (var intern stype ((a "qwer")))) 11 | 12 | (def main 13 | (fn extern-c int (void) 14 | (printf "%s\n" s) 15 | (printf "%s\n" (@ (: mys a))) 16 | 0)) 17 | -------------------------------------------------------------------------------- /t/src/gstruct-padding.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def ss (struct extern ((c char) (b (p (const char)))))) 4 | 5 | (def otherfn 6 | (fn extern ss (void) 7 | (def mm (var auto ss)) 8 | (setf (: mm c) #\a) 9 | (setf (: mm b) "asdf") 10 | (return mm))) 11 | 12 | (def a (var intern ss (otherfn))) 13 | 14 | (def main 15 | (fn extern-c int (void) 16 | (printf "%c\n" (@ (: a c))) 17 | (printf "%s\n" (@ (: a b))) 18 | 0)) 19 | -------------------------------------------------------------------------------- /t/src/hello-name.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def main 4 | (fn extern-c int ((argc int) (argv (p (p char)))) 5 | (printf "Hello %s!\n" (@ argv)) 6 | (return 0))) 7 | -------------------------------------------------------------------------------- /t/src/hello-samename.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | (import introspection) 3 | 4 | (def main (fn extern-c int (void) 5 | (def name (var auto (p (const char)) "name")) 6 | (printf "hello, %s\n" name) 7 | 0)) 8 | -------------------------------------------------------------------------------- /t/src/hello-world.dt: -------------------------------------------------------------------------------- 1 | (import cstdio-core) 2 | 3 | (def main 4 | (fn extern-c int (void) 5 | (printf "Hello world!\n") 6 | 0)) 7 | -------------------------------------------------------------------------------- /t/src/hex-literals.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def main 4 | (fn extern-c int (void) 5 | (printf "%u\n" 0x1) 6 | (printf "%u\n" 0xA) 7 | (printf "%u\n" 0xB) 8 | (printf "%u\n" 0xF) 9 | (printf "%u\n" 0xF0) 10 | (printf "%u\n" 0xFFFF) 11 | (printf "%u\n" 0xFFFFFFFF) 12 | 0)) 13 | -------------------------------------------------------------------------------- /t/src/if-branches-different.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def main (fn extern-c int (void) 4 | (if true 0 "asdf") 5 | (printf "done\n") 6 | 0)) 7 | -------------------------------------------------------------------------------- /t/src/if-struct.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def main2 4 | (fn extern-c int (void) 5 | (def mys (struct extern((a int) (b int)))) 6 | (def m (var auto mys ((a 10) (b 20)))) 7 | (printf "%d %d\n" (@ (: m a)) (@ (: m b))) 8 | 0)) 9 | 10 | (def main 11 | (fn extern-c int (void) 12 | (main2) 13 | (def mys (struct extern((a int) (b int)))) 14 | (def m (var auto mys ((a 10) (b 20)))) 15 | (printf "%d %d\n" (@ (: m a)) (@ (: m b))) 16 | 0)) 17 | -------------------------------------------------------------------------------- /t/src/implicit-branch.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | (import macros) 3 | 4 | (def main 5 | (fn extern-c int (void) 6 | (def n (var auto int 10)) 7 | 8 | (while (> n 0) 9 | (printf "n is %d\n" n) 10 | (setv n (- n 1))) 11 | 12 | (while (< n 10) 13 | (printf "n is %d\n" n) 14 | (setv n (+ n 1))) 15 | 16 | (printf "Finished\n") 17 | (return 0))) 18 | -------------------------------------------------------------------------------- /t/src/implicit-funcall.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def myfn 4 | (fn extern-c int (void) 5 | (printf "hello\n") 6 | 0)) 7 | 8 | (def main 9 | (fn extern-c int (void) 10 | (def m (var auto (p (fn int (void))))) 11 | (setv m (# myfn)) 12 | (m) 13 | 0)) 14 | -------------------------------------------------------------------------------- /t/src/implicit-return.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def +1 4 | (fn intern int ((n int)) 5 | (+ 1 n))) 6 | 7 | (def +2 8 | (fn intern int ((n int)) 9 | (+ 2 n))) 10 | 11 | (def implicit-with-if 12 | (fn intern int ((n int)) 13 | (if (< n 50) 3 4))) 14 | 15 | (def main 16 | (fn extern-c int (void) 17 | (printf "%d\n" (+1 0)) 18 | (printf "%d\n" (+2 0)) 19 | (printf "%d\n" (implicit-with-if 25)) 20 | 0)) 21 | -------------------------------------------------------------------------------- /t/src/import-within-fn.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (using-namespace std.macros 4 | (def test (macro intern (void) 5 | (qq do 6 | (import cstdlib) 7 | (rand))))) 8 | 9 | (def main (fn extern-c int (void) 10 | (def x (var auto \ (test))) 11 | (printf "%d\n" x) 12 | 0)) 13 | -------------------------------------------------------------------------------- /t/src/incf-and-decf.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | (import macros) 3 | 4 | (def mys (struct extern((a int) (b int)))) 5 | 6 | (def main 7 | (fn extern-c int (void) 8 | (let ((n mys ((a 10) (b 20)))) 9 | (incf (: n a)) 10 | (decf (: n b)) 11 | (printf "%d\n" (@: n a)) 12 | (printf "%d\n" (@: n b)) 13 | 0))) 14 | -------------------------------------------------------------------------------- /t/src/include-non-toplevel-include.dt: -------------------------------------------------------------------------------- 1 | (import enum) 2 | 3 | (def-enum enum extern uint 4 | ((value 0))) 5 | -------------------------------------------------------------------------------- /t/src/include-non-toplevel.dt: -------------------------------------------------------------------------------- 1 | (namespace include 2 | 3 | (include "include-non-toplevel-include.dt") 4 | 5 | (def print-enum (fn intern void ((a enum)) ;;type enum not defined in this scope 6 | (printf "%u" a))) 7 | 8 | ) 9 | 10 | (def main (fn extern-c int (void) 11 | (include.print-enum include.value) 12 | (printf "\n") 13 | 0)) 14 | -------------------------------------------------------------------------------- /t/src/include-test-2.dt: -------------------------------------------------------------------------------- 1 | (def var1 (var intern int 1000)) 2 | -------------------------------------------------------------------------------- /t/src/include-test.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (include "include-test-2.dt") 4 | 5 | (def main (fn extern-c int (void) 6 | (printf "%d\n" var1) 7 | 0)) 8 | -------------------------------------------------------------------------------- /t/src/include.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def main 4 | (fn extern-c int (void) 5 | (printf "Included %s properly\n" "file") 6 | (return 0))) 7 | -------------------------------------------------------------------------------- /t/src/incorrect-cto-error.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | (import macros) 3 | 4 | (using-namespace std.macros 5 | (def when (macro extern (con rest) ;this works 6 | (def list (var auto \ (get-varargs-list mc (- (arg-count mc) 1) rest))) 7 | (qq if (uq con) 8 | false 9 | (do (uql list))))) 10 | 11 | (def unless (macro extern (con rest) ;this doesn't 12 | (qq if (uq con) 13 | false 14 | (do (uql (get-varargs-list mc (- (arg-count mc) 1) rest))))))) 15 | 16 | (def main 17 | (fn extern-c int (void) 18 | 0)) 19 | -------------------------------------------------------------------------------- /t/src/init-array.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def main (fn extern-c int (void) 4 | (def x (var auto (array-of 2 int) (array 123 456))) 5 | (def y (var auto (array-of 2 int) x)) 6 | (printf "%d %d\n" (@$ x 0) (@$ x 1)) 7 | (printf "%d %d\n" (@$ y 0) (@$ y 1)) 8 | 0)) 9 | -------------------------------------------------------------------------------- /t/src/input-type-basic.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | (import macros) 3 | 4 | (using-namespace std.macros 5 | (def print-arg-types 6 | (macro intern (fn) 7 | (let ((n int (arity mc fn)) 8 | (i int 0)) 9 | (for true (< i n) (incv i) 10 | (print (input-type mc fn i)) 11 | (printf "\n"))) 12 | (mnfv mc "0"))) 13 | ) 14 | 15 | (def main 16 | (fn extern-c int (void) 17 | (print-arg-types malloc) 18 | (print-arg-types printf) 19 | (print-arg-types memcpy) 20 | 0)) 21 | 22 | -------------------------------------------------------------------------------- /t/src/intern-in-fn-explicit-expr.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def myfn (fn intern void (void) 4 | (def myintern (var intern int (+ 0 1))) 5 | (printf "%d\n" myintern) 6 | (setv myintern (+ myintern 1)) 7 | (return))) 8 | 9 | (def main (fn extern-c int (void) 10 | (myfn) 11 | (myfn) 12 | (myfn) 13 | 0)) 14 | -------------------------------------------------------------------------------- /t/src/intern-in-fn-explicit.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def myfn (fn intern void (void) 4 | (def myintern (var intern int 0)) 5 | (printf "%d\n" myintern) 6 | (setv myintern (+ myintern 1)) 7 | (return))) 8 | 9 | (def main (fn extern-c int (void) 10 | (myfn) 11 | (myfn) 12 | (myfn) 13 | 0)) 14 | -------------------------------------------------------------------------------- /t/src/invoke-var-with-args.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def invoke 4 | (fn intern void ((a int) (b int)) 5 | (printf "called %d\n" b) 6 | (return))) 7 | 8 | (def main (fn extern-c int (void) 9 | (def x (var auto int 0)) 10 | (x 1) 11 | 0)) 12 | -------------------------------------------------------------------------------- /t/src/invoke-var.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def invoke 4 | (fn intern void ((a int)) 5 | (printf "called\n") 6 | (return))) 7 | 8 | (def main (fn extern-c int (void) 9 | (def x (var auto int 0)) 10 | (x) 11 | 0)) 12 | -------------------------------------------------------------------------------- /t/src/is-lvalue.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def mys (struct intern ((a int) (b int)))) 4 | 5 | (def m-is-lvalue (macro intern (frm) 6 | (printf "%d\n" (is-lvalue mc frm)) 7 | (return (nullptr DNode)))) 8 | 9 | (def main (fn extern-c int (void) 10 | (m-is-lvalue not-exists) 11 | (def x (var auto int 0)) 12 | (m-is-lvalue x) 13 | (def y (var auto mys)) 14 | (m-is-lvalue y) 15 | (m-is-lvalue (@: y a)) 16 | (m-is-lvalue (@: y b)) 17 | (def z (var auto (array-of 100 int))) 18 | (m-is-lvalue (@$ z 50)) 19 | (m-is-lvalue (arbitrary form)) 20 | 0)) 21 | -------------------------------------------------------------------------------- /t/src/labels.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def main 4 | (fn extern-c int (void) 5 | 6 | (def i (var auto int 0)) 7 | 8 | (label begin-loop) 9 | 10 | (printf "In loop, index is %d\n" i) 11 | (setv i (+ i 1)) 12 | 13 | (if (= i 10) 14 | (goto end-loop) 15 | (goto begin-loop)) 16 | 17 | (label end-loop) 18 | (printf "Finished loop\n") 19 | 20 | (return 0))) 21 | -------------------------------------------------------------------------------- /t/src/let.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | (import macros) 3 | 4 | (def main 5 | (fn extern-c int (void) 6 | (let ((a int 1) 7 | (b int 2) 8 | (c int) 9 | (d (p (const char)) "let form")) 10 | (setv c 3) 11 | (printf "%d: %s\n" (+ a (+ b c)) d)) 12 | 0)) 13 | -------------------------------------------------------------------------------- /t/src/lfc-problem.dt: -------------------------------------------------------------------------------- 1 | (import macros) 2 | (def f1 (fn intern void (void))) 3 | (def f2 (fn intern void (void) (f1))) 4 | (using-namespace std.macros 5 | (def m (macro intern (void) 6 | (nullptr DNode))) 7 | (def m2 (macro intern (void) 8 | (m) 9 | (nullptr DNode)))) 10 | -------------------------------------------------------------------------------- /t/src/libmod-importforms-nomacros.bc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomhrr/dale/458a543c0d2eb66564755875dd71fb8ab49dd88c/t/src/libmod-importforms-nomacros.bc -------------------------------------------------------------------------------- /t/src/libmod-importforms.bc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomhrr/dale/458a543c0d2eb66564755875dd71fb8ab49dd88c/t/src/libmod-importforms.bc -------------------------------------------------------------------------------- /t/src/link-bc-1.dt: -------------------------------------------------------------------------------- 1 | (def myextfn 2 | (fn extern int (void))) 3 | 4 | (def main 5 | (fn extern-c int (void) 6 | (return (myextfn)))) 7 | -------------------------------------------------------------------------------- /t/src/link-bc-2.dt: -------------------------------------------------------------------------------- 1 | (def myextfn 2 | (fn extern int (void) 3 | (return 100))) 4 | -------------------------------------------------------------------------------- /t/src/locale.dt: -------------------------------------------------------------------------------- 1 | (import macros) 2 | (import cstdio) 3 | (import clocale) 4 | 5 | (def main 6 | (fn extern-c int (void) 7 | (printf "%c\n" (@ (@:@ (localeconv) decimal-point))) 8 | 0)) 9 | -------------------------------------------------------------------------------- /t/src/long-double.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def strtold 4 | (fn extern-c long-double ((nptr (p (const char))) 5 | (endptr (p (p char)))))) 6 | 7 | (def main 8 | (fn extern-c int (void) 9 | (def c (var auto \ "123.123")) 10 | (def d (var auto \ (strtold c (nullptr (p char))))) 11 | (printf "%Lf\n" d) 12 | 0)) 13 | -------------------------------------------------------------------------------- /t/src/macro-arg-collision.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | (import macros) 3 | 4 | (def mac1 5 | (macro intern (frm1 frm2) 6 | (def blah (var auto (p DNode))) 7 | (setv blah frm1) 8 | (return blah))) 9 | 10 | (def mac2 11 | (macro intern (frm1 frm2) 12 | (def blah (var auto (p DNode))) 13 | (setv blah frm2) 14 | (return blah))) 15 | 16 | (def main 17 | (fn extern-c int (void) 18 | (mac1 1 1) 19 | (mac2 2 2) 20 | (return 0))) 21 | -------------------------------------------------------------------------------- /t/src/macros-basic.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | (import macros) 3 | 4 | (def identity2 5 | (macro intern (form) 6 | (return form))) 7 | 8 | (def main 9 | (fn extern-c int (void) 10 | (identity2 (printf "Should be returned\n")) 11 | (identity2 (printf "%d\n" (+ 1 2))) 12 | (identity2 (return 0)))) 13 | -------------------------------------------------------------------------------- /t/src/macros-qq-2.dt: -------------------------------------------------------------------------------- 1 | (import macros) 2 | (import cstdio) 3 | 4 | (def qq-test-2 5 | (macro intern (frm) 6 | (std.macros.qq + (uq frm) (uq frm)))) 7 | 8 | (def main 9 | (fn extern-c int (void) 10 | (printf "%d\n" (qq-test-2 500)) 11 | 0)) 12 | -------------------------------------------------------------------------------- /t/src/macros-qq-4.dt: -------------------------------------------------------------------------------- 1 | (import macros) 2 | (import cstdio) 3 | 4 | (using-namespace std.macros 5 | (def wrap-body 6 | (macro intern (rest) 7 | (def arg-count (var auto \ (arg-count mc))) 8 | (def varargs-list (var auto \ (get-varargs-list mc arg-count rest))) 9 | (qq do 10 | (printf "Wrap function start\n") 11 | (uql varargs-list) 12 | (printf "Wrap function end\n")))) 13 | ) 14 | (def main 15 | (fn extern-c int (void) 16 | (wrap-body (printf "0\n") (printf "1\n") (printf "2\n") (printf "4\n")) 17 | 0)) 18 | -------------------------------------------------------------------------------- /t/src/macros-qq-simple.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | (import macros) 3 | 4 | (def qq-test 5 | (macro intern (void) 6 | (std.macros.qq + 1 2))) 7 | 8 | (def main 9 | (fn extern-c int (void) 10 | (printf "%d\n" (qq-test)) 11 | 0)) 12 | -------------------------------------------------------------------------------- /t/src/main-with-args.dt: -------------------------------------------------------------------------------- 1 | (def main 2 | (fn extern-c int ((argc int) (argv (p (p char)))) 3 | (return 0))) 4 | -------------------------------------------------------------------------------- /t/src/malloc-simple.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | (import macros) 3 | 4 | (def main (fn extern-c int (void) 5 | (let ((b (p int) (malloc' 10 int)) 6 | (i int)) 7 | (for (setv i 0) (< i 10) (incv i) 8 | (setf ($ b i) i)) 9 | (for (setv i 0) (< i 10) (incv i) 10 | (printf "%d\n" (@ ($ b i)))) 11 | (free' b) 12 | ) 13 | 0)) 14 | -------------------------------------------------------------------------------- /t/src/malloc.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def main 4 | (fn extern-c int (void) 5 | (def intp (var auto (p int))) 6 | 7 | (setv intp (cast (malloc (* (cast 100 size) (sizeof int))) (p int))) 8 | (setf ($ intp 0) 0) 9 | (setf ($ intp 1) 1) 10 | (setf ($ intp 99) 99) 11 | 12 | (printf "%d %d %d\n" 13 | (@ ($ intp 0)) 14 | (@ ($ intp 1)) 15 | (@ ($ intp 99))) 16 | 17 | (printf "%d\n" (@ intp)) 18 | 19 | (return 0))) 20 | -------------------------------------------------------------------------------- /t/src/math-helpers.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | (import stdlib) 3 | 4 | (def main 5 | (fn extern-c int (void) 6 | (let ((a int 8) 7 | (b int16 3) 8 | (c int 0) 9 | (d bool false)) 10 | (mfor Op (+' -' *' /' %') 11 | (setv c (Op a b)) 12 | (printf "%d\n" c)) 13 | (mfor Op (=' !=' <' <=' >' >=') 14 | (setv d (Op a b)) 15 | (printf "%d\n" d))) 16 | 0)) 17 | -------------------------------------------------------------------------------- /t/src/mfor-range.dt: -------------------------------------------------------------------------------- 1 | (import stdlib) 2 | 3 | (def main (fn extern-c int (void) 4 | (mfor' N (range 0 2) 5 | (printf "%d\n" N)) 6 | 0)) 7 | -------------------------------------------------------------------------------- /t/src/mfor-sum.dt: -------------------------------------------------------------------------------- 1 | (import stdlib) 2 | 3 | (def main (fn extern-c int (void) 4 | (def sum (var auto int 0)) 5 | (mfor' i (range 0 4) 6 | (printf "adding %i to sum\n" i) 7 | (setv sum (+ sum i))) 8 | (printf "now sum is %i\n" sum) ;;sum still is 0 9 | 0)) 10 | -------------------------------------------------------------------------------- /t/src/mif.dt: -------------------------------------------------------------------------------- 1 | (import stdlib) 2 | 3 | (mif true (def x (var intern int 1)) 4 | (def x (var intern int 2))) 5 | 6 | (mif false (def y (var intern int 1)) 7 | (def y (var intern int 2))) 8 | 9 | (def main (fn extern-c int (void) 10 | (printf "%d %d\n" x y) 11 | 0)) 12 | -------------------------------------------------------------------------------- /t/src/ml-comment-nested.dt: -------------------------------------------------------------------------------- 1 | #| #| asdf asdf asdf 2 | 3 | #| 4 | qwerqwer qwerqwer 5 | |# 6 | 7 | 8 | |# |# 9 | 10 | (import cstdio) 11 | 12 | (def main 13 | (fn #| #| qwer |# |# extern-c int (void) #| qwer |# 14 | (printf "%d\n" 0) 15 | 0)) 16 | -------------------------------------------------------------------------------- /t/src/ml-comment.dt: -------------------------------------------------------------------------------- 1 | #| asdf asdf asfd 2 | 3 | 4 | qwerqwer qwerqwer 5 | 6 | 7 | |# 8 | 9 | (import cstdio) 10 | 11 | (def main 12 | (fn #| qwer |# extern-c int (void) #| qwer |# 13 | (printf "%d\n" 0) 14 | 0)) 15 | -------------------------------------------------------------------------------- /t/src/modc.dt: -------------------------------------------------------------------------------- 1 | (def modc-val 2 | (var extern int 100)) 3 | -------------------------------------------------------------------------------- /t/src/modp-infile-user.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | (import modp-infile) 3 | 4 | (def main 5 | (fn extern-c int (void) 6 | (printf "%d\n" (modp-fn)) 7 | 0)) 8 | -------------------------------------------------------------------------------- /t/src/modp-infile.dt: -------------------------------------------------------------------------------- 1 | (module modp-infile) 2 | 3 | (def modp-fn 4 | (fn extern int (void) 5 | (* 10 2))) 6 | -------------------------------------------------------------------------------- /t/src/modp-user.dt: -------------------------------------------------------------------------------- 1 | (import modp) 2 | (import modp2) 3 | 4 | (import cstdio) 5 | 6 | (def main 7 | (fn extern-c int (void) 8 | (printf "%d\n" (modp-fn)) 9 | (printf "%d\n" (modp2-fn)) 10 | 0)) 11 | -------------------------------------------------------------------------------- /t/src/modp.dt: -------------------------------------------------------------------------------- 1 | (import modc) 2 | 3 | (def modp-fn 4 | (fn extern int (void) 5 | (* modc-val 2))) 6 | 7 | -------------------------------------------------------------------------------- /t/src/modp2.dt: -------------------------------------------------------------------------------- 1 | (import modc) 2 | 3 | (def modp2-fn 4 | (fn extern int (void) 5 | (* modc-val 2))) 6 | -------------------------------------------------------------------------------- /t/src/modulus.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | (import enum) 3 | 4 | (def-enum thing extern int (a b c d e f g)) 5 | 6 | (def main (fn extern-c int (void) 7 | (let ((a int 12) 8 | (b int 5)) 9 | (printf "%d\n" (% a b))) 10 | (let ((a uint 12) 11 | (b uint 5)) 12 | (printf "%u\n" (% a b))) 13 | (let ((a float 12.0) 14 | (b float 5.0)) 15 | (printf "%f\n" (% a b))) 16 | (let ((a thing g) 17 | (b thing e)) 18 | (printf "%d\n" (% a b))) 19 | 0)) 20 | -------------------------------------------------------------------------------- /t/src/mr-struct.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def first (struct opaque)) 4 | (def second (struct opaque)) 5 | 6 | (def first (struct extern((a int) (n (p second))))) 7 | (def second (struct extern((a char) (n (p first))))) 8 | 9 | (def main 10 | (fn extern-c int (void) 11 | (def f (var auto first)) 12 | (def s (var auto second)) 13 | (setf (: f a) 10) 14 | (setf (: s a) #\a) 15 | (setf (: f n) (# s)) 16 | (setf (: s n) (# f)) 17 | (printf "%d\n" (@ (: (@ (@ (: s n))) a))) 18 | (printf "%c\n" (@ (: (@ (@ (: f n))) a))) 19 | 0)) 20 | -------------------------------------------------------------------------------- /t/src/namespace-macs.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | (import macros) 3 | 4 | (namespace x 5 | (def other-macro 6 | (macro intern (x-mac) 7 | x-mac))) 8 | 9 | (namespace y 10 | (def other-macro 11 | (macro intern (y-mac) 12 | (std.macros.qq printf "not the identity macro\n")))) 13 | 14 | (def main 15 | (fn extern-c int (void) 16 | (x.other-macro (printf "the identity macro\n")) 17 | (y.other-macro (printf "the identity macro\n")) 18 | 0)) 19 | -------------------------------------------------------------------------------- /t/src/namespace-nested.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (namespace a 4 | (def thing (var intern int 0)) 5 | (namespace b 6 | (def thing (var intern int 1)) 7 | (namespace c 8 | (def thing (var intern int 2))) 9 | (def thing2 (var intern int 3))) 10 | (def thing2 (var intern int 4))) 11 | 12 | (def main 13 | (fn extern-c int (void) 14 | (printf "%d %d %d %d %d\n" 15 | a.thing a.b.thing a.b.c.thing a.b.thing2 a.thing2) 16 | 0)) 17 | 18 | -------------------------------------------------------------------------------- /t/src/negative-array-indices.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def main 4 | (fn extern-c int (void) 5 | (def n (var auto (array-of 100 int))) 6 | (def m (var auto (p int) ($ n 10))) 7 | (setf ($ n 9) 200) 8 | (printf "%d\n" (@$ m -1)) 9 | 0)) 10 | -------------------------------------------------------------------------------- /t/src/negative-fp.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def main 4 | (fn extern-c int (void) 5 | (return (cast -0.0 int)))) 6 | -------------------------------------------------------------------------------- /t/src/negative-hex.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def main (fn extern-c int (void) 4 | (printf "%d\n" -0xff) 5 | 0)) 6 | -------------------------------------------------------------------------------- /t/src/nested-ifs-2.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def main 4 | (fn extern-c int (void) 5 | (def i (var auto int 0)) 6 | 7 | (label begin-loop) 8 | (if (= i 10) 9 | (goto end-loop) 10 | (do (printf "i is %d\n" i) 11 | (setf i (+ i 1)) 12 | (goto begin-loop))) 13 | 14 | (label end-loop) 15 | (printf "Finished\n") 16 | (return 0))) 17 | -------------------------------------------------------------------------------- /t/src/nested-ifs.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def main 4 | (fn extern-c int (void) 5 | (def i (var auto int 0)) 6 | 7 | (label begin-loop) 8 | (setv i (if (> i 20) (+ i 3) 9 | (if (> i 10) (+ i 2) 10 | (+ i 1)))) 11 | (printf "%d " i) 12 | (if (> i 40) 13 | (goto end-loop) 14 | (goto begin-loop)) 15 | 16 | (label end-loop) 17 | (printf "Finished\n") 18 | (return 0))) 19 | -------------------------------------------------------------------------------- /t/src/nested-qq.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | (import macros) 3 | 4 | (using-namespace std.macros 5 | 6 | (def make-+ 7 | (macro intern (T) 8 | (qq def + 9 | (macro intern ((a (uq T)) (b (uq T)) (c (uq T))) 10 | (qq + (uq (uq a)) (+ (uq (uq b)) (uq (uq c)))))))) 11 | 12 | (make-+ int) 13 | (make-+ float) 14 | 15 | ) 16 | 17 | (def main 18 | (fn extern-c int (void) 19 | (printf "%d\n" (+ 1 2 3)) 20 | (printf "%f\n" (+ 1.0 2.0 3.0)) 21 | 0)) 22 | -------------------------------------------------------------------------------- /t/src/no-intern-init.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def num (var intern int)) 4 | (def mys (struct extern((a int) (b int)))) 5 | (def myv (var intern mys)) 6 | 7 | (def main 8 | (fn extern-c int (void) 9 | (printf "%d\n" num) 10 | (printf "%d %d\n" (@ (: myv a)) (@ (: myv b))) 11 | 0)) 12 | -------------------------------------------------------------------------------- /t/src/no-op.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (no-op) 4 | 5 | (def main (fn extern-c int (void) 6 | (no-op) 7 | (using-namespace std 8 | (no-op) 9 | (def x (var auto \ 1)) 10 | (no-op)) 11 | (def z (var auto \ x)) 12 | (printf "%d\n" z) 13 | (no-op) 14 | 0)) 15 | -------------------------------------------------------------------------------- /t/src/ns-problem.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | (import macros) 3 | 4 | (namespace blah 5 | (namespace blah 6 | (def blah (struct extern((a int)))))) 7 | 8 | (def main 9 | (fn extern-c int (void) 10 | (let ((m blah.blah.blah)) 11 | (setf (: m a) 10) 12 | (printf "%d\n" (@ (: m a))) 13 | 0))) 14 | 15 | -------------------------------------------------------------------------------- /t/src/ns2.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (namespace a 4 | (namespace b 5 | (namespace c 6 | (def main (fn extern int (void) 0))))) 7 | 8 | (using-namespace a 9 | (def blah (fn extern int (void) 0))) 10 | 11 | (using-namespace a.b 12 | (def blah2 (fn extern int (void) 0))) 13 | 14 | (using-namespace a.b.c 15 | (def blah2 (fn extern int (void) 0))) 16 | 17 | (using-namespace a.b.c 18 | (def blah2 (fn extern int (void) 0))) 19 | 20 | 21 | -------------------------------------------------------------------------------- /t/src/null-macro.dt: -------------------------------------------------------------------------------- 1 | (import macros) 2 | (import cstdio) 3 | 4 | (def testmac 5 | (macro intern (void) 6 | (cast 0 (p DNode)))) 7 | 8 | (def main 9 | (fn extern-c int (void) 10 | (printf "pre null\n") 11 | (testmac) 12 | (printf "post null\n") 13 | 0)) 14 | 15 | -------------------------------------------------------------------------------- /t/src/nullptr.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def main 4 | (fn extern-c int (void) 5 | (def np (var auto \ (nullptr char))) 6 | (def vp (var auto \ "asdfasdfasdf")) 7 | (printf "np is a %s pointer\n" (if (null np) "null" "non-null")) 8 | (printf "vp is a %s pointer\n" (if (null vp) "null" "non-null")) 9 | 0)) 10 | -------------------------------------------------------------------------------- /t/src/offsetof.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def s (struct extern((a char) (b double) (c char) (d int)))) 4 | 5 | (def main 6 | (fn extern-c int (void) 7 | (printf "%d %d %d %d\n" 8 | (offsetof s a) 9 | (offsetof s b) 10 | (offsetof s c) 11 | (offsetof s d)) 12 | 0)) 13 | -------------------------------------------------------------------------------- /t/src/once.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | (include "t/include/cycle1.dth") 3 | 4 | (def main 5 | (fn extern-c int (void) 6 | (printf "hello\n") 7 | (return 0))) 8 | -------------------------------------------------------------------------------- /t/src/one.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def myfn 4 | (fn extern int (void))) 5 | 6 | (def main 7 | (fn extern-c int (void) 8 | (printf "Zero: %d\n" (myfn)) 9 | 0)) 10 | -------------------------------------------------------------------------------- /t/src/opaque-struct-redef-2.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def mys (struct opaque)) 4 | 5 | (def print-a 6 | (fn extern-c int ((a (p mys))))) 7 | 8 | (def myfn 9 | (fn extern-c int ((a (p mys))) 10 | (print-a a) 11 | 0)) 12 | 13 | (def mys (struct extern((a int)))) 14 | 15 | (def print-a 16 | (fn extern-c int ((a (p mys))) 17 | (printf "%d\n" (@ (: (@ a) a))) 18 | 0)) 19 | 20 | (def main 21 | (fn extern-c int (void) 22 | (def n (var auto mys)) 23 | (setf (: n a) 10) 24 | (myfn (# n)) 25 | (printf "done\n") 26 | 0)) 27 | 28 | -------------------------------------------------------------------------------- /t/src/opaque-struct-redef.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def mys (struct opaque)) 4 | (def mys (struct extern((a int)))) 5 | 6 | (def main 7 | (fn extern-c int (void) 8 | (def n (var auto mys)) 9 | (setf (: n a) 10) 10 | (printf "%d\n" (@ (: n a))) 11 | (printf "All good\n") 12 | 0)) 13 | -------------------------------------------------------------------------------- /t/src/opaque-struct.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def mys (struct opaque)) 4 | 5 | (def main 6 | (fn extern-c int (void) 7 | (def n (var auto (p mys))) 8 | (printf "All good\n") 9 | 0)) 10 | -------------------------------------------------------------------------------- /t/src/operator-macro-problems.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | (import macros) 3 | (import operator-macros) 4 | 5 | (def main (fn extern-c int (void) 6 | (def x (var auto (array-of (+ 1 2 3) int) (array 0 1 2 3 4 5))) 7 | (for (i \ 0) (< i 6) (incv i) 8 | (printf "%d\n" (@$ x i))) 9 | (setv x (array-of (+ 1 2 3) int (array 1 2 3 4 5 6))) 10 | (for (i \ 0) (< i 6) (incv i) 11 | (printf "%d\n" (@$ x i))) 12 | (def y (var auto int (+ 1 2 3))) 13 | (printf "%d\n" y) 14 | 0)) 15 | -------------------------------------------------------------------------------- /t/src/operator-macros-transitive.dt: -------------------------------------------------------------------------------- 1 | (import operator-macros) 2 | 3 | (def main (fn extern-c int (void) 4 | (printf "%s\n" (if (< 1 2 3) "ok" "not ok")) 5 | (def x (var auto \ 5.0)) 6 | (printf "%s\n" (if (< 1.0 x 10.0) "ok" "not ok")) 7 | (printf "%s\n" (if (> 10.0 x 5.0) "ok" "not ok")) 8 | (printf "%s\n" (if (= x 5.0 x 5.0 x 5.0) "ok" "not ok")) 9 | 0)) 10 | -------------------------------------------------------------------------------- /t/src/operator-macros.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | (import macros) 3 | 4 | (import operator-macros) 5 | 6 | (def main (fn extern-c int (void) 7 | (printf "%d\n" (+ 10 2 3)) 8 | (printf "%d\n" (- 10 2 3)) 9 | 0)) 10 | -------------------------------------------------------------------------------- /t/src/other.dt: -------------------------------------------------------------------------------- 1 | (def other-var (var extern int 100)) 2 | -------------------------------------------------------------------------------- /t/src/over-fp-address.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def fn 4 | (fn extern int ((# int)) 5 | 1)) 6 | 7 | (def fn 8 | (fn extern int ((# int) (b int)) 9 | 2)) 10 | 11 | (def main 12 | (fn extern-c int (void) 13 | (def fp (var auto (p (fn int ((# int)))) 14 | (# fn int))) 15 | (def fp2 (var auto (p (fn int ((# int) (b int)))) 16 | (# fn int int))) 17 | (printf "%d\n" (funcall fp 10)) 18 | (printf "%d\n" (funcall fp2 10 20)) 19 | 0)) 20 | -------------------------------------------------------------------------------- /t/src/over-fp.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def myfn 4 | (fn extern int ((fp (p (fn int ((a int) (b int)))))) 5 | (funcall fp 1 2))) 6 | 7 | (def myfn 8 | (fn extern int ((fp (p (fn int ((a int) (b int) (c int)))))) 9 | (funcall fp 1 2 3))) 10 | 11 | (def fp2 12 | (fn extern-c int ((a int) (b int)) 13 | (+ a b))) 14 | 15 | (def fp3 16 | (fn extern-c int ((a int) (b int) (c int)) 17 | (+ a (+ b c)))) 18 | 19 | (def main 20 | (fn extern-c int (void) 21 | (printf "%d %d\n" (myfn (# fp2)) (myfn (# fp3))) 22 | 0)) 23 | -------------------------------------------------------------------------------- /t/src/over-ns.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (namespace test1 4 | (def myfn (fn extern int (void) 100)) 5 | (def myfn (fn extern int ((# int)) 200))) 6 | 7 | (namespace test2 8 | (def myfn (fn extern int (void) 300)) 9 | (def myfn (fn extern int ((# int)) 400))) 10 | 11 | (using-namespace test1 12 | (using-namespace test2 13 | (def main 14 | (fn extern-c int (void) 15 | (printf "%d %d\n" (myfn) (myfn 1)) 16 | (printf "%d %d\n" (test1.myfn) (test2.myfn)) 17 | (printf "%d %d\n" (test1.myfn 1) (test2.myfn 1)) 18 | 0)))) 19 | -------------------------------------------------------------------------------- /t/src/pair.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | (import macros) 3 | (import utility) 4 | (import concepts) 5 | 6 | (std.concepts.instantiate Pair int char) 7 | 8 | (def main 9 | (fn extern-c int (void) 10 | (def thing (var auto (Pair int char))) 11 | (setf (: thing first) 10) 12 | (setf (: thing second) #\a) 13 | (printf "%d %c\n" (@ (: thing first)) (@ (: thing second))) 14 | 0)) 15 | -------------------------------------------------------------------------------- /t/src/pointers.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def main 4 | (fn extern-c int (void) 5 | (def var1 (var auto (p int))) 6 | (def var2 (var auto int 0)) 7 | (setv var2 200) 8 | (setv var1 (# var2)) 9 | (printf "Var 1 is %d, Var 2 is %d\n" (@ var1) var2) 10 | (return 0))) 11 | -------------------------------------------------------------------------------- /t/src/preserve-imported3.dt: -------------------------------------------------------------------------------- 1 | (import dtm-preserve-imported2) 2 | 3 | (def main (fn extern-c int (void) 4 | (mfn2) 5 | 0)) 6 | -------------------------------------------------------------------------------- /t/src/printf.dt: -------------------------------------------------------------------------------- 1 | (def printf 2 | (fn extern-c int ((str (p char)) ...))) 3 | -------------------------------------------------------------------------------- /t/src/proc-include-test.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def main (fn extern-c int (void) 4 | (printf (include "t/src/proc-include.dt")) 5 | 0)) 6 | -------------------------------------------------------------------------------- /t/src/proc-include.dt: -------------------------------------------------------------------------------- 1 | (do "test") 2 | -------------------------------------------------------------------------------- /t/src/quote.dt: -------------------------------------------------------------------------------- 1 | (import macros) 2 | (import cstdio) 3 | (import introspection) 4 | 5 | (using-namespace std.macros 6 | (def def-type-macro (macro extern (new linkage old) 7 | (qq using-namespace std.macros 8 | (def (uq new) (macro (uq linkage) (void) 9 | (q (uq old)))))))) 10 | 11 | (def-type-macro cstring extern (p (const char))) 12 | 13 | (def main (fn extern-c int (void) 14 | (def a-string (var auto (cstring) "Yo dude")) 15 | (printf "string: %s\n" a-string) 16 | 0)) 17 | -------------------------------------------------------------------------------- /t/src/refs-basic.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def increment (fn extern int ((a (ref int))) 4 | (setf a (+ (@ a) 1)) 5 | (@ a))) 6 | 7 | (def main (fn extern-c int (void) 8 | (def x (var auto int 0)) 9 | (printf "%d\n" x) 10 | (increment x) 11 | (printf "%d\n" x) 12 | (increment x) 13 | (printf "%d\n" x) 14 | 0)) 15 | -------------------------------------------------------------------------------- /t/src/refs-const.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def plus (fn extern int ((a (ref (const int))) (b (ref (const int)))) 4 | (+ (@ a) (@ b)))) 5 | 6 | (def main (fn extern-c int (void) 7 | (def x (var auto int 0)) 8 | (printf "%d\n" (plus x 100)) 9 | (printf "%d\n" (plus 200 300)) 10 | (printf "%d\n" (plus x x)) 11 | 0)) 12 | -------------------------------------------------------------------------------- /t/src/refs-fnptr-exp.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def myfn (fn intern int ((a (ref (const int))) (b (ref (const int)))) 4 | (+ (@ a) (@ b)))) 5 | 6 | (def main 7 | (fn extern-c int (void) 8 | (def fp (var auto (p (fn int ((a (ref (const int))) (b (ref (const int)))))) 9 | (# myfn int int))) 10 | (printf "%d\n" (fp 50 50)) 11 | 0)) 12 | -------------------------------------------------------------------------------- /t/src/refs-fnptr.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def myfn (fn intern int ((a (ref (const int))) (b (ref (const int)))) 4 | (+ (@ a) (@ b)))) 5 | 6 | (def main 7 | (fn extern-c int (void) 8 | (def fp (var auto \ (# myfn int int))) 9 | (printf "%d\n" (fp 50 50)) 10 | 0)) 11 | -------------------------------------------------------------------------------- /t/src/refs-pass.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def mys (struct intern ((a int) (b int)))) 4 | 5 | (def ref-fn2 (fn intern int ((n (ref mys))) 6 | (setf (:@ n a) (+ 3 (@:@ n a))) 7 | (setf (:@ n b) (+ 4 (@:@ n b))) 8 | 0)) 9 | 10 | (def ref-fn1 (fn intern int ((n (ref mys))) 11 | (setf (:@ n a) (+ 1 (@:@ n a))) 12 | (setf (:@ n b) (+ 2 (@:@ n b))) 13 | (ref-fn2 (@ n)))) 14 | 15 | (def main (fn extern-c int ((argc int) (argv (p (p char)))) 16 | (let ((m mys ((a 1) (b 2)))) 17 | (ref-fn1 m) 18 | (printf "%d %d\n" (@: m a) (@: m b)) 19 | 0))) 20 | -------------------------------------------------------------------------------- /t/src/report-error.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | (import macros) 3 | (import assert) 4 | 5 | (def istype 6 | (macro intern (f) 7 | (if (not (exists-type mc f)) 8 | (do (report-error mc f "this node is not a type") 9 | (std.macros.qq + 0 0)) 10 | (std.macros.qq + 0 1)))) 11 | 12 | (def main 13 | (fn extern-c int (void) 14 | (printf "Int is type: %d\n" (istype int)) 15 | (printf "Blah is type: %d\n" (istype blah)) 16 | 0)) 17 | -------------------------------------------------------------------------------- /t/src/ret-problem.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def mycfun 4 | (fn extern-c void (void) 5 | (printf "1 ") 6 | (return) 7 | (return) 8 | (return) 9 | (return) 10 | (return))) 11 | 12 | (def myfun 13 | (fn extern void (void) 14 | (mycfun) 15 | (mycfun))) 16 | 17 | (def main 18 | (fn extern-c int (void) 19 | (myfun) 20 | (myfun) 21 | (myfun) 22 | (printf "\n") 23 | 0)) 24 | -------------------------------------------------------------------------------- /t/src/root-ns.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | (import stdlib) 3 | 4 | (namespace test 5 | (def + (fn intern int ((a int) (b int)) 6 | (printf "calling +\n") 7 | (def x (var auto \ (.+ a b))) 8 | (printf "called +\n") 9 | (return x)))) 10 | 11 | (def main (fn extern-c int (void) 12 | (printf "%d\n" (+ 1 2)) 13 | (using-namespace test 14 | (printf "%d\n" (+ 1 2))) 15 | 0)) 16 | -------------------------------------------------------------------------------- /t/src/rv-refs-simple.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def ref-fn (fn extern int ((a (ref int))) 4 | 1)) 5 | 6 | (def ref-fn (fn extern int ((a (rv-ref int))) 7 | 2)) 8 | 9 | (def main (fn extern-c int (void) 10 | (def n (var auto int 0)) 11 | (printf "%d\n" (ref-fn n)) 12 | (printf "%d\n" (ref-fn 0)) 13 | 0)) 14 | -------------------------------------------------------------------------------- /t/src/rv-refs-use-simple.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def ref-fn (fn extern int ((a (ref int))) 4 | (printf "%d\n" (@ a)) 5 | 0)) 6 | 7 | (def ref-fn (fn extern int ((a (rv-ref int))) 8 | (printf "%d\n" (@ a)) 9 | 0)) 10 | 11 | (def main (fn extern-c int (void) 12 | (def n (var auto int 1)) 13 | (ref-fn n) 14 | (ref-fn 2) 15 | 0)) 16 | -------------------------------------------------------------------------------- /t/src/set-const-struct-member.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | (import cstring) 3 | (import stdlib) 4 | 5 | (def mys (struct intern ((a int) (b (p (const char)))))) 6 | 7 | (def main (fn extern-c int (void) 8 | (let ((ms mys) 9 | (str \ (malloc' 100 char))) 10 | (setf ($ str 0) #\NULL) 11 | (strcat str "asdf") 12 | (setf (: ms b) str) 13 | (printf "%s\n" (@: ms b)) 14 | 0))) 15 | -------------------------------------------------------------------------------- /t/src/setf-stack-vars.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def main 4 | (fn extern-c int (void) 5 | (def var1 (var auto int 0)) 6 | (printf "Var 1 is %d\n" var1) 7 | (def var2 (var auto int 500)) 8 | (printf "Var 2 is %d\n" var2) 9 | (setv var1 100) 10 | (setv var2 200) 11 | (printf "Var 1 is %d, Var 2 is %d\n" var1 var2) 12 | (return 0))) 13 | -------------------------------------------------------------------------------- /t/src/setjmp.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | (import csetjmp) 3 | (import cstdlib) 4 | 5 | (using-namespace std 6 | 7 | (def main 8 | (fn extern-c int (void) 9 | (let ((mine jmpbuf)) 10 | (if (= 0 (setjmp (# mine))) 11 | (do (printf "setjmp\n") 0) 12 | (do (printf "longjmp\n") 13 | (exit 0))) 14 | (longjmp (# mine) 1)))) 15 | 16 | ) 17 | -------------------------------------------------------------------------------- /t/src/signal.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | (import csignal) 3 | 4 | (using-namespace std 5 | 6 | (def main 7 | (fn extern-c int (void) 8 | (signal (SIGINT) 9 | (fn (p void) ((n int)) 10 | (printf "Caught sigint\n") 11 | (return (nullptr void)))) 12 | (raise (SIGINT)) 13 | (printf "Raised sigint\n") 14 | (raise (SIGINT)) 15 | (printf "Raised sigint\n") 16 | 0)) 17 | 18 | ) 19 | -------------------------------------------------------------------------------- /t/src/sizeof-array-problem.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def main 4 | (fn extern-c int (void) 5 | (def myarray (var auto (array-of 100 char))) 6 | (printf "%d\n" (sizeof myarray)) 7 | 0)) 8 | -------------------------------------------------------------------------------- /t/src/sizeof-array.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def main 4 | (fn extern-c int (void) 5 | (def ptr (var auto int)) 6 | (def arr (var auto (array-of 10 int))) 7 | (def arr2 (var auto (array-of 10 (p int)))) 8 | (def parr (var auto (p (array-of 10 int)))) 9 | (def big (var auto (array-of 10 (array-of 10 int)))) 10 | 11 | (printf "%d %d\n" (sizeof ptr) 12 | (sizeof arr)) 13 | 14 | 0)) 15 | -------------------------------------------------------------------------------- /t/src/sizeof-problem.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def main 4 | (fn extern-c int (void) 5 | (printf "Size of 1 + 1 is: %d\n" 6 | (sizeof (+ 1 1))) 7 | 0)) 8 | -------------------------------------------------------------------------------- /t/src/sp-make.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | (import macros) 3 | (import shared-ptr) 4 | 5 | (std.concepts.instantiate SharedPtr int) 6 | 7 | (def main 8 | (fn extern-c int (void) 9 | (let ((myptr (SharedPtr int)) 10 | (myint \ (malloc' 1 int))) 11 | (setf myint 100) 12 | (init myptr myint) 13 | (printf "%d\n" (@ myptr)) 14 | 0))) 15 | -------------------------------------------------------------------------------- /t/src/sp-set-value.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | (import macros) 3 | (import shared-ptr) 4 | 5 | (make-SharedPtr int) 6 | 7 | (using-namespace std 8 | 9 | (def main 10 | (fn extern-c int (void) 11 | (let ((myint \ (malloc' 1 int)) 12 | (myptr (SharedPtr int) (init (# myptr) myint))) 13 | (setv myptr 100) 14 | (printf "%d\n" (@ myptr)) 15 | 0))) 16 | 17 | ) 18 | -------------------------------------------------------------------------------- /t/src/sref-on-fn.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def thing (struct extern((a int) (b int)))) 4 | 5 | (def myfn 6 | (fn extern thing ((a int)) 7 | (return (thing ((a 10)))))) 8 | 9 | (def main 10 | (fn extern-c int (void) 11 | (printf "%d\n" (@ (: (myfn 1) a))) 12 | 0)) 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /t/src/stack-vars.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def main 4 | (fn extern-c int (void) 5 | (def var1 (var auto int 0)) 6 | (printf "Var 1 is %d\n" var1) 7 | (def var2 (var auto int 500)) 8 | (printf "Var 2 is %d\n" var2) 9 | (return 0))) 10 | -------------------------------------------------------------------------------- /t/src/string-chars.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | (def main (fn extern-c int (void) 3 | (printf "asdf\tasdf\\\n") 4 | (printf "\\") 5 | 0)) 6 | -------------------------------------------------------------------------------- /t/src/struct-casting.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def mys 4 | (struct extern((a int64) (b int64)))) 5 | 6 | (def main 7 | (fn extern-c int (void) 8 | (def n (var auto mys ((a 10) (b 20)))) 9 | (printf "%lld %lld\n" (@ (: n a)) (@ (: n b))) 10 | 0)) 11 | -------------------------------------------------------------------------------- /t/src/struct-deref.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def mys (struct extern((a int) (b int)))) 4 | 5 | (def main 6 | (fn extern-c int (void) 7 | (def n (var auto mys ((a 10) (b 20)))) 8 | (printf "%d\n" (@: n a)) 9 | (printf "%d\n" (@: n b)) 10 | 0)) 11 | -------------------------------------------------------------------------------- /t/src/struct-init.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def Point (struct extern((x int) (y int)))) 4 | 5 | (def main 6 | (fn extern-c int (void) 7 | (def p1 (var auto Point ((x 1) (y 2)))) 8 | (printf "%d %d\n" (@ (: p1 x)) (@ (: p1 y))) 9 | 0)) 10 | -------------------------------------------------------------------------------- /t/src/struct-literal-array.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def X (struct intern ((value (array-of 2 int))))) 4 | 5 | (def main (fn extern-c int (void) 6 | (def a (var auto (array-of 2 int) (array 1 1))) 7 | (setv a (array 0 0)) 8 | (def x (var auto X ((value (array 1 2))))) 9 | (printf "%d %d\n" (@$ (@: x value) 0) (@$ (@: x value) 1)) 10 | 0)) 11 | -------------------------------------------------------------------------------- /t/src/struct.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def my-struct (struct extern((a int) (b int) (c (p (const char))) (d int)))) 4 | 5 | (def main 6 | (fn extern-c int (void) 7 | 8 | (def thing (var auto my-struct)) 9 | 10 | (setf (: thing a) 10) 11 | (setf (: thing b) 10) 12 | (setf (: thing c) "qwer") 13 | (setf (: thing d) 20) 14 | 15 | (printf "%d %d %s %d\n" 16 | (@ (: thing a)) 17 | (@ (: thing b)) 18 | (@ (: thing c)) 19 | (@ (: thing d))) 20 | 21 | (return 0))) 22 | -------------------------------------------------------------------------------- /t/src/tl-do.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (do 4 | (def main 5 | (fn extern-c int (void) 6 | (printf "hello\n") 7 | 0))) 8 | -------------------------------------------------------------------------------- /t/src/tl-macro.dt: -------------------------------------------------------------------------------- 1 | (import macros) 2 | (import cstdio) 3 | 4 | (using-namespace std.macros 5 | (def def-main-fn 6 | (macro intern (rest) 7 | (def arg-count (var auto \ (arg-count mc))) 8 | (def varargs-list (var auto \ (get-varargs-list mc arg-count rest))) 9 | (qq def main (fn extern-c int (void) (uql varargs-list) 0)))) 10 | ) 11 | (def-main-fn (printf "Hello world part 2\n")) 12 | -------------------------------------------------------------------------------- /t/src/triple.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | (import macros) 3 | (import utility) 4 | (import concepts) 5 | 6 | (std.concepts.instantiate Triple int char int) 7 | 8 | (def main 9 | (fn extern-c int (void) 10 | (def thing (var auto (Triple int char int))) 11 | (setf (: thing first) 10) 12 | (setf (: thing second) #\a) 13 | (setf (: thing third) 20) 14 | (printf "%d %c %d\n" (@ (: thing first)) 15 | (@ (: thing second)) 16 | (@ (: thing third))) 17 | 0)) 18 | 19 | -------------------------------------------------------------------------------- /t/src/two.dt: -------------------------------------------------------------------------------- 1 | (def myfn (fn extern int (void) 0)) 2 | -------------------------------------------------------------------------------- /t/src/unary-minus.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def main (fn extern-c int (void) 4 | (let ((a int 10) 5 | (b int16 10) 6 | (c uint 10) 7 | (d float 10.0)) 8 | (printf "%d\n" (- a)) 9 | (printf "%d\n" (- b)) 10 | (printf "%d\n" (- c)) 11 | (printf "%f\n" (- d)) 12 | 0))) 13 | -------------------------------------------------------------------------------- /t/src/unquote-arbitrary.dt: -------------------------------------------------------------------------------- 1 | (import macros) 2 | (import stdlib) 3 | (import unistd) 4 | 5 | (def + (fn intern int ((a int) (b int) (c int) (d int)) 6 | (+ a (+ b (+ c d))))) 7 | 8 | (using-namespace std.macros 9 | (def test (macro intern (void) 10 | (qq identity (uq (mnfv mc 1))))) 11 | (def test2 (macro intern (a b c d) 12 | (qq + (uql (link-nodes 4 a b c d)))))) 13 | 14 | (def main (fn extern-c void (void) 15 | (printf "%i\n" (test)) 16 | (printf "%d\n" (test2 1 2 3 4)) 17 | 0)) 18 | -------------------------------------------------------------------------------- /t/src/unquote-first-null-nodes.dt: -------------------------------------------------------------------------------- 1 | (import macros) 2 | 3 | (def mym (macro intern (void) 4 | (def x (var auto \ (std.macros.make-node mc))) 5 | (std.macros.qq (uq x) printf "%s %s\n" 6 | (uq x) (uq-nc x) ((uq x) do "asdf" (uql x)) (uql x) "qwer" (uql-nc x)))) 7 | 8 | (def main (fn extern-c int (void) 9 | (mym) 10 | 0)) 11 | -------------------------------------------------------------------------------- /t/src/unquote-list-null-nodes.dt: -------------------------------------------------------------------------------- 1 | (import macros) 2 | 3 | (def mym (macro intern (void) 4 | (def x (var auto \ (std.macros.make-node mc))) 5 | (std.macros.qq (uq x) printf "%s %s\n" 6 | (uq x) (uq-nc x) ((uq x) do "asdf" (uql x)) (uql x) "qwer" (uql-nc x)))) 7 | 8 | (def main (fn extern-c int (void) 9 | (mym) 10 | 0)) 11 | -------------------------------------------------------------------------------- /t/src/unquote-null-nodes.dt: -------------------------------------------------------------------------------- 1 | (import macros) 2 | 3 | (def mym (macro intern (void) 4 | (def x (var auto \ (std.macros.make-node mc))) 5 | (std.macros.qq printf "%s %s\n" 6 | (uq x) (uq-nc x) "asdf" (uql x) "qwer" (uql-nc x)))) 7 | 8 | (def main (fn extern-c int (void) 9 | (mym) 10 | 0)) 11 | -------------------------------------------------------------------------------- /t/src/up-make.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | (import macros) 3 | (import unique-ptr) 4 | 5 | (std.concepts.instantiate UniquePtr int) 6 | 7 | (def main (fn extern-c int (void) 8 | (let ((myptr (UniquePtr int)) 9 | (myint \ (malloc' 1 int))) 10 | (setf myint 100) 11 | (init myptr myint) 12 | (printf "%d\n" (@ myptr)) 13 | 0))) 14 | -------------------------------------------------------------------------------- /t/src/used-ns-problem.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (namespace a 4 | (def x (var intern int 10))) 5 | 6 | (def main (fn extern-c int (void) 7 | (using-namespace a 8 | (def y (var intern int x))) 9 | (printf "%d\n" y) 10 | 0)) 11 | -------------------------------------------------------------------------------- /t/src/using-namespace.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def myfn 4 | (fn extern int ((a int)) 5 | (* 2 a))) 6 | 7 | (namespace x 8 | (def myfn 9 | (fn extern int ((a int)) 10 | (* 3 a)))) 11 | 12 | (def main 13 | (fn extern-c int (void) 14 | (printf "%d\n" (myfn 1)) 15 | (using-namespace x 16 | (printf "%d\n" (myfn 1))) 17 | (printf "%d\n" (myfn 1)) 18 | 0)) 19 | -------------------------------------------------------------------------------- /t/src/variant-basic.dt: -------------------------------------------------------------------------------- 1 | (import variant) 2 | (import cstdio) 3 | 4 | (using-namespace std.macros 5 | 6 | (def-variant Single (Instance)) 7 | 8 | (def main (fn extern-c int (void) 9 | (let ((myinstance Single (Instance))) 10 | (case myinstance 11 | (Instance (printf "Instance is single instance\n")) 12 | (true (printf "Something has gone wrong\n")))) 13 | 0)) 14 | 15 | ) 16 | -------------------------------------------------------------------------------- /t/src/variant-multiple.dt: -------------------------------------------------------------------------------- 1 | (import variant) 2 | (import cstdio) 3 | 4 | (using-namespace std.macros 5 | 6 | (def-variant Direction (Left Right)) 7 | 8 | (def main (fn extern-c int (void) 9 | (let ((left Direction (Left)) 10 | (right Direction (Right))) 11 | (case left 12 | (Left (printf "Left (expected)\n")) 13 | (Right (printf "Right (unexpected)\n"))) 14 | (case right 15 | (Left (printf "Left (unexpected)\n")) 16 | (Right (printf "Right (expected)\n")))) 17 | 0)) 18 | 19 | ) 20 | -------------------------------------------------------------------------------- /t/src/variant-sizes.dt: -------------------------------------------------------------------------------- 1 | (import variant) 2 | (import cstdio) 3 | 4 | (using-namespace std.macros 5 | 6 | (def-variant Direction ((Left ((s float)) ((rest (p (const char))))) 7 | (Right ((s int))))) 8 | 9 | (def main (fn extern-c int (void) 10 | (let ((lsize \ (sizeof Left)) 11 | (rsize \ (sizeof Right)) 12 | (dsize \ (sizeof Direction))) 13 | (printf "%s\n" (if (>= dsize lsize) "ok" "not ok")) 14 | (printf "%s\n" (if (>= dsize rsize) "ok" "not ok"))) 15 | 0)) 16 | 17 | ) 18 | -------------------------------------------------------------------------------- /t/src/vector-in-ns.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | (import macros) 3 | (import vector) 4 | 5 | (namespace mine 6 | (std.concepts.instantiate Vector int) 7 | ) 8 | 9 | (using-namespace mine 10 | (def main 11 | (fn extern-c int (void) 12 | (let ((vec (Vector int) (init vec 100)) 13 | (myiter (Iterator (Vector int)))) 14 | (push-back vec 200) 15 | (setv myiter (begin vec)) 16 | (printf "%d\n" (@ (source myiter))) 17 | 0) 18 | 0)) 19 | ) 20 | -------------------------------------------------------------------------------- /t/src/void-fnptr.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def fn (fn extern void ((n int)) (printf "%d\n" n) (return))) 4 | 5 | (def main 6 | (fn extern-c int (void) 7 | (def mfn (var auto (p (fn void ((n int)))))) 8 | (setv mfn (# fn int)) 9 | (funcall mfn 1) 10 | 11 | 0)) 12 | -------------------------------------------------------------------------------- /t/src/void-if-nested.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def main (fn extern-c int (void) 4 | (if true (if true (printf "done\n") false) 5 | (if true (printf "not done\n") false)) 6 | 0)) 7 | -------------------------------------------------------------------------------- /t/src/void-if.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def myfn (fn intern void (void) 4 | (printf "called myfn\n") 5 | (return))) 6 | 7 | (def main (fn extern-c int (void) 8 | (if true (myfn) (myfn)) 9 | 0)) 10 | -------------------------------------------------------------------------------- /t/src/void-ptr-arithmetic.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | (import macros) 3 | 4 | (def main (fn extern-c int (void) 5 | (let ((n \ 100) 6 | (pn \ (cast (# n) (p void)))) 7 | (printf "Pre-add\n") 8 | (setv pn (p+ pn 1)) 9 | (printf "Pre-subtract\n") 10 | (setv pn (p- pn 1)) 11 | (printf "Finished\n") 12 | 0))) 13 | -------------------------------------------------------------------------------- /t/src/void-return.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | 3 | (def void-fn (fn intern void (void) 4 | (printf "void return\n"))) 5 | 6 | (def main (fn extern-c int (void) 7 | (void-fn) 8 | 0)) 9 | -------------------------------------------------------------------------------- /t/src/zero-len-arrays.dt: -------------------------------------------------------------------------------- 1 | (import cstdio) 2 | (import macros) 3 | 4 | (def main 5 | (fn extern-c int (void) 6 | (def x (var auto (array-of 0 int) (array 1 2 3 4 5))) 7 | (let ((i \ 0)) 8 | (for true (< i 5) (incv i) 9 | (printf "%d\n" (@$ x i)))) 10 | )) 11 | --------------------------------------------------------------------------------