├── .gitattributes ├── .gitignore ├── LICENSE ├── README.md ├── compile.bat ├── design ├── cpp-classdiagram.zargo ├── swift-architecture.pptx ├── swift-ir-classdiagram.svg └── swift-ir-classdiagram.zargo ├── example ├── ar1.blog ├── birthday.blog ├── burglary-multihouse.blog ├── burglary.blog ├── csi.blog ├── exponential.blog ├── galaxy.blog ├── grades.blog ├── healthiness.blog ├── hmm.blog ├── hurricane-new-query-single.blog ├── hurricane-new.blog ├── hurricane.blog ├── poisson-ball-biased.blog ├── poisson-ball.blog ├── simple-aircraft.blog ├── sybil-attack-large.blog ├── sybil-attack-original.blog ├── test │ ├── test-diaggaussian.blog │ ├── test-distrib-placement.blog │ ├── test-extern.blog │ ├── test-invwishart.blog │ ├── test-matrix.blog │ ├── test-obs-forloop-pf.blog │ ├── test-obs-forloop.blog │ ├── test-precisiongaussian.blog │ └── test-query-forloop.blog └── tugwar.blog ├── git-sync.sh ├── lib ├── byacc-20130925 │ ├── ACKNOWLEDGEMENTS │ ├── AUTHORS │ ├── CHANGES │ ├── Makefile.old │ ├── NEW_FEATURES │ ├── NOTES │ ├── NO_WARRANTY │ ├── README │ ├── VERSION │ ├── aclocal.m4 │ ├── closure.c │ ├── config.guess │ ├── config.sub │ ├── config_h.in │ ├── configure │ ├── configure.in │ ├── defs.h │ ├── descrip.mms │ ├── error.c │ ├── graph.c │ ├── install-sh │ ├── lalr.c │ ├── lr0.c │ ├── main.c │ ├── makefile.in │ ├── mkpar.c │ ├── output.c │ ├── package │ │ ├── byacc.spec │ │ ├── debian │ │ │ ├── changelog │ │ │ ├── compat │ │ │ ├── control │ │ │ ├── copyright │ │ │ ├── docs │ │ │ ├── postinst │ │ │ ├── prerm │ │ │ ├── rules │ │ │ ├── source │ │ │ │ └── format │ │ │ └── watch │ │ ├── mingw-byacc.spec │ │ └── pkgsrc │ │ │ ├── DESCR │ │ │ ├── Makefile │ │ │ ├── PLIST │ │ │ └── distinfo │ ├── reader.c │ ├── skeleton.c │ ├── symtab.c │ ├── test │ │ ├── README │ │ ├── calc.output │ │ ├── calc.tab.c │ │ ├── calc.tab.h │ │ ├── calc.y │ │ ├── calc1.output │ │ ├── calc1.tab.c │ │ ├── calc1.tab.h │ │ ├── calc1.y │ │ ├── calc2.output │ │ ├── calc2.tab.c │ │ ├── calc2.tab.h │ │ ├── calc2.y │ │ ├── calc3.output │ │ ├── calc3.tab.c │ │ ├── calc3.tab.h │ │ ├── calc3.y │ │ ├── code_calc.code.c │ │ ├── code_calc.output │ │ ├── code_calc.tab.c │ │ ├── code_calc.tab.h │ │ ├── code_calc.y │ │ ├── code_error.code.c │ │ ├── code_error.output │ │ ├── code_error.tab.c │ │ ├── code_error.tab.h │ │ ├── code_error.y │ │ ├── error.output │ │ ├── error.tab.c │ │ ├── error.tab.h │ │ ├── error.y │ │ ├── ftp.output │ │ ├── ftp.tab.c │ │ ├── ftp.tab.h │ │ ├── ftp.y │ │ ├── grammar.output │ │ ├── grammar.tab.c │ │ ├── grammar.tab.h │ │ ├── grammar.y │ │ ├── pure_calc.output │ │ ├── pure_calc.tab.c │ │ ├── pure_calc.tab.h │ │ ├── pure_calc.y │ │ ├── pure_error.output │ │ ├── pure_error.tab.c │ │ ├── pure_error.tab.h │ │ ├── pure_error.y │ │ ├── quote_calc-s.output │ │ ├── quote_calc-s.tab.c │ │ ├── quote_calc-s.tab.h │ │ ├── quote_calc.output │ │ ├── quote_calc.tab.c │ │ ├── quote_calc.tab.h │ │ ├── quote_calc.y │ │ ├── quote_calc2-s.output │ │ ├── quote_calc2-s.tab.c │ │ ├── quote_calc2-s.tab.h │ │ ├── quote_calc2.output │ │ ├── quote_calc2.tab.c │ │ ├── quote_calc2.tab.h │ │ ├── quote_calc2.y │ │ ├── quote_calc3-s.output │ │ ├── quote_calc3-s.tab.c │ │ ├── quote_calc3-s.tab.h │ │ ├── quote_calc3.output │ │ ├── quote_calc3.tab.c │ │ ├── quote_calc3.tab.h │ │ ├── quote_calc3.y │ │ ├── quote_calc4-s.output │ │ ├── quote_calc4-s.tab.c │ │ ├── quote_calc4-s.tab.h │ │ ├── quote_calc4.output │ │ ├── quote_calc4.tab.c │ │ ├── quote_calc4.tab.h │ │ ├── quote_calc4.y │ │ ├── run_lint.sh │ │ ├── run_make.sh │ │ └── run_test.sh │ ├── verbose.c │ ├── vmsbuild.com │ ├── warshall.c │ └── yacc.1 └── flex-2.5.37 │ ├── .indent.pro │ ├── ABOUT-NLS │ ├── AUTHORS │ ├── COPYING │ ├── ChangeLog │ ├── FlexLexer.h │ ├── INSTALL │ ├── Makefile.am │ ├── Makefile.in │ ├── NEWS │ ├── ONEWS │ ├── README │ ├── README-alpha │ ├── README.cvs │ ├── THANKS │ ├── TODO │ ├── aclocal.m4 │ ├── autogen.sh │ ├── buf.c │ ├── ccl.c │ ├── compile │ ├── conf.in │ ├── config.guess │ ├── config.rpath │ ├── config.sub │ ├── configure │ ├── configure.in │ ├── depcomp │ ├── dfa.c │ ├── doc │ ├── Makefile.am │ ├── Makefile.in │ ├── flex.1 │ ├── flex.info │ ├── flex.info-1 │ ├── flex.info-2 │ ├── flex.pdf │ ├── flex.texi │ ├── mdate-sh │ ├── stamp-vti │ ├── texinfo.tex │ └── version.texi │ ├── ecs.c │ ├── examples │ ├── Makefile.am │ ├── Makefile.in │ ├── README │ ├── debflex.awk │ ├── fastwc │ │ ├── Makefile.am │ │ ├── Makefile.in │ │ ├── README │ │ ├── mywc.c │ │ ├── wc1.l │ │ ├── wc2.l │ │ ├── wc3.l │ │ ├── wc4.l │ │ └── wc5.l │ ├── manual │ │ ├── ChangeLog │ │ ├── Makefile.am │ │ ├── Makefile.examples │ │ ├── Makefile.in │ │ ├── README │ │ ├── cat.lex │ │ ├── dates.lex │ │ ├── datetest.dat │ │ ├── eof_rules.lex │ │ ├── eof_test01.txt │ │ ├── eof_test02.txt │ │ ├── eof_test03.txt │ │ ├── expr.lex │ │ ├── expr.y │ │ ├── front.lex │ │ ├── front.y │ │ ├── j2t.lex │ │ ├── myname.lex │ │ ├── myname.txt │ │ ├── myname2.lex │ │ ├── numbers.lex │ │ ├── pas_include.lex │ │ ├── pascal.lex │ │ ├── reject.lex │ │ ├── replace.lex │ │ ├── string1.lex │ │ ├── string2.lex │ │ ├── strtest.dat │ │ ├── unput.lex │ │ ├── user_act.lex │ │ ├── userinit.lex │ │ ├── wc.lex │ │ ├── yymore.lex │ │ ├── yymore2.lex │ │ └── yymoretest.dat │ └── testxxLexer.l │ ├── filter.c │ ├── flex.skl │ ├── flexdef.h │ ├── flexint.h │ ├── gen.c │ ├── gettext.h │ ├── install-sh │ ├── lib │ ├── Makefile.am │ ├── Makefile.in │ ├── lib.c │ ├── malloc.c │ └── realloc.c │ ├── libmain.c │ ├── libyywrap.c │ ├── m4 │ ├── gettext.m4 │ ├── iconv.m4 │ ├── lib-ld.m4 │ ├── lib-link.m4 │ ├── lib-prefix.m4 │ ├── nls.m4 │ ├── po.m4 │ └── progtest.m4 │ ├── main.c │ ├── misc.c │ ├── missing │ ├── mkinstalldirs │ ├── mkskel.sh │ ├── nfa.c │ ├── options.c │ ├── options.h │ ├── parse.c │ ├── parse.h │ ├── parse.y │ ├── po │ ├── LINGUAS │ ├── Makefile.in.in │ ├── Makevars │ ├── POTFILES.in │ ├── Rules-quot │ ├── boldquot.sed │ ├── ca.gmo │ ├── ca.po │ ├── da.gmo │ ├── da.po │ ├── de.gmo │ ├── de.po │ ├── en@boldquot.header │ ├── en@quot.header │ ├── es.gmo │ ├── es.po │ ├── fi.gmo │ ├── fi.po │ ├── flex.pot │ ├── fr.gmo │ ├── fr.po │ ├── ga.gmo │ ├── ga.po │ ├── insert-header.sin │ ├── ko.gmo │ ├── ko.po │ ├── nl.gmo │ ├── nl.po │ ├── pl.gmo │ ├── pl.po │ ├── pt_BR.gmo │ ├── pt_BR.po │ ├── quot.sed │ ├── remove-potcdate.sin │ ├── ro.gmo │ ├── ro.po │ ├── ru.gmo │ ├── ru.po │ ├── stamp-po │ ├── sv.gmo │ ├── sv.po │ ├── tr.gmo │ ├── tr.po │ ├── vi.gmo │ ├── vi.po │ ├── zh_CN.gmo │ └── zh_CN.po │ ├── regex.c │ ├── scan.c │ ├── scan.l │ ├── scanflags.c │ ├── scanopt.c │ ├── scanopt.h │ ├── skel.c │ ├── sym.c │ ├── tables.c │ ├── tables.h │ ├── tables_shared.c │ ├── tables_shared.h │ ├── tblcmp.c │ ├── tests │ ├── Makefile.am │ ├── Makefile.in │ ├── README │ ├── TEMPLATE │ │ ├── Makefile.am │ │ ├── Makefile.in │ │ ├── parser.y │ │ ├── scanner.l │ │ └── test.input │ ├── create-test │ ├── test-alloc-extra │ │ ├── Makefile.am │ │ ├── Makefile.in │ │ ├── scanner.l │ │ └── test.input │ ├── test-array-nr │ │ ├── Makefile.am │ │ ├── Makefile.in │ │ ├── scanner.l │ │ └── test.input │ ├── test-array-r │ │ ├── Makefile.am │ │ ├── Makefile.in │ │ ├── scanner.l │ │ └── test.input │ ├── test-basic-nr │ │ ├── Makefile.am │ │ ├── Makefile.in │ │ ├── scanner.l │ │ └── test.input │ ├── test-basic-r │ │ ├── Makefile.am │ │ ├── Makefile.in │ │ ├── scanner.l │ │ └── test.input │ ├── test-bison-nr │ │ ├── Makefile.am │ │ ├── Makefile.in │ │ ├── main.c │ │ ├── parser.y │ │ ├── scanner.l │ │ └── test.input │ ├── test-bison-yylloc │ │ ├── Makefile.am │ │ ├── Makefile.in │ │ ├── main.c │ │ ├── parser.y │ │ ├── scanner.l │ │ └── test.input │ ├── test-bison-yylval │ │ ├── Makefile.am │ │ ├── Makefile.in │ │ ├── main.c │ │ ├── parser.y │ │ ├── scanner.l │ │ └── test.input │ ├── test-c++-basic │ │ ├── Makefile.am │ │ ├── Makefile.in │ │ ├── scanner.l │ │ └── test.input │ ├── test-c++-multiple-scanners │ │ ├── Makefile.am │ │ ├── Makefile.in │ │ ├── main.cpp │ │ ├── scanner-1.l │ │ ├── scanner-2.l │ │ └── test.input │ ├── test-c++-yywrap │ │ ├── Makefile.am │ │ ├── Makefile.in │ │ ├── scanner.l │ │ └── test.input │ ├── test-c-cpp-nr │ │ ├── Makefile.am │ │ ├── Makefile.in │ │ ├── scanner.l │ │ └── test.input │ ├── test-c-cpp-r │ │ ├── Makefile.am │ │ ├── Makefile.in │ │ ├── scanner.l │ │ └── test.input │ ├── test-ccl │ │ ├── Makefile.am │ │ ├── Makefile.in │ │ ├── scanner.l │ │ └── test.input │ ├── test-concatenated-options │ │ ├── Makefile.am │ │ └── Makefile.in │ ├── test-debug-nr │ │ ├── Makefile.am │ │ ├── Makefile.in │ │ ├── scanner.l │ │ └── test.input │ ├── test-debug-r │ │ ├── Makefile.am │ │ ├── Makefile.in │ │ ├── scanner.l │ │ └── test.input │ ├── test-extended │ │ ├── Makefile.am │ │ ├── Makefile.in │ │ ├── scanner.l │ │ └── test.input │ ├── test-header-nr │ │ ├── Makefile.am │ │ ├── Makefile.in │ │ ├── main.c │ │ ├── scanner.l │ │ └── test.input │ ├── test-header-r │ │ ├── Makefile.am │ │ ├── Makefile.in │ │ ├── main.c │ │ ├── scanner.l │ │ └── test.input │ ├── test-include-by-buffer │ │ ├── Makefile.am │ │ ├── Makefile.in │ │ ├── scanner.l │ │ ├── test-1.input │ │ ├── test-2.input │ │ └── test-3.input │ ├── test-include-by-push │ │ ├── Makefile.am │ │ ├── Makefile.in │ │ ├── scanner.l │ │ ├── test-1.input │ │ ├── test-2.input │ │ └── test-3.input │ ├── test-include-by-reentrant │ │ ├── Makefile.am │ │ ├── Makefile.in │ │ ├── scanner.l │ │ ├── test-1.input │ │ ├── test-2.input │ │ └── test-3.input │ ├── test-linedir-r │ │ ├── Makefile.am │ │ ├── Makefile.in │ │ ├── check-lines.awk │ │ ├── main.c │ │ ├── scanner.l │ │ └── test.input │ ├── test-lineno-nr │ │ ├── Makefile.am │ │ ├── Makefile.in │ │ ├── scanner.l │ │ └── test.input │ ├── test-lineno-r │ │ ├── Makefile.am │ │ ├── Makefile.in │ │ ├── scanner.l │ │ └── test.input │ ├── test-mem-nr │ │ ├── Makefile.am │ │ ├── Makefile.in │ │ ├── scanner.l │ │ └── test.input │ ├── test-mem-r │ │ ├── Makefile.am │ │ ├── Makefile.in │ │ ├── scanner.l │ │ └── test.input │ ├── test-multiple-scanners-nr │ │ ├── Makefile.am │ │ ├── Makefile.in │ │ ├── main.c │ │ ├── scanner-1.l │ │ └── scanner-2.l │ ├── test-multiple-scanners-r │ │ ├── Makefile.am │ │ ├── Makefile.in │ │ ├── main.c │ │ ├── scanner-1.l │ │ └── scanner-2.l │ ├── test-noansi-nr │ │ ├── Makefile.am │ │ ├── Makefile.in │ │ ├── scanner.l │ │ └── test.input │ ├── test-noansi-r │ │ ├── Makefile.am │ │ ├── Makefile.in │ │ ├── scanner.l │ │ └── test.input │ ├── test-posix │ │ ├── Makefile.am │ │ ├── Makefile.in │ │ └── scanner.l │ ├── test-posixly-correct │ │ ├── Makefile.am │ │ ├── Makefile.in │ │ └── scanner.l │ ├── test-prefix-nr │ │ ├── Makefile.am │ │ ├── Makefile.in │ │ ├── README │ │ ├── scanner.l │ │ └── test.input │ ├── test-prefix-r │ │ ├── Makefile.am │ │ ├── Makefile.in │ │ ├── README │ │ ├── scanner.l │ │ └── test.input │ ├── test-pthread │ │ ├── Makefile.am │ │ ├── Makefile.in │ │ ├── scanner.l │ │ ├── test-1.input │ │ ├── test-2.input │ │ ├── test-3.input │ │ ├── test-4.input │ │ └── test-5.input │ ├── test-quotes │ │ ├── Makefile.am │ │ ├── Makefile.in │ │ ├── scanner.l │ │ └── test.input │ ├── test-reject │ │ ├── Makefile.am │ │ ├── Makefile.in │ │ ├── scanner.l │ │ └── test.input │ ├── test-rescan-nr │ │ ├── Makefile.am │ │ ├── Makefile.in │ │ ├── scanner.l │ │ └── test.input │ ├── test-rescan-r │ │ ├── Makefile.am │ │ ├── Makefile.in │ │ ├── scanner.l │ │ └── test.input │ ├── test-string-nr │ │ ├── Makefile.am │ │ ├── Makefile.in │ │ └── scanner.l │ ├── test-string-r │ │ ├── Makefile.am │ │ ├── Makefile.in │ │ └── scanner.l │ ├── test-table-opts │ │ ├── Makefile.am │ │ ├── Makefile.in │ │ ├── scanner.l │ │ └── test.input │ ├── test-top │ │ ├── Makefile.am │ │ ├── Makefile.in │ │ ├── main.c │ │ ├── scanner.l │ │ └── test.input │ └── test-yyextra │ │ ├── Makefile.am │ │ ├── Makefile.in │ │ ├── scanner.l │ │ └── test.input │ ├── tools │ ├── Makefile.am │ ├── Makefile.in │ └── git2cl │ ├── version.h │ ├── ylwrap │ └── yylex.c ├── makefile ├── run-experiment.sh ├── runtests.bat ├── src ├── absyn │ ├── Absyn.cpp │ ├── Absyn.h │ ├── ArrayExpr.cpp │ ├── ArrayExpr.h │ ├── BlogProgram.cpp │ ├── BlogProgram.h │ ├── BoolLiteral.cpp │ ├── BoolLiteral.h │ ├── CardinalityExpr.cpp │ ├── CardinalityExpr.h │ ├── CaseExpr.cpp │ ├── CaseExpr.h │ ├── CondSet.cpp │ ├── CondSet.h │ ├── Decl.cpp │ ├── Decl.h │ ├── DistinctDecl.cpp │ ├── DistinctDecl.h │ ├── DistrExpr.cpp │ ├── DistrExpr.h │ ├── DoubleLiteral.cpp │ ├── DoubleLiteral.h │ ├── Evidence.cpp │ ├── Evidence.h │ ├── Expr.cpp │ ├── Expr.h │ ├── FuncApp.cpp │ ├── FuncApp.h │ ├── FuncDecl.cpp │ ├── FuncDecl.h │ ├── IfExpr.cpp │ ├── IfExpr.h │ ├── IntLiteral.cpp │ ├── IntLiteral.h │ ├── ListSet.cpp │ ├── ListSet.h │ ├── Literal.cpp │ ├── Literal.h │ ├── MapExpr.cpp │ ├── MapExpr.h │ ├── NullLiteral.cpp │ ├── NullLiteral.h │ ├── NumStDecl.cpp │ ├── NumStDecl.h │ ├── OpExpr.cpp │ ├── OpExpr.h │ ├── OriginDecl.cpp │ ├── OriginDecl.h │ ├── QuantExpr.cpp │ ├── QuantExpr.h │ ├── Query.cpp │ ├── Query.h │ ├── SetExpr.cpp │ ├── SetExpr.h │ ├── Stmt.cpp │ ├── Stmt.h │ ├── StringLiteral.cpp │ ├── StringLiteral.h │ ├── Symbol.cpp │ ├── Symbol.h │ ├── TimeStampLiteral.cpp │ ├── TimeStampLiteral.h │ ├── TupleSetExpr.cpp │ ├── TupleSetExpr.h │ ├── Ty.cpp │ ├── Ty.h │ ├── TypDecl.cpp │ ├── TypDecl.h │ ├── VarDecl.cpp │ ├── VarDecl.h │ ├── VarRef.cpp │ └── VarRef.h ├── analyzer │ ├── Analyzer.cpp │ ├── Analyzer.h │ ├── ConjugacyAnalyzer.cpp │ ├── ConjugacyAnalyzer.h │ ├── ConjugatePriors │ │ ├── ConjugatePrior.cpp │ │ ├── ConjugatePrior.h │ │ ├── ConjugatePriorList.cpp │ │ ├── ConjugatePriorList.h │ │ ├── InvGammaPrior.cpp │ │ └── InvGammaPrior.h │ ├── ContigAnalyzer.cpp │ ├── ContigAnalyzer.h │ ├── MCMCAnalyzer.cpp │ └── MCMCAnalyzer.h ├── benchmark │ └── handcompile │ │ ├── LWSamplerBurglary.cpp │ │ ├── LWSamplerBurglary.h │ │ ├── LWSamplerCSI.cpp │ │ ├── LWSamplerCSI.h │ │ ├── LWSamplerUrnBall.cpp │ │ ├── LWSamplerUrnBall.h │ │ ├── execute_hurricane.cpp │ │ ├── execute_urnball.cpp │ │ ├── lwsampler_hurricane.cpp │ │ ├── lwsampler_hurricane.h │ │ ├── makefile │ │ ├── rejsampler_hurricane.cpp │ │ ├── rejsampler_hurricane.h │ │ ├── rejsampler_urnball.cpp │ │ └── rejsampler_urnball.h ├── code │ ├── ArraySubscriptExpr.cpp │ ├── ArraySubscriptExpr.h │ ├── BinaryOperator.cpp │ ├── BinaryOperator.h │ ├── BooleanLiteral.cpp │ ├── BooleanLiteral.h │ ├── BreakStmt.cpp │ ├── BreakStmt.h │ ├── CallClassConstructor.cpp │ ├── CallClassConstructor.h │ ├── CallExpr.cpp │ ├── CallExpr.h │ ├── CaseStmt.cpp │ ├── CaseStmt.h │ ├── ClassConstructor.cpp │ ├── ClassConstructor.h │ ├── ClassDecl.cpp │ ├── ClassDecl.h │ ├── Code.cpp │ ├── Code.h │ ├── CodeForwardDeclaration.h │ ├── CompoundStmt.cpp │ ├── CompoundStmt.h │ ├── ContinueStmt.cpp │ ├── ContinueStmt.h │ ├── Decl.cpp │ ├── Decl.h │ ├── DeclContext.cpp │ ├── DeclContext.h │ ├── DeclStmt.cpp │ ├── DeclStmt.h │ ├── Expr.cpp │ ├── Expr.h │ ├── FieldDecl.cpp │ ├── FieldDecl.h │ ├── FloatingLiteral.cpp │ ├── FloatingLiteral.h │ ├── ForStmt.cpp │ ├── ForStmt.h │ ├── FunctionDecl.cpp │ ├── FunctionDecl.h │ ├── Identifier.cpp │ ├── Identifier.h │ ├── IfStmt.cpp │ ├── IfStmt.h │ ├── IntegerLiteral.cpp │ ├── IntegerLiteral.h │ ├── LambdaExpr.cpp │ ├── LambdaExpr.h │ ├── ListInitExpr.cpp │ ├── ListInitExpr.h │ ├── NamespaceDecl.cpp │ ├── NamespaceDecl.h │ ├── NewExpr.cpp │ ├── NewExpr.h │ ├── NullLiteral.cpp │ ├── NullLiteral.h │ ├── ParamVarDecl.cpp │ ├── ParamVarDecl.h │ ├── ReturnStmt.cpp │ ├── ReturnStmt.h │ ├── SpecialMacro.cpp │ ├── SpecialMacro.h │ ├── Stmt.cpp │ ├── Stmt.h │ ├── StringLiteral.cpp │ ├── StringLiteral.h │ ├── SwitchStmt.cpp │ ├── SwitchStmt.h │ ├── TemplateExpr.cpp │ ├── TemplateExpr.h │ ├── Type.cpp │ ├── Type.h │ ├── VarDecl.cpp │ └── VarDecl.h ├── codegen │ ├── GibbsTranslator.cpp │ ├── GibbsTranslator.h │ ├── LWTranslator.cpp │ ├── LWTranslator.h │ ├── MHTranslator.cpp │ ├── MHTranslator.h │ ├── PFTranslator.cpp │ ├── PFTranslator.h │ ├── Translator.cpp │ └── Translator.h ├── fabrica │ ├── Functory.cpp │ ├── Functory.h │ ├── PreDeclFactory.cpp │ ├── PreDeclFactory.h │ ├── TypeFactory.cpp │ └── TypeFactory.h ├── ir │ ├── ArrayExpr.cpp │ ├── ArrayExpr.h │ ├── ArrayTy.cpp │ ├── ArrayTy.h │ ├── BlogModel.cpp │ ├── BlogModel.h │ ├── BoolLiteral.cpp │ ├── BoolLiteral.h │ ├── Branch.cpp │ ├── Branch.h │ ├── CardExpr.cpp │ ├── CardExpr.h │ ├── CategoricalDistr.cpp │ ├── CategoricalDistr.h │ ├── Clause.cpp │ ├── Clause.h │ ├── CondSet.cpp │ ├── CondSet.h │ ├── ConstSymbol.cpp │ ├── ConstSymbol.h │ ├── Distribution.cpp │ ├── Distribution.h │ ├── DoubleLiteral.cpp │ ├── DoubleLiteral.h │ ├── Evidence.cpp │ ├── Evidence.h │ ├── Expr.cpp │ ├── Expr.h │ ├── FuncDefn.cpp │ ├── FuncDefn.h │ ├── FunctionCall.cpp │ ├── FunctionCall.h │ ├── IRConst.cpp │ ├── IRConst.h │ ├── IRForwardDecl.h │ ├── IRHeader.h │ ├── IfThen.cpp │ ├── IfThen.h │ ├── InstSymbol.cpp │ ├── InstSymbol.h │ ├── InstSymbolRef.cpp │ ├── InstSymbolRef.h │ ├── IntLiteral.cpp │ ├── IntLiteral.h │ ├── ListSet.cpp │ ├── ListSet.h │ ├── MapExpr.cpp │ ├── MapExpr.h │ ├── MapTy.cpp │ ├── MapTy.h │ ├── MatrixExpr.cpp │ ├── MatrixExpr.h │ ├── NameTy.cpp │ ├── NameTy.h │ ├── NullSymbol.cpp │ ├── NullSymbol.h │ ├── NumberStmt.cpp │ ├── NumberStmt.h │ ├── OprExpr.cpp │ ├── OprExpr.h │ ├── OriginAttr.cpp │ ├── OriginAttr.h │ ├── OriginRefer.cpp │ ├── OriginRefer.h │ ├── QuantForm.cpp │ ├── QuantForm.h │ ├── Query.cpp │ ├── Query.h │ ├── SetExpr.cpp │ ├── SetExpr.h │ ├── SetTy.cpp │ ├── SetTy.h │ ├── StringLiteral.cpp │ ├── StringLiteral.h │ ├── TimestepLiteral.cpp │ ├── TimestepLiteral.h │ ├── Ty.cpp │ ├── Ty.h │ ├── TypeDomain.cpp │ ├── TypeDomain.h │ ├── UniformChoiceDistr.cpp │ ├── UniformChoiceDistr.h │ ├── VarDecl.cpp │ ├── VarDecl.h │ ├── VarRefer.cpp │ └── VarRefer.h ├── main.cpp ├── msg │ ├── ErrorMsg.cpp │ └── ErrorMsg.h ├── parse │ ├── BLOGSymbol.h │ ├── blog.flex │ ├── blog.yacc │ ├── lexer.cpp │ ├── parser.cpp │ └── parser.h ├── predecl │ ├── BernoulliDistrDecl.cpp │ ├── BernoulliDistrDecl.h │ ├── BetaDistrDecl.cpp │ ├── BetaDistrDecl.h │ ├── BinomialDistrDecl.cpp │ ├── BinomialDistrDecl.h │ ├── BooleanDistrDecl.cpp │ ├── BooleanDistrDecl.h │ ├── CategoricalDistrDecl.cpp │ ├── CategoricalDistrDecl.h │ ├── DiagGaussianDistrDecl.cpp │ ├── DiagGaussianDistrDecl.h │ ├── DirichletDistrDecl.cpp │ ├── DirichletDistrDecl.h │ ├── DiscreteDistrDecl.cpp │ ├── DiscreteDistrDecl.h │ ├── ExponentialDistrDecl.cpp │ ├── ExponentialDistrDecl.h │ ├── GammaDistrDecl.cpp │ ├── GammaDistrDecl.h │ ├── GaussianDistrDecl.cpp │ ├── GaussianDistrDecl.h │ ├── GeometricDistrDecl.cpp │ ├── GeometricDistrDecl.h │ ├── InvGammaDistrDecl.cpp │ ├── InvGammaDistrDecl.h │ ├── InvWishartDistrDecl.cpp │ ├── InvWishartDistrDecl.h │ ├── LaplaceDistrDecl.cpp │ ├── LaplaceDistrDecl.h │ ├── LoadRealMatrixFuncDecl.cpp │ ├── LoadRealMatrixFuncDecl.h │ ├── MathFuncDecl.cpp │ ├── MathFuncDecl.h │ ├── MatrixConstructFuncDecl.cpp │ ├── MatrixConstructFuncDecl.h │ ├── MatrixIntFuncDecl.cpp │ ├── MatrixIntFuncDecl.h │ ├── MatrixMatrixFuncDecl.cpp │ ├── MatrixMatrixFuncDecl.h │ ├── MatrixRealFuncDecl.cpp │ ├── MatrixRealFuncDecl.h │ ├── MatrixStackFuncDecl.cpp │ ├── MatrixStackFuncDecl.h │ ├── MatrixSubsetFuncDecl.cpp │ ├── MatrixSubsetFuncDecl.h │ ├── MultinomialDistrDecl.cpp │ ├── MultinomialDistrDecl.h │ ├── MultivarGaussianDistrDecl.cpp │ ├── MultivarGaussianDistrDecl.h │ ├── PoissonDistrDecl.cpp │ ├── PoissonDistrDecl.h │ ├── PreDecl.cpp │ ├── PreDecl.h │ ├── PreDeclList.cpp │ ├── PreDeclList.h │ ├── PrecisionGaussianDistrDecl.cpp │ ├── PrecisionGaussianDistrDecl.h │ ├── PrevFuncDecl.cpp │ ├── PrevFuncDecl.h │ ├── SetAggrFuncDecl.cpp │ ├── SetAggrFuncDecl.h │ ├── ToIntFuncDecl.cpp │ ├── ToIntFuncDecl.h │ ├── ToMatrixFuncDecl.cpp │ ├── ToMatrixFuncDecl.h │ ├── ToRealFuncDecl.cpp │ ├── ToRealFuncDecl.h │ ├── ToStringFuncDecl.cpp │ ├── ToStringFuncDecl.h │ ├── TruncatedGaussDistrDecl.cpp │ ├── TruncatedGaussDistrDecl.h │ ├── UniformChoiceDistrDecl.cpp │ ├── UniformChoiceDistrDecl.h │ ├── UniformIntDistrDecl.cpp │ ├── UniformIntDistrDecl.h │ ├── UniformRealDistrDecl.cpp │ ├── UniformRealDistrDecl.h │ ├── UniformVectorDistrDecl.cpp │ └── UniformVectorDistrDecl.h ├── preprocess │ ├── Preprocessor.cpp │ └── Preprocessor.h ├── printer │ ├── CPPPrinter.cpp │ ├── CPPPrinter.h │ ├── Printer.cpp │ └── Printer.h ├── random │ ├── Bernoulli.cpp │ ├── Bernoulli.h │ ├── Beta.cpp │ ├── Beta.h │ ├── Binomial.cpp │ ├── Binomial.h │ ├── BooleanDistrib.cpp │ ├── BooleanDistrib.h │ ├── Categorical.cpp │ ├── Categorical.h │ ├── DiagGaussian.cpp │ ├── DiagGaussian.h │ ├── Dirichlet.cpp │ ├── Dirichlet.h │ ├── Discrete.cpp │ ├── Discrete.h │ ├── Exponential.cpp │ ├── Exponential.h │ ├── Gamma.cpp │ ├── Gamma.h │ ├── Gaussian.cpp │ ├── Gaussian.h │ ├── Geometric.cpp │ ├── Geometric.h │ ├── InvGamma.cpp │ ├── InvGamma.h │ ├── InvWishart.cpp │ ├── InvWishart.h │ ├── Laplace.cpp │ ├── Laplace.h │ ├── Multinomial.cpp │ ├── Multinomial.h │ ├── MultivarGaussian.cpp │ ├── MultivarGaussian.h │ ├── MultivarGaussianIndep.cpp │ ├── MultivarGaussianIndep.h │ ├── Poisson.cpp │ ├── Poisson.h │ ├── PrecisionGaussian.cpp │ ├── PrecisionGaussian.h │ ├── SwiftDistribution.h │ ├── TruncatedGauss.cpp │ ├── TruncatedGauss.h │ ├── UniformChoice.cpp │ ├── UniformChoice.h │ ├── UniformInt.cpp │ ├── UniformInt.h │ ├── UniformReal.cpp │ ├── UniformReal.h │ ├── UniformVector.cpp │ └── UniformVector.h ├── semant │ ├── Semant.cpp │ └── Semant.h ├── test.cc ├── test │ ├── absyn │ │ ├── AircraftSimple.cpp │ │ ├── AircraftSimple.h │ │ ├── BiasedBall.cpp │ │ ├── BiasedBall.h │ │ ├── Birthday.cpp │ │ ├── Birthday.h │ │ ├── DirichletSimpleTest.cpp │ │ ├── DirichletSimpleTest.h │ │ ├── DirichletSimpleTest2.cpp │ │ ├── DirichletSimpleTest2.h │ │ ├── HMM.cpp │ │ ├── HMM.h │ │ ├── Hurricane.cpp │ │ ├── Hurricane.h │ │ ├── MatrixTest.cpp │ │ ├── MatrixTest.h │ │ ├── MultiCaseSimpleTest.cpp │ │ ├── MultiCaseSimpleTest.h │ │ ├── MultinomialSimpleTest.cpp │ │ ├── MultinomialSimpleTest.h │ │ ├── PoissonBall.cpp │ │ └── PoissonBall.h │ ├── parse │ │ ├── distinct.in │ │ ├── distinct.out │ │ ├── evidence.in │ │ ├── evidence.out │ │ ├── fundec.in │ │ ├── fundec.out │ │ ├── hurricane.in │ │ ├── hurricane.out │ │ ├── ifexp.in │ │ ├── ifexp.out │ │ ├── map.in │ │ ├── map.out │ │ ├── numdec.in │ │ ├── numdec.out │ │ ├── numref.in │ │ ├── numref.out │ │ ├── origin.in │ │ ├── origin.out │ │ ├── quant.in │ │ └── quant.out │ ├── random │ │ └── TestCategorical.cpp │ └── semant │ │ └── Semant_test.cpp └── util │ ├── Configuration.cpp │ ├── Configuration.h │ ├── DynamicTable.h │ ├── Hist.h │ ├── Hist_matrix.h │ ├── MCMC.h │ ├── util.h │ ├── util_MCMC.h │ ├── util_conjugate.h │ └── util_matrix.h ├── swift.rc ├── swifty-mh.bat ├── swifty-mh.sh ├── swifty-pf.bat ├── swifty-pf.sh ├── swifty.bat └── swifty.sh /compile.bat: -------------------------------------------------------------------------------- 1 | g++ -std=c++11 -Wall src/preprocess/*.cpp src/printer/*.cpp src/absyn/*.cpp src/analyzer/*.cpp src/analyzer/ConjugatePriors/*.cpp src/ir/*.cpp src/fabrica/*.cpp src/msg/*.cpp src/predecl/*.cpp src/code/*.cpp src/codegen/*.cpp src/util/*.cpp src/semant/Semant.cpp src/main.cpp src/parse/parser.cpp src/parse/lexer.cpp -o swift 2 | -------------------------------------------------------------------------------- /design/swift-architecture.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lileicc/swift/57c4a4cd065f1149f86f3d04402f8dbdce1ac5ff/design/swift-architecture.pptx -------------------------------------------------------------------------------- /design/swift-ir-classdiagram.zargo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lileicc/swift/57c4a4cd065f1149f86f3d04402f8dbdce1ac5ff/design/swift-ir-classdiagram.zargo -------------------------------------------------------------------------------- /example/birthday.blog: -------------------------------------------------------------------------------- 1 | type Date; 2 | distinct Date Day[365]; 3 | 4 | type Person; 5 | 6 | random Date Birthday(Person p) ~ 7 | UniformChoice({d for Date d}); 8 | 9 | #Person ~ Poisson(13); 10 | 11 | // comment the following to try full open world model 12 | obs size({p for Person p}) = 23; 13 | query exists Person x exists Person y 14 | ((x != y) & (Birthday(x) == Birthday(y))); 15 | -------------------------------------------------------------------------------- /example/burglary-multihouse.blog: -------------------------------------------------------------------------------- 1 | type House; 2 | 3 | distinct House Maryhouse, Johnhouse, Cathyhouse, Rogerhouse; 4 | 5 | random Boolean Burglary(House h) ~ BooleanDistrib(0.003); 6 | random Boolean Earthquake ~ BooleanDistrib(0.002); 7 | random Boolean Alarm(House h) ~ 8 | case [Burglary(h), Earthquake] in { 9 | [false, false] -> BooleanDistrib(0.01), 10 | [false, true] -> BooleanDistrib(0.40), 11 | [true, false] -> BooleanDistrib(0.80), 12 | [true, true ] -> BooleanDistrib(0.90) 13 | }; 14 | 15 | obs Alarm(Maryhouse) = true; 16 | obs Alarm(Johnhouse) = true; 17 | obs Alarm(Cathyhouse) = true; 18 | obs Alarm(Rogerhouse) = false; 19 | 20 | query Earthquake; -------------------------------------------------------------------------------- /example/csi.blog: -------------------------------------------------------------------------------- 1 | /* Model that illustrates context-specific independence. This is a 2 | * parameterization of the model shown in Fig. 3 of [Milch et al., 3 | * AISTATS 2005]: X depends on W when U is true, but on V when U is false. 4 | * 5 | * The probability of X being true given no evidence is P(X=true) = 0.596. 6 | */ 7 | 8 | random Boolean U ~ BooleanDistrib(0.3); 9 | 10 | random Boolean V ~ BooleanDistrib(0.9); 11 | 12 | random Boolean W ~ BooleanDistrib(0.1); 13 | 14 | random Boolean X ~ 15 | if U then case W in {true -> BooleanDistrib(0.8), 16 | false -> BooleanDistrib(0.2)} 17 | else case V in {true -> BooleanDistrib(0.8), 18 | false -> BooleanDistrib(0.2)} 19 | ; 20 | query X; -------------------------------------------------------------------------------- /example/exponential.blog: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * Simple model to test if exponential distribution is working. 4 | * 5 | * Query will check if BLOG can correctly compute the likelihood of the exponential. 6 | */ 7 | 8 | 9 | random Real wait ~ Exponential(4); 10 | 11 | random Boolean check ~ 12 | if wait < 0.5 then BooleanDistrib(1.0) 13 | else BooleanDistrib(0.0); 14 | 15 | 16 | obs check = false; 17 | 18 | query wait; 19 | -------------------------------------------------------------------------------- /example/simple-aircraft.blog: -------------------------------------------------------------------------------- 1 | // Type Declarations 2 | type Aircraft; 3 | type Blip; 4 | 5 | // Origin Declarations 6 | origin Aircraft Source(Blip); 7 | 8 | // Number Declarations 9 | #Aircraft ~ Poisson(5); 10 | #Blip(Source=a) ~ Poisson(4); 11 | 12 | // Evidence 13 | obs size({b for Blip b}) = 3; 14 | 15 | // Query 16 | query size({a for Aircraft a}); 17 | -------------------------------------------------------------------------------- /example/test/test-diaggaussian.blog: -------------------------------------------------------------------------------- 1 | /** 2 | * Simple test for DiagGaussian model. 3 | */ 4 | 5 | fixed RealMatrix mean = [0.0;0.0]; 6 | fixed RealMatrix cov = [1.0;1.0]; 7 | 8 | Random RealMatrix r ~ DiagGaussian(mean, cov); 9 | 10 | Random Boolean check ~ if r[0] < 0 then true else false; 11 | 12 | obs check = false; 13 | query r[0]; 14 | query r; 15 | -------------------------------------------------------------------------------- /example/test/test-distrib-placement.blog: -------------------------------------------------------------------------------- 1 | type Data; 2 | distinct Data D[10]; 3 | random Real X ~ Gaussian(0, 1); 4 | random Boolean A(Data d) ~ BooleanDistrib(0.5); 5 | random Real Y(Data d) ~ 6 | if A(d) then Gaussian(toInt(d), 1) 7 | else Gaussian(X + toInt(d), 1); 8 | 9 | obs Y(d) = toInt(d) for Data d; 10 | 11 | query X; 12 | -------------------------------------------------------------------------------- /example/test/test-extern.blog: -------------------------------------------------------------------------------- 1 | /* 2 | * This example demonstrates how to import external C++ function (i.e. sqr(), loadData();) 3 | * User can write a customized function in an external C++ header file: user_util.h 4 | * double sqr(double x) {...} 5 | * double loadData() {...} 6 | * Then use swift option 7 | * swift --include "user_util.h" 8 | * to ask swift to include the external C++ file in the target code 9 | */ 10 | 11 | extern Real sqr(Real x); 12 | extern Real loadData(); 13 | 14 | fixed Real a = 1.0; 15 | fixed Real b = 2.0 - 1; 16 | random Real x ~ Gaussian(b, sqr(a)); 17 | random Real y ~ Gaussian(x, 1); 18 | 19 | obs y = loadData(); 20 | 21 | query x; 22 | -------------------------------------------------------------------------------- /example/test/test-invwishart.blog: -------------------------------------------------------------------------------- 1 | /** 2 | * Basic test for InverseWishart distribution. 3 | */ 4 | 5 | fixed RealMatrix mean = [0.0; 0.0; 0.0]; 6 | fixed RealMatrix cov = [400.0, 256.0, 144.0; 256.0, 256.0, 196.0; 144.0, 196.0, 324.0]; 7 | random RealMatrix Variance ~ InvWishart(cov, 4); 8 | random RealMatrix Intensity ~ MultivarGaussian(mean, Variance); 9 | 10 | obs Intensity = [0.0; 0.0; 0.0]; 11 | query Variance; // In expectation, Variance should equal the value of cov 12 | -------------------------------------------------------------------------------- /example/test/test-matrix.blog: -------------------------------------------------------------------------------- 1 | fixed Real x = 1; 2 | fixed Real y = 0; 3 | fixed Real z = -1; 4 | fixed RealMatrix A = [x,y,z]; 5 | fixed RealMatrix B = [x;y;z]; 6 | fixed RealMatrix W = [1,0.0,0;0.0,1,0;0.0,0,1]; 7 | 8 | fixed Real scale(Real k) = A * transpose(A) * k; 9 | 10 | random RealMatrix C ~ MultivarGaussian(B,W); 11 | random RealMatrix D ~ MultivarGaussian([3.0;3.0;3.0],W); 12 | 13 | obs D = vstack(2,2,2); 14 | 15 | query scale(1.5); 16 | query C[0]; 17 | query D[0] + (B * A)[0][0]; 18 | query C; 19 | -------------------------------------------------------------------------------- /example/test/test-obs-forloop-pf.blog: -------------------------------------------------------------------------------- 1 | type Data; 2 | distinct Data D[10]; 3 | 4 | fixed RealMatrix A = randn(3, 10); 5 | 6 | random Real mu ~ Gaussian(0, 1); 7 | 8 | random Real B(Data d, Timestep t) ~ Gaussian(mu, 1); 9 | 10 | obs B(d, t) = A[toInt(t)][toInt(d)] for Timestep t, Data d: @0 <= t & t <= @2; 11 | 12 | query mu; 13 | -------------------------------------------------------------------------------- /example/test/test-obs-forloop.blog: -------------------------------------------------------------------------------- 1 | type Data; 2 | type Step; 3 | distinct Data D[10]; 4 | distinct Step S[3]; 5 | 6 | fixed RealMatrix A = randn(3, 10); 7 | 8 | random Real mu ~ Gaussian(0, 1); 9 | 10 | random Real B(Data d, Step t) ~ Gaussian(mu, 1); 11 | 12 | obs B(d, t) = A[toInt(t)][toInt(d)] for Step t, Data d; 13 | 14 | query mu; 15 | -------------------------------------------------------------------------------- /example/test/test-precisiongaussian.blog: -------------------------------------------------------------------------------- 1 | /** 2 | * Simple test for PrecisionGaussian model. 3 | */ 4 | 5 | fixed RealMatrix mean = [0.0;0.0]; 6 | fixed RealMatrix cov_inv = [2.28571, -1.71429; -1.71429, 2.28571]; 7 | fixed RealMatrix cov = [1.0, 0.75 ; 0.75, 1.0]; 8 | 9 | Random RealMatrix r ~ PrecisionGaussian(mean, cov_inv); 10 | Random RealMatrix q ~ MultivarGaussian(mean, cov); 11 | 12 | Random Boolean check1 ~ if r[0] < 0 then true else false; 13 | Random Boolean check2 ~ if q[0] < 0 then true else false; 14 | 15 | obs check1 = false; 16 | obs check2 = false; 17 | 18 | query r[0]; 19 | query q[0]; 20 | -------------------------------------------------------------------------------- /example/test/test-query-forloop.blog: -------------------------------------------------------------------------------- 1 | type Data; 2 | type Step; 3 | distinct Data D[10]; 4 | distinct Step S[3]; 5 | 6 | fixed RealMatrix A = randn(3, 10); 7 | 8 | random Real mu ~ Gaussian(0, 1); 9 | 10 | random Real B(Data d, Step t) ~ Gaussian(mu, 1); 11 | 12 | random Real C(Data d, Step t) ~ Gaussian(B(d, t), 1); 13 | 14 | obs C(d, t) = A[toInt(t)][toInt(d)] for Step t, Data d; 15 | 16 | query B(d, t) for Step t, Data d; 17 | -------------------------------------------------------------------------------- /git-sync.sh: -------------------------------------------------------------------------------- 1 | git pull --all 2 | git remote prune origin 3 | git branch --merged | grep -v "\*" | xargs -n 1 git branch -d 4 | -------------------------------------------------------------------------------- /lib/byacc-20130925/AUTHORS: -------------------------------------------------------------------------------- 1 | -- $Id: AUTHORS,v 1.1 2010/06/06 20:31:51 tom Exp $ 2 | -- vile:txtmode 3 | -- This file is used by a script that collects contributor information and 4 | -- resolves nicknames vs fullnames. 5 | dickey Thomas Dickey 6 | schmitz Sylvain Schmitz 7 | unknown Robert Corbett 8 | -------------------------------------------------------------------------------- /lib/byacc-20130925/NOTES: -------------------------------------------------------------------------------- 1 | Berkeley Yacc reflects its origins. The reason so many routines 2 | use exactly six register variables is that Berkeley Yacc was 3 | developed on a VAX using PCC. PCC placed at most six variables 4 | in registers. I went to considerable effort to find which six 5 | variables most belonged in registers. Changes in machines and 6 | compilers make that effort worthless, perhaps even harmful. 7 | 8 | The code contains many instances where address calculations are 9 | performed in particular ways to optimize the code for the VAX. 10 | -------------------------------------------------------------------------------- /lib/byacc-20130925/NO_WARRANTY: -------------------------------------------------------------------------------- 1 | Berkeley Yacc is distributed with no warranty whatever. The author 2 | and any other contributors take no responsibility for the consequences of 3 | its use. 4 | -------------------------------------------------------------------------------- /lib/byacc-20130925/VERSION: -------------------------------------------------------------------------------- 1 | 20130925 2 | -------------------------------------------------------------------------------- /lib/byacc-20130925/configure.in: -------------------------------------------------------------------------------- 1 | dnl Process this file with 'autoconf' to produce a 'configure' script 2 | dnl $Id: configure.in,v 1.14 2012/10/03 23:41:36 tom Exp $ 3 | AC_PREREQ(2.52.20011201) 4 | AC_REVISION($Revision: 1.14 $) 5 | AC_INIT(main.c) 6 | AC_CONFIG_HEADER(config.h:config_h.in) 7 | 8 | CF_CHECK_CACHE([AC_CANONICAL_SYSTEM]) 9 | 10 | AC_ARG_PROGRAM 11 | CF_PROG_CC 12 | AC_PROG_MAKE_SET 13 | AC_PROG_INSTALL 14 | CF_MAKE_TAGS 15 | CF_PROG_LINT 16 | 17 | CF_XOPEN_SOURCE 18 | AC_CHECK_HEADERS(fcntl.h) 19 | CF_MKSTEMP 20 | 21 | CF_WITH_WARNINGS(Wwrite-strings) 22 | CF_DISABLE_ECHO 23 | CF_DISABLE_LEAKS 24 | 25 | ### output makefile 26 | AC_OUTPUT(makefile) 27 | -------------------------------------------------------------------------------- /lib/byacc-20130925/package/debian/compat: -------------------------------------------------------------------------------- 1 | 5 2 | -------------------------------------------------------------------------------- /lib/byacc-20130925/package/debian/control: -------------------------------------------------------------------------------- 1 | Source: byacc 2 | Maintainer: Dave Beckett 3 | Section: devel 4 | Priority: extra 5 | Standards-Version: 3.8.4 6 | Build-Depends: debhelper (>= 5) 7 | Homepage: http://invisible-island.net/byacc/ 8 | 9 | Package: byacc 10 | Architecture: any 11 | Depends: ${shlibs:Depends}, ${misc:Depends} 12 | Description: public domain Berkeley LALR Yacc parser generator 13 | This package provides a parser generator utility that reads a grammar 14 | specification from a file and generates an LR(1) parser for it. The 15 | parsers consist of a set of LALR(1) parsing tables and a driver 16 | routine written in the C programming language. It has a public domain 17 | license which includes the generated C. 18 | -------------------------------------------------------------------------------- /lib/byacc-20130925/package/debian/docs: -------------------------------------------------------------------------------- 1 | README 2 | ACKNOWLEDGEMENTS 3 | NEW_FEATURES 4 | NOTES 5 | -------------------------------------------------------------------------------- /lib/byacc-20130925/package/debian/postinst: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # postinst script for byacc 3 | 4 | set -e 5 | 6 | if [ $1 != "upgrade" ] ; then 7 | update-alternatives \ 8 | --install /usr/bin/yacc yacc /usr/bin/byacc 80 \ 9 | --slave /usr/share/man/man1/yacc.1.gz yaccman \ 10 | /usr/share/man/man1/byacc.1.gz 11 | fi 12 | 13 | #DEBHELPER# 14 | 15 | exit 0 16 | -------------------------------------------------------------------------------- /lib/byacc-20130925/package/debian/prerm: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # prerm script for byacc 3 | 4 | set -e 5 | 6 | if [ $1 != "upgrade" ]; then 7 | update-alternatives --remove yacc /usr/bin/byacc 8 | fi 9 | 10 | #DEBHELPER# 11 | 12 | exit 0 13 | -------------------------------------------------------------------------------- /lib/byacc-20130925/package/debian/source/format: -------------------------------------------------------------------------------- 1 | 3.0 (quilt) 2 | -------------------------------------------------------------------------------- /lib/byacc-20130925/package/debian/watch: -------------------------------------------------------------------------------- 1 | version=3 2 | 3 | opts=passive ftp://invisible-island.net/byacc/byacc-(\d+)\.tgz \ 4 | debian uupdate 5 | -------------------------------------------------------------------------------- /lib/byacc-20130925/package/pkgsrc/DESCR: -------------------------------------------------------------------------------- 1 | Berkeley Yacc (byacc) is a LALR(1) parser generator. Berkeley Yacc 2 | has been made as compatible as possible with AT&T Yacc. Berkeley 3 | Yacc can accept any input specification that conforms to the AT&T 4 | Yacc documentation. 5 | 6 | Some programs depend on a byacc (instead of bison). 7 | -------------------------------------------------------------------------------- /lib/byacc-20130925/package/pkgsrc/Makefile: -------------------------------------------------------------------------------- 1 | # $NetBSD: Makefile,v 1.9 2008/07/24 17:13:00 tonnerre Exp $ 2 | # 3 | 4 | DISTNAME= byacc-20050813 5 | PKGREVISION= 1 6 | CATEGORIES= devel 7 | MASTER_SITES= ftp://invisible-island.net/byacc/ 8 | EXTRACT_SUFX= .tgz 9 | 10 | MAINTAINER= pkgsrc-users@NetBSD.org 11 | HOMEPAGE= http://dickey.his.com/byacc/byacc.html 12 | COMMENT= Berkeley Yacc 13 | 14 | PKG_DESTDIR_SUPPORT= user-destdir 15 | 16 | GNU_CONFIGURE= YES 17 | MAKE_FILE= makefile 18 | 19 | .include "../../mk/bsd.pkg.mk" 20 | -------------------------------------------------------------------------------- /lib/byacc-20130925/package/pkgsrc/PLIST: -------------------------------------------------------------------------------- 1 | @comment $NetBSD: PLIST,v 1.2 2005/04/13 14:11:54 wiz Exp $ 2 | bin/yacc 3 | man/man1/yacc.1 4 | -------------------------------------------------------------------------------- /lib/byacc-20130925/package/pkgsrc/distinfo: -------------------------------------------------------------------------------- 1 | $NetBSD: distinfo,v 1.4 2008/07/24 17:13:00 tonnerre Exp $ 2 | 3 | SHA1 (byacc-20050813.tgz) = 3258494f3422eb3150944c1823af1c9c2c386062 4 | RMD160 (byacc-20050813.tgz) = 3ee159857a79025a83e2b0807577925fe460f816 5 | Size (byacc-20050813.tgz) = 138684 bytes 6 | SHA1 (patch-aa) = decae78775a5e0f1e1f7aaaa258da53903aa1f7a 7 | -------------------------------------------------------------------------------- /lib/byacc-20130925/test/README: -------------------------------------------------------------------------------- 1 | -- $Id: README,v 1.1 2004/03/28 19:10:48 tom Exp $ 2 | 3 | The files in this directory are input (.y) and output (.output, .tab.c, .tab.h) 4 | examples. 5 | -------------------------------------------------------------------------------- /lib/byacc-20130925/test/calc.tab.h: -------------------------------------------------------------------------------- 1 | #define DIGIT 257 2 | #define LETTER 258 3 | #define UMINUS 259 4 | -------------------------------------------------------------------------------- /lib/byacc-20130925/test/calc1.tab.h: -------------------------------------------------------------------------------- 1 | #define DREG 257 2 | #define VREG 258 3 | #define CONST 259 4 | #define UMINUS 260 5 | #ifdef YYSTYPE 6 | #undef YYSTYPE_IS_DECLARED 7 | #define YYSTYPE_IS_DECLARED 1 8 | #endif 9 | #ifndef YYSTYPE_IS_DECLARED 10 | #define YYSTYPE_IS_DECLARED 1 11 | typedef union 12 | { 13 | int ival; 14 | double dval; 15 | INTERVAL vval; 16 | } YYSTYPE; 17 | #endif /* !YYSTYPE_IS_DECLARED */ 18 | extern YYSTYPE calc1_lval; 19 | -------------------------------------------------------------------------------- /lib/byacc-20130925/test/calc2.tab.h: -------------------------------------------------------------------------------- 1 | #define DIGIT 257 2 | #define LETTER 258 3 | #define UMINUS 259 4 | -------------------------------------------------------------------------------- /lib/byacc-20130925/test/calc3.tab.h: -------------------------------------------------------------------------------- 1 | #define DIGIT 257 2 | #define LETTER 258 3 | #define UMINUS 259 4 | -------------------------------------------------------------------------------- /lib/byacc-20130925/test/code_calc.tab.h: -------------------------------------------------------------------------------- 1 | #define DIGIT 257 2 | #define LETTER 258 3 | #define UMINUS 259 4 | -------------------------------------------------------------------------------- /lib/byacc-20130925/test/code_error.output: -------------------------------------------------------------------------------- 1 | 0 $accept : S $end 2 | 3 | 1 S : error 4 | 5 | state 0 6 | $accept : . S $end (0) 7 | 8 | error shift 1 9 | . error 10 | 11 | S goto 2 12 | 13 | 14 | state 1 15 | S : error . (1) 16 | 17 | . reduce 1 18 | 19 | 20 | state 2 21 | $accept : S . $end (0) 22 | 23 | $end accept 24 | 25 | 26 | 2 terminals, 2 nonterminals 27 | 2 grammar rules, 3 states 28 | -------------------------------------------------------------------------------- /lib/byacc-20130925/test/code_error.tab.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lileicc/swift/57c4a4cd065f1149f86f3d04402f8dbdce1ac5ff/lib/byacc-20130925/test/code_error.tab.h -------------------------------------------------------------------------------- /lib/byacc-20130925/test/code_error.y: -------------------------------------------------------------------------------- 1 | %{ 2 | 3 | #ifdef YYBISON 4 | int yylex(void); 5 | static void yyerror(const char *); 6 | #endif 7 | 8 | %} 9 | %% 10 | S: error 11 | %% 12 | 13 | #include 14 | 15 | #ifdef YYBYACC 16 | extern int YYLEX_DECL(); 17 | #endif 18 | 19 | int 20 | main(void) 21 | { 22 | printf("yyparse() = %d\n", yyparse()); 23 | return 0; 24 | } 25 | 26 | int 27 | yylex(void) 28 | { 29 | return -1; 30 | } 31 | 32 | static void 33 | yyerror(const char* s) 34 | { 35 | printf("%s\n", s); 36 | } 37 | -------------------------------------------------------------------------------- /lib/byacc-20130925/test/error.output: -------------------------------------------------------------------------------- 1 | 0 $accept : S $end 2 | 3 | 1 S : error 4 | 5 | state 0 6 | $accept : . S $end (0) 7 | 8 | error shift 1 9 | . error 10 | 11 | S goto 2 12 | 13 | 14 | state 1 15 | S : error . (1) 16 | 17 | . reduce 1 18 | 19 | 20 | state 2 21 | $accept : S . $end (0) 22 | 23 | $end accept 24 | 25 | 26 | 2 terminals, 2 nonterminals 27 | 2 grammar rules, 3 states 28 | -------------------------------------------------------------------------------- /lib/byacc-20130925/test/error.tab.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lileicc/swift/57c4a4cd065f1149f86f3d04402f8dbdce1ac5ff/lib/byacc-20130925/test/error.tab.h -------------------------------------------------------------------------------- /lib/byacc-20130925/test/error.y: -------------------------------------------------------------------------------- 1 | %{ 2 | int yylex(void); 3 | static void yyerror(const char *); 4 | %} 5 | %% 6 | S: error 7 | %% 8 | 9 | #include 10 | 11 | int 12 | main(void) 13 | { 14 | printf("yyparse() = %d\n", yyparse()); 15 | return 0; 16 | } 17 | 18 | int 19 | yylex(void) 20 | { 21 | return -1; 22 | } 23 | 24 | static void 25 | yyerror(const char* s) 26 | { 27 | printf("%s\n", s); 28 | } 29 | -------------------------------------------------------------------------------- /lib/byacc-20130925/test/pure_calc.tab.h: -------------------------------------------------------------------------------- 1 | #define DIGIT 257 2 | #define LETTER 258 3 | #define UMINUS 259 4 | -------------------------------------------------------------------------------- /lib/byacc-20130925/test/pure_error.output: -------------------------------------------------------------------------------- 1 | 0 $accept : S $end 2 | 3 | 1 S : error 4 | 5 | state 0 6 | $accept : . S $end (0) 7 | 8 | error shift 1 9 | . error 10 | 11 | S goto 2 12 | 13 | 14 | state 1 15 | S : error . (1) 16 | 17 | . reduce 1 18 | 19 | 20 | state 2 21 | $accept : S . $end (0) 22 | 23 | $end accept 24 | 25 | 26 | 2 terminals, 2 nonterminals 27 | 2 grammar rules, 3 states 28 | -------------------------------------------------------------------------------- /lib/byacc-20130925/test/pure_error.tab.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lileicc/swift/57c4a4cd065f1149f86f3d04402f8dbdce1ac5ff/lib/byacc-20130925/test/pure_error.tab.h -------------------------------------------------------------------------------- /lib/byacc-20130925/test/pure_error.y: -------------------------------------------------------------------------------- 1 | %{ 2 | 3 | #ifdef YYBISON 4 | #define YYSTYPE int 5 | #define YYLEX_PARAM &yylval 6 | #define YYLEX_DECL() yylex(YYSTYPE *yylval) 7 | #define YYERROR_DECL() yyerror(const char *s) 8 | int YYLEX_DECL(); 9 | static void YYERROR_DECL(); 10 | #endif 11 | 12 | %} 13 | 14 | %% 15 | S: error 16 | %% 17 | 18 | #include 19 | 20 | #ifdef YYBYACC 21 | extern int YYLEX_DECL(); 22 | #endif 23 | 24 | int 25 | main(void) 26 | { 27 | printf("yyparse() = %d\n", yyparse()); 28 | return 0; 29 | } 30 | 31 | int 32 | yylex(YYSTYPE *value) 33 | { 34 | return value ? 0 : -1; 35 | } 36 | 37 | static void 38 | yyerror(const char* s) 39 | { 40 | printf("%s\n", s); 41 | } 42 | -------------------------------------------------------------------------------- /lib/byacc-20130925/test/quote_calc-s.tab.h: -------------------------------------------------------------------------------- 1 | #define OP_ADD 257 2 | #define OP_SUB 259 3 | #define OP_MUL 261 4 | #define OP_DIV 263 5 | #define OP_MOD 265 6 | #define OP_AND 267 7 | #define DIGIT 269 8 | #define LETTER 270 9 | #define UMINUS 271 10 | -------------------------------------------------------------------------------- /lib/byacc-20130925/test/quote_calc.tab.h: -------------------------------------------------------------------------------- 1 | #define OP_ADD 257 2 | #define ADD 258 3 | #define OP_SUB 259 4 | #define SUB 260 5 | #define OP_MUL 261 6 | #define MUL 262 7 | #define OP_DIV 263 8 | #define DIV 264 9 | #define OP_MOD 265 10 | #define MOD 266 11 | #define OP_AND 267 12 | #define AND 268 13 | #define DIGIT 269 14 | #define LETTER 270 15 | #define UMINUS 271 16 | -------------------------------------------------------------------------------- /lib/byacc-20130925/test/quote_calc2-s.tab.h: -------------------------------------------------------------------------------- 1 | #define OP_ADD 257 2 | #define OP_SUB 259 3 | #define OP_MUL 261 4 | #define OP_DIV 263 5 | #define OP_MOD 265 6 | #define OP_AND 267 7 | #define DIGIT 269 8 | #define LETTER 270 9 | #define UMINUS 271 10 | -------------------------------------------------------------------------------- /lib/byacc-20130925/test/quote_calc2.tab.h: -------------------------------------------------------------------------------- 1 | #define OP_ADD 257 2 | #define ADD 258 3 | #define OP_SUB 259 4 | #define SUB 260 5 | #define OP_MUL 261 6 | #define MUL 262 7 | #define OP_DIV 263 8 | #define DIV 264 9 | #define OP_MOD 265 10 | #define MOD 266 11 | #define OP_AND 267 12 | #define AND 268 13 | #define DIGIT 269 14 | #define LETTER 270 15 | #define UMINUS 271 16 | -------------------------------------------------------------------------------- /lib/byacc-20130925/test/quote_calc3-s.tab.h: -------------------------------------------------------------------------------- 1 | #define OP_ADD 257 2 | #define OP_SUB 259 3 | #define OP_MUL 261 4 | #define OP_DIV 263 5 | #define OP_MOD 265 6 | #define OP_AND 267 7 | #define DIGIT 269 8 | #define LETTER 270 9 | #define UMINUS 271 10 | -------------------------------------------------------------------------------- /lib/byacc-20130925/test/quote_calc3.tab.h: -------------------------------------------------------------------------------- 1 | #define OP_ADD 257 2 | #define OP_SUB 259 3 | #define OP_MUL 261 4 | #define OP_DIV 263 5 | #define OP_MOD 265 6 | #define OP_AND 267 7 | #define DIGIT 269 8 | #define LETTER 270 9 | #define UMINUS 271 10 | -------------------------------------------------------------------------------- /lib/byacc-20130925/test/quote_calc4-s.tab.h: -------------------------------------------------------------------------------- 1 | #define OP_ADD 257 2 | #define OP_SUB 259 3 | #define OP_MUL 261 4 | #define OP_DIV 263 5 | #define OP_MOD 265 6 | #define OP_AND 267 7 | #define DIGIT 269 8 | #define LETTER 270 9 | #define UMINUS 271 10 | -------------------------------------------------------------------------------- /lib/byacc-20130925/test/quote_calc4.tab.h: -------------------------------------------------------------------------------- 1 | #define OP_ADD 257 2 | #define OP_SUB 259 3 | #define OP_MUL 261 4 | #define OP_DIV 263 5 | #define OP_MOD 265 6 | #define OP_AND 267 7 | #define DIGIT 269 8 | #define LETTER 270 9 | #define UMINUS 271 10 | -------------------------------------------------------------------------------- /lib/byacc-20130925/test/run_lint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # $Id: run_lint.sh,v 1.1 2010/06/08 09:00:58 tom Exp $ 3 | # vi:ts=4 sw=4: 4 | 5 | # run lint on each of the ".c" files in the test directory 6 | 7 | if test $# = 1 8 | then 9 | PROG_DIR=`pwd` 10 | TEST_DIR=$1 11 | else 12 | PROG_DIR=.. 13 | TEST_DIR=. 14 | fi 15 | 16 | echo '** '`date` 17 | for i in ${TEST_DIR}/*.c 18 | do 19 | make -f $PROG_DIR/makefile lint C_FILES=$i srcdir=$PROG_DIR 20 | done 21 | -------------------------------------------------------------------------------- /lib/flex-2.5.37/.indent.pro: -------------------------------------------------------------------------------- 1 | --blank-lines-after-declarations 2 | --blank-lines-after-procedures 3 | -br /* open braces on same line */ 4 | -nce /* start else on new line */ 5 | -nbc /* vars on same line */ 6 | -di8 /* line up var decl at col 8 */ 7 | -brs /* struct brace on same line */ 8 | -i8 /* indent 4 */ 9 | -lp /* line up parens */ 10 | -ts8 /* tab stop */ 11 | -bbo /* break before && || */ 12 | -hnl /* honor newlines */ 13 | --space-special-semicolon 14 | --line-length75 15 | --dont-break-procedure-type 16 | -------------------------------------------------------------------------------- /lib/flex-2.5.37/AUTHORS: -------------------------------------------------------------------------------- 1 | 2 | In 2001, Will Estes took over as maintainer of flex. 3 | 4 | John Millaway is a co-author of the current version of flex. He has 5 | contributed a large number of new features, fixed a large number of 6 | outstanding bugs and has made significant contributions to the flex 7 | documentation. 8 | 9 | Aaron Stone has contributed several bug fixes to the flex codebase. 10 | 11 | Vern Paxson wrote flex with the help of many ideas and much 12 | inspiration from Van Jacobson. Original version by Jef Poskanzer. 13 | 14 | The fast table representation is a partial implementation of a design 15 | done by Van Jacobson. The implementation was done by Kevin Gong and 16 | Vern Paxson. 17 | -------------------------------------------------------------------------------- /lib/flex-2.5.37/README-alpha: -------------------------------------------------------------------------------- 1 | Beta versions and cvs snapshots of flex can be had at 2 | ftp://ftp.uncg.edu/people/wlestes/. 3 | -------------------------------------------------------------------------------- /lib/flex-2.5.37/doc/Makefile.am: -------------------------------------------------------------------------------- 1 | help2man = @HELP2MAN@ 2 | 3 | info_TEXINFOS = flex.texi 4 | dist_man_MANS = flex.1 5 | dist_doc_DATA= flex.pdf 6 | 7 | CLEANFILES = \ 8 | flex.hks \ 9 | flex.ops 10 | 11 | $(dist_man_MANS): $(top_srcdir)/main.c 12 | for i in $(dist_man_MANS) ; do \ 13 | $(help2man) --name='$(PACKAGE_NAME)' \ 14 | --section=`echo $$i | sed -e 's/.*\.\([^.]*\)$$/\1/'` \ 15 | ../flex$(EXEEXT) > $$i || rm -f $$i ; \ 16 | done 17 | -------------------------------------------------------------------------------- /lib/flex-2.5.37/doc/flex.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lileicc/swift/57c4a4cd065f1149f86f3d04402f8dbdce1ac5ff/lib/flex-2.5.37/doc/flex.pdf -------------------------------------------------------------------------------- /lib/flex-2.5.37/doc/stamp-vti: -------------------------------------------------------------------------------- 1 | @set UPDATED 22 July 2012 2 | @set UPDATED-MONTH July 2012 3 | @set EDITION 2.5.37 4 | @set VERSION 2.5.37 5 | -------------------------------------------------------------------------------- /lib/flex-2.5.37/doc/version.texi: -------------------------------------------------------------------------------- 1 | @set UPDATED 22 July 2012 2 | @set UPDATED-MONTH July 2012 3 | @set EDITION 2.5.37 4 | @set VERSION 2.5.37 5 | -------------------------------------------------------------------------------- /lib/flex-2.5.37/examples/README: -------------------------------------------------------------------------------- 1 | This directory contains some examples of what you can do with 2 | flex. These files are not tested regularly so you might have to tinker 3 | a bit before they work for you. Updates, new files and patches are welcome. 4 | 5 | - debflex.awk, an awk script for anotating flex debug output. 6 | It presently only works with gawk and mawk, not with "old" 7 | or "new" awk. 8 | 9 | - testxxLexer.l, a sample C++ program that uses flex's scanner 10 | class option ("-+"). 11 | 12 | - fastwc/, a subdirectory containing examples of how to use flex 13 | to write progressively higher-performance versions of the Unix 14 | "wc" utility. This certainly should work with 2.5, but hasn't 15 | been tested. 16 | -------------------------------------------------------------------------------- /lib/flex-2.5.37/examples/fastwc/mywc.c: -------------------------------------------------------------------------------- 1 | /* A simple but fairly efficient C version of the Unix "wc" tool */ 2 | 3 | #include 4 | #include 5 | 6 | main() 7 | { 8 | register int c, cc = 0, wc = 0, lc = 0; 9 | FILE *f = stdin; 10 | 11 | while ((c = getc(f)) != EOF) { 12 | ++cc; 13 | if (isgraph(c)) { 14 | ++wc; 15 | do { 16 | c = getc(f); 17 | if (c == EOF) 18 | goto done; 19 | ++cc; 20 | } while (isgraph(c)); 21 | } 22 | if (c == '\n') 23 | ++lc; 24 | } 25 | done: printf( "%8d%8d%8d\n", lc, wc, cc ); 26 | } 27 | -------------------------------------------------------------------------------- /lib/flex-2.5.37/examples/fastwc/wc1.l: -------------------------------------------------------------------------------- 1 | /* First cut at a flex-based "wc" tool. */ 2 | 3 | ws [ \t] 4 | nonws [^ \t\n] 5 | 6 | %option main noyywrap 7 | %% 8 | int cc = 0, wc = 0, lc = 0; 9 | 10 | {nonws}+ cc += yyleng; ++wc; 11 | 12 | {ws}+ cc += yyleng; 13 | 14 | \n ++lc; ++cc; 15 | 16 | <> { 17 | printf( "%8d %8d %8d\n", lc, wc, cc ); 18 | yyterminate(); 19 | } 20 | -------------------------------------------------------------------------------- /lib/flex-2.5.37/examples/fastwc/wc2.l: -------------------------------------------------------------------------------- 1 | /* Somewhat faster "wc" tool: match more text with each rule */ 2 | 3 | ws [ \t] 4 | nonws [^ \t\n] 5 | word {ws}*{nonws}+ 6 | 7 | %option main noyywrap 8 | %% 9 | int cc = 0, wc = 0, lc = 0; 10 | 11 | {word}{ws}* cc += yyleng; ++wc; 12 | {word}{ws}*\n cc += yyleng; ++wc; ++lc; 13 | 14 | {ws}+ cc += yyleng; 15 | 16 | \n+ cc += yyleng; lc += yyleng; 17 | 18 | <> { 19 | printf( "%8d %8d %8d\n", lc, wc, cc ); 20 | yyterminate(); 21 | } 22 | -------------------------------------------------------------------------------- /lib/flex-2.5.37/examples/fastwc/wc3.l: -------------------------------------------------------------------------------- 1 | /* Somewhat faster still: potentially match a lot of text with each rule */ 2 | 3 | ws [ \t] 4 | nonws [^ \t\n] 5 | word {ws}*{nonws}+ 6 | words {word}{ws}+ 7 | 8 | %option main noyywrap 9 | %% 10 | int cc = 0, wc = 0, lc = 0; 11 | 12 | {word}{ws}* cc += yyleng; ++wc; 13 | {word}{ws}*\n cc += yyleng; ++wc; ++lc; 14 | {words}{word}{ws}* cc += yyleng; wc += 2; 15 | {words}{2}{word}{ws}* cc += yyleng; wc += 3; 16 | {words}{3}{word}{ws}* cc += yyleng; wc += 4; 17 | 18 | {ws}+ cc += yyleng; 19 | 20 | \n+ cc += yyleng; lc += yyleng; 21 | 22 | <> { 23 | printf( "%8d %8d %8d\n", lc, wc, cc ); 24 | yyterminate(); 25 | } 26 | -------------------------------------------------------------------------------- /lib/flex-2.5.37/examples/fastwc/wc5.l: -------------------------------------------------------------------------------- 1 | /* Oops; slight change from wc3.l introduces backtracking */ 2 | 3 | ws [ \t] 4 | nonws [^ \t\n] 5 | word {ws}*{nonws}+ 6 | words {word}{ws}+ 7 | 8 | %option main noyywrap 9 | %% 10 | int cc = 0, wc = 0, lc = 0; 11 | 12 | {word}{ws}* cc += yyleng; ++wc; 13 | {word}{ws}*\n cc += yyleng; ++wc; ++lc; 14 | {words}{word} cc += yyleng; wc += 2; /* oops */ 15 | {words}{2}{word}{ws}* cc += yyleng; wc += 3; 16 | {words}{3}{word}{ws}* cc += yyleng; wc += 4; 17 | 18 | {ws}+ cc += yyleng; 19 | 20 | \n+ cc += yyleng; lc += yyleng; 21 | 22 | <> { 23 | printf( "%8d %8d %8d\n", lc, wc, cc ); 24 | yyterminate(); 25 | } 26 | -------------------------------------------------------------------------------- /lib/flex-2.5.37/examples/manual/README: -------------------------------------------------------------------------------- 1 | This directory contains the example programs from the manual, and a 2 | few other things as well. To make all the programs, simply type "make 3 | -f Makefile.examples", and assuming you have flex and gcc, all will be 4 | well. 5 | 6 | To build the programs individually, type 7 | 8 | make -f Makefile.examples program_name 9 | 10 | For example: 11 | 12 | make -f Makefile.examples expr 13 | -------------------------------------------------------------------------------- /lib/flex-2.5.37/examples/manual/datetest.dat: -------------------------------------------------------------------------------- 1 | short 2 | 1989:12:23 3 | 1989:11:12 4 | 23:12:1989 5 | 11:12:1989 6 | 1989/12/23 7 | 1989/11/12 8 | 23/12/1989 9 | 11/12/1989 10 | 1989-12-23 11 | 1989-11-12 12 | 23-12-1989 13 | 11-12-1989 14 | long 15 | Friday the 5th of January, 1989 16 | Friday, 5th of January, 1989 17 | Friday, January 5th, 1989 18 | Fri, January 5th, 1989 19 | Fri, Jan 5th, 1989 20 | Fri, Jan 5, 1989 21 | FriJan 5, 1989 22 | FriJan5, 1989 23 | FriJan51989 24 | Jan51989 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /lib/flex-2.5.37/examples/manual/eof_test01.txt: -------------------------------------------------------------------------------- 1 | This is test file #1 2 | 3 | ------------------------------------------------- 4 | 5 | We will now include test #2 in a standard way. 6 | 7 | #include "eof_test02.txt" 8 | 9 | ------------------------------------------------- 10 | 11 | And now we will include test # 2 with a different 12 | format 13 | 14 | #include "eof_test02.txt" 15 | ------------------------------------------------- 16 | 17 | and this is the end of the test. 18 | -------------------------------------------------------------------------------- /lib/flex-2.5.37/examples/manual/eof_test02.txt: -------------------------------------------------------------------------------- 1 | INCLUDE #2 2 | 3 | This is the second file that will 4 | be included. 5 | 6 | >>> Foo are GNU? 7 | 8 | #include "eof_test03.txt" 9 | -------------------------------------------------------------------------------- /lib/flex-2.5.37/examples/manual/eof_test03.txt: -------------------------------------------------------------------------------- 1 | INCLUDE #3 2 | 3 | This is the third file that will 4 | be included. 5 | 6 | >>> echo "I am `whoami`!!" 7 | 8 | -------------------------------------------------------------------------------- /lib/flex-2.5.37/examples/manual/expr.lex: -------------------------------------------------------------------------------- 1 | /* 2 | * expr.lex : Scanner for a simple 3 | * expression parser. 4 | */ 5 | 6 | %{ 7 | #include "y.tab.h" 8 | 9 | %} 10 | 11 | %% 12 | 13 | [0-9]+ { yylval.val = atol(yytext); 14 | return(NUMBER); 15 | } 16 | [0-9]+\.[0-9]+ { 17 | sscanf(yytext,"%f",&yylval.val); 18 | return(NUMBER); 19 | } 20 | "+" return(PLUS); 21 | "-" return(MINUS); 22 | "*" return(MULT); 23 | "/" return(DIV); 24 | "^" return(EXPON); 25 | "(" return(LB); 26 | ")" return(RB); 27 | \n return(EOL); 28 | [\t ]* /* throw away whitespace */ 29 | . { yyerror("Illegal character"); 30 | return(EOL); 31 | } 32 | %% 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /lib/flex-2.5.37/examples/manual/myname.lex: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * myname.lex : A sample Flex program 4 | * that does token replacement. 5 | */ 6 | 7 | %% 8 | 9 | %NAME { printf("%s",getenv("LOGNAME")); } 10 | %HOST { printf("%s",getenv("HOST")); } 11 | %HOSTTYPE { printf("%s",getenv("HOSTTYPE"));} 12 | %HOME { printf("%s",getenv("HOME")); } 13 | 14 | %% 15 | 16 | -------------------------------------------------------------------------------- /lib/flex-2.5.37/examples/manual/myname.txt: -------------------------------------------------------------------------------- 1 | Hello, my name name is %NAME. Actually 2 | "%NAME" isn't my real name, it is the 3 | alias I use when I'm on %HOST, which 4 | is the %HOSTTYPE I use. My HOME 5 | directory is %HOME. 6 | 7 | -------------------------------------------------------------------------------- /lib/flex-2.5.37/examples/manual/myname2.lex: -------------------------------------------------------------------------------- 1 | /* 2 | * myname2.lex : A sample Flex program 3 | * that does token replacement. 4 | */ 5 | 6 | %{ 7 | #include 8 | %} 9 | 10 | %x STRING 11 | %% 12 | \" ECHO; BEGIN(STRING); 13 | [^\"\n]* ECHO; 14 | \" ECHO; BEGIN(INITIAL); 15 | 16 | %NAME { printf("%s",getenv("LOGNAME")); } 17 | %HOST { printf("%s",getenv("HOST")); } 18 | %HOSTTYPE { printf("%s",getenv("HOSTTYPE"));} 19 | %HOME { printf("%s",getenv("HOME")); } 20 | -------------------------------------------------------------------------------- /lib/flex-2.5.37/examples/manual/reject.lex: -------------------------------------------------------------------------------- 1 | /* 2 | * reject.lex: An example of REJECT and unput() 3 | * misuse. 4 | */ 5 | 6 | %% 7 | UNIX { 8 | unput('U'); unput('N'); unput('G'); unput('\0'); 9 | REJECT; 10 | } 11 | GNU printf("GNU is Not Unix!\n"); 12 | %% 13 | -------------------------------------------------------------------------------- /lib/flex-2.5.37/examples/manual/replace.lex: -------------------------------------------------------------------------------- 1 | /* 2 | * replace.lex : A simple filter for renaming 3 | * parts of flex of bison generated 4 | * scanners or parsers. 5 | */ 6 | 7 | %{ 8 | #include 9 | 10 | char lower_replace[1024]; 11 | char upper_replace[1024]; 12 | 13 | %} 14 | 15 | %% 16 | 17 | "yy" printf("%s",lower_replace); 18 | "YY" printf("%s",upper_replace); 19 | , ECHO; 20 | 21 | %% 22 | 23 | int main(int argc, char *argv[]) 24 | { 25 | if(argc < 2){ 26 | printf("Usage %s lower UPPER\n",argv[0]); 27 | exit(1); 28 | } 29 | strcpy(lower_replace,argv[1]); 30 | strcpy(upper_replace,argv[2]); 31 | yylex(); 32 | return(0); 33 | } 34 | -------------------------------------------------------------------------------- /lib/flex-2.5.37/examples/manual/unput.lex: -------------------------------------------------------------------------------- 1 | /* 2 | * unput.l : An example of what *not* 3 | * to do with unput(). 4 | */ 5 | 6 | 7 | %{ 8 | #include 9 | 10 | void putback_yytext(void); 11 | %} 12 | 13 | %% 14 | foobar putback_yytext(); 15 | raboof putback_yytext(); 16 | %% 17 | 18 | void putback_yytext(void) 19 | { 20 | int i; 21 | int l = strlen(yytext); 22 | char buffer[YY_BUF_SIZE]; 23 | 24 | strcpy(buffer,yytext); 25 | printf("Got: %s\n",yytext); 26 | for(i=0; i 4 | 5 | void user_action(void); 6 | 7 | #define YY_USER_ACTION user_action(); 8 | 9 | %} 10 | 11 | %% 12 | 13 | .* ECHO; 14 | \n ECHO; 15 | 16 | %% 17 | 18 | void user_action(void) 19 | { 20 | int loop; 21 | 22 | for(loop=0; loop 8 | 9 | void yyerror(char *message) 10 | { 11 | printf("Error: %s\n",message); 12 | } 13 | 14 | %} 15 | 16 | %x STRING 17 | 18 | %% 19 | \" BEGIN(STRING); 20 | 21 | [^\\\n"]* yymore(); 22 | <> yyerror("EOF in string."); BEGIN(INITIAL); 23 | \n yyerror("Unterminated string."); BEGIN(INITIAL); 24 | \\\n yymore(); 25 | \" { 26 | yytext[yyleng-1] = '\0'; 27 | printf("string = \"%s\"",yytext); BEGIN(INITIAL); 28 | } 29 | %% 30 | -------------------------------------------------------------------------------- /lib/flex-2.5.37/examples/manual/yymoretest.dat: -------------------------------------------------------------------------------- 1 | "This is a test \ 2 | of multi-line string \ 3 | scanning in flex. \ 4 | This may be breaking some law \ 5 | of usage though..." 6 | 7 | 8 | -------------------------------------------------------------------------------- /lib/flex-2.5.37/lib/Makefile.am: -------------------------------------------------------------------------------- 1 | noinst_LIBRARIES = libcompat.a 2 | libcompat_a_SOURCES = lib.c 3 | libcompat_a_LIBADD = $(LIBOBJS) 4 | 5 | -------------------------------------------------------------------------------- /lib/flex-2.5.37/lib/lib.c: -------------------------------------------------------------------------------- 1 | /* Since building an empty library could cause problems, we provide a 2 | * function to go into the library. We could make this non-trivial by 3 | * moving something that flex treats as a library function into this 4 | * directory. */ 5 | 6 | void do_nothing(){ return;} 7 | 8 | -------------------------------------------------------------------------------- /lib/flex-2.5.37/lib/malloc.c: -------------------------------------------------------------------------------- 1 | #include 2 | #undef malloc 3 | 4 | #include 5 | 6 | void *malloc (); 7 | 8 | /* Allocate an N-byte block of memory from the heap. 9 | If N is zero, allocate a 1-byte block. */ 10 | 11 | void * 12 | rpl_malloc (size_t n) 13 | { 14 | if (n == 0) 15 | n = 1; 16 | return malloc (n); 17 | } 18 | -------------------------------------------------------------------------------- /lib/flex-2.5.37/lib/realloc.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | #include 6 | 7 | void * rpl_realloc (void *p, size_t n) 8 | { 9 | void *result; 10 | 11 | if (n == 0) 12 | { 13 | n = 1; 14 | } 15 | 16 | if (p == NULL) 17 | { 18 | result = malloc (n); 19 | } 20 | else 21 | result = realloc (p, n); 22 | 23 | if (result == NULL) 24 | errno = ENOMEM; 25 | 26 | return result; 27 | } 28 | -------------------------------------------------------------------------------- /lib/flex-2.5.37/po/LINGUAS: -------------------------------------------------------------------------------- 1 | ca 2 | da 3 | de 4 | es 5 | fi 6 | fr 7 | ga 8 | ko 9 | nl 10 | pl 11 | pt_BR 12 | ro 13 | ru 14 | sv 15 | tr 16 | vi 17 | zh_CN 18 | -------------------------------------------------------------------------------- /lib/flex-2.5.37/po/POTFILES.in: -------------------------------------------------------------------------------- 1 | buf.c 2 | ccl.c 3 | dfa.c 4 | ecs.c 5 | gen.c 6 | libmain.c 7 | libyywrap.c 8 | main.c 9 | misc.c 10 | nfa.c 11 | options.c 12 | parse.y 13 | scan.l 14 | scanopt.c 15 | skel.c 16 | sym.c 17 | tblcmp.c 18 | yylex.c 19 | -------------------------------------------------------------------------------- /lib/flex-2.5.37/po/boldquot.sed: -------------------------------------------------------------------------------- 1 | s/"\([^"]*\)"/“\1”/g 2 | s/`\([^`']*\)'/‘\1’/g 3 | s/ '\([^`']*\)' / ‘\1’ /g 4 | s/ '\([^`']*\)'$/ ‘\1’/g 5 | s/^'\([^`']*\)' /‘\1’ /g 6 | s/“”/""/g 7 | s/“/“/g 8 | s/”/”/g 9 | s/‘/‘/g 10 | s/’/’/g 11 | -------------------------------------------------------------------------------- /lib/flex-2.5.37/po/ca.gmo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lileicc/swift/57c4a4cd065f1149f86f3d04402f8dbdce1ac5ff/lib/flex-2.5.37/po/ca.gmo -------------------------------------------------------------------------------- /lib/flex-2.5.37/po/da.gmo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lileicc/swift/57c4a4cd065f1149f86f3d04402f8dbdce1ac5ff/lib/flex-2.5.37/po/da.gmo -------------------------------------------------------------------------------- /lib/flex-2.5.37/po/da.po: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lileicc/swift/57c4a4cd065f1149f86f3d04402f8dbdce1ac5ff/lib/flex-2.5.37/po/da.po -------------------------------------------------------------------------------- /lib/flex-2.5.37/po/de.gmo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lileicc/swift/57c4a4cd065f1149f86f3d04402f8dbdce1ac5ff/lib/flex-2.5.37/po/de.gmo -------------------------------------------------------------------------------- /lib/flex-2.5.37/po/es.gmo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lileicc/swift/57c4a4cd065f1149f86f3d04402f8dbdce1ac5ff/lib/flex-2.5.37/po/es.gmo -------------------------------------------------------------------------------- /lib/flex-2.5.37/po/es.po: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lileicc/swift/57c4a4cd065f1149f86f3d04402f8dbdce1ac5ff/lib/flex-2.5.37/po/es.po -------------------------------------------------------------------------------- /lib/flex-2.5.37/po/fi.gmo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lileicc/swift/57c4a4cd065f1149f86f3d04402f8dbdce1ac5ff/lib/flex-2.5.37/po/fi.gmo -------------------------------------------------------------------------------- /lib/flex-2.5.37/po/fr.gmo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lileicc/swift/57c4a4cd065f1149f86f3d04402f8dbdce1ac5ff/lib/flex-2.5.37/po/fr.gmo -------------------------------------------------------------------------------- /lib/flex-2.5.37/po/ga.gmo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lileicc/swift/57c4a4cd065f1149f86f3d04402f8dbdce1ac5ff/lib/flex-2.5.37/po/ga.gmo -------------------------------------------------------------------------------- /lib/flex-2.5.37/po/insert-header.sin: -------------------------------------------------------------------------------- 1 | # Sed script that inserts the file called HEADER before the header entry. 2 | # 3 | # At each occurrence of a line starting with "msgid ", we execute the following 4 | # commands. At the first occurrence, insert the file. At the following 5 | # occurrences, do nothing. The distinction between the first and the following 6 | # occurrences is achieved by looking at the hold space. 7 | /^msgid /{ 8 | x 9 | # Test if the hold space is empty. 10 | s/m/m/ 11 | ta 12 | # Yes it was empty. First occurrence. Read the file. 13 | r HEADER 14 | # Output the file's contents by reading the next line. But don't lose the 15 | # current line while doing this. 16 | g 17 | N 18 | bb 19 | :a 20 | # The hold space was nonempty. Following occurrences. Do nothing. 21 | x 22 | :b 23 | } 24 | -------------------------------------------------------------------------------- /lib/flex-2.5.37/po/ko.gmo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lileicc/swift/57c4a4cd065f1149f86f3d04402f8dbdce1ac5ff/lib/flex-2.5.37/po/ko.gmo -------------------------------------------------------------------------------- /lib/flex-2.5.37/po/ko.po: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lileicc/swift/57c4a4cd065f1149f86f3d04402f8dbdce1ac5ff/lib/flex-2.5.37/po/ko.po -------------------------------------------------------------------------------- /lib/flex-2.5.37/po/nl.gmo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lileicc/swift/57c4a4cd065f1149f86f3d04402f8dbdce1ac5ff/lib/flex-2.5.37/po/nl.gmo -------------------------------------------------------------------------------- /lib/flex-2.5.37/po/pl.gmo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lileicc/swift/57c4a4cd065f1149f86f3d04402f8dbdce1ac5ff/lib/flex-2.5.37/po/pl.gmo -------------------------------------------------------------------------------- /lib/flex-2.5.37/po/pl.po: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lileicc/swift/57c4a4cd065f1149f86f3d04402f8dbdce1ac5ff/lib/flex-2.5.37/po/pl.po -------------------------------------------------------------------------------- /lib/flex-2.5.37/po/pt_BR.gmo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lileicc/swift/57c4a4cd065f1149f86f3d04402f8dbdce1ac5ff/lib/flex-2.5.37/po/pt_BR.gmo -------------------------------------------------------------------------------- /lib/flex-2.5.37/po/pt_BR.po: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lileicc/swift/57c4a4cd065f1149f86f3d04402f8dbdce1ac5ff/lib/flex-2.5.37/po/pt_BR.po -------------------------------------------------------------------------------- /lib/flex-2.5.37/po/quot.sed: -------------------------------------------------------------------------------- 1 | s/"\([^"]*\)"/“\1”/g 2 | s/`\([^`']*\)'/‘\1’/g 3 | s/ '\([^`']*\)' / ‘\1’ /g 4 | s/ '\([^`']*\)'$/ ‘\1’/g 5 | s/^'\([^`']*\)' /‘\1’ /g 6 | s/“”/""/g 7 | -------------------------------------------------------------------------------- /lib/flex-2.5.37/po/remove-potcdate.sin: -------------------------------------------------------------------------------- 1 | # Sed script that remove the POT-Creation-Date line in the header entry 2 | # from a POT file. 3 | # 4 | # The distinction between the first and the following occurrences of the 5 | # pattern is achieved by looking at the hold space. 6 | /^"POT-Creation-Date: .*"$/{ 7 | x 8 | # Test if the hold space is empty. 9 | s/P/P/ 10 | ta 11 | # Yes it was empty. First occurrence. Remove the line. 12 | g 13 | d 14 | bb 15 | :a 16 | # The hold space was nonempty. Following occurrences. Do nothing. 17 | x 18 | :b 19 | } 20 | -------------------------------------------------------------------------------- /lib/flex-2.5.37/po/ro.gmo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lileicc/swift/57c4a4cd065f1149f86f3d04402f8dbdce1ac5ff/lib/flex-2.5.37/po/ro.gmo -------------------------------------------------------------------------------- /lib/flex-2.5.37/po/ro.po: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lileicc/swift/57c4a4cd065f1149f86f3d04402f8dbdce1ac5ff/lib/flex-2.5.37/po/ro.po -------------------------------------------------------------------------------- /lib/flex-2.5.37/po/ru.gmo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lileicc/swift/57c4a4cd065f1149f86f3d04402f8dbdce1ac5ff/lib/flex-2.5.37/po/ru.gmo -------------------------------------------------------------------------------- /lib/flex-2.5.37/po/ru.po: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lileicc/swift/57c4a4cd065f1149f86f3d04402f8dbdce1ac5ff/lib/flex-2.5.37/po/ru.po -------------------------------------------------------------------------------- /lib/flex-2.5.37/po/stamp-po: -------------------------------------------------------------------------------- 1 | timestamp 2 | -------------------------------------------------------------------------------- /lib/flex-2.5.37/po/sv.gmo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lileicc/swift/57c4a4cd065f1149f86f3d04402f8dbdce1ac5ff/lib/flex-2.5.37/po/sv.gmo -------------------------------------------------------------------------------- /lib/flex-2.5.37/po/sv.po: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lileicc/swift/57c4a4cd065f1149f86f3d04402f8dbdce1ac5ff/lib/flex-2.5.37/po/sv.po -------------------------------------------------------------------------------- /lib/flex-2.5.37/po/tr.gmo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lileicc/swift/57c4a4cd065f1149f86f3d04402f8dbdce1ac5ff/lib/flex-2.5.37/po/tr.gmo -------------------------------------------------------------------------------- /lib/flex-2.5.37/po/vi.gmo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lileicc/swift/57c4a4cd065f1149f86f3d04402f8dbdce1ac5ff/lib/flex-2.5.37/po/vi.gmo -------------------------------------------------------------------------------- /lib/flex-2.5.37/po/zh_CN.gmo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lileicc/swift/57c4a4cd065f1149f86f3d04402f8dbdce1ac5ff/lib/flex-2.5.37/po/zh_CN.gmo -------------------------------------------------------------------------------- /lib/flex-2.5.37/po/zh_CN.po: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lileicc/swift/57c4a4cd065f1149f86f3d04402f8dbdce1ac5ff/lib/flex-2.5.37/po/zh_CN.po -------------------------------------------------------------------------------- /lib/flex-2.5.37/tests/TEMPLATE/test.input: -------------------------------------------------------------------------------- 1 | 0000 foo 1111 foo 0000 bar 2 | 0000 foo 1111 foo 0000 bar 3 | -------------------------------------------------------------------------------- /lib/flex-2.5.37/tests/create-test: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | TESTFILES="Makefile.am scanner.l parser.y .cvsignore test.input" 4 | 5 | if [ ! $# -eq 1 ] ; then 6 | echo 1>&2 Usage: $0 test-name 7 | exit 1 8 | fi 9 | 10 | if test -e "$1" ; then 11 | echo 1>&2 "$1 exists already" 12 | exit 1 13 | fi 14 | 15 | mkdir $1 16 | if test "$?" -ne 0 ; then 17 | echo 1>&2 "mkdir $1 failed" 18 | exit 1 19 | fi 20 | 21 | for i in $TESTFILES ; do 22 | cp TEMPLATE/$i $1/$i 23 | done 24 | 25 | echo "$1" >> "$1"/.cvsignore 26 | 27 | sed -i '/--new-test-here--/i\ 28 | tests/'"$1"'/Makefile' ../configure.in 29 | 30 | sed -i '/^\(DIST_\)\?SUBDIRS/a\ 31 | '"$1"' \\' Makefile.am 32 | 33 | sed -i "s:TEMPLATE:$1:g" "$1"/Makefile.am 34 | -------------------------------------------------------------------------------- /lib/flex-2.5.37/tests/test-array-nr/test.input: -------------------------------------------------------------------------------- 1 | 0000 foo 1111 foo 0000 bar 2 | 0000 foo 1111 foo 0000 bar 3 | -------------------------------------------------------------------------------- /lib/flex-2.5.37/tests/test-array-r/test.input: -------------------------------------------------------------------------------- 1 | 0000 foo 1111 foo 0000 bar 2 | 0000 foo 1111 foo 0000 bar 3 | -------------------------------------------------------------------------------- /lib/flex-2.5.37/tests/test-basic-nr/test.input: -------------------------------------------------------------------------------- 1 | # this is a comment 2 | foo = "bar" 3 | num = 43 4 | setting = false 5 | 6 | -------------------------------------------------------------------------------- /lib/flex-2.5.37/tests/test-basic-r/test.input: -------------------------------------------------------------------------------- 1 | # this is a comment 2 | foo = "bar" 3 | num = 43 4 | setting = false 5 | -------------------------------------------------------------------------------- /lib/flex-2.5.37/tests/test-bison-nr/test.input: -------------------------------------------------------------------------------- 1 | 0001: FIRSTNAME=firstname 2 | 0002: MIDDLENAME=middle 3 | 0003: LASTNAME=lastname 4 | 0004: ADDRESS=address 5 | -------------------------------------------------------------------------------- /lib/flex-2.5.37/tests/test-bison-yylloc/test.input: -------------------------------------------------------------------------------- 1 | 0001: FIRSTNAME=firstname 2 | 0002: MIDDLENAME=middle 3 | 0003: LASTNAME=lastname 4 | 0004: ADDRESS=address 5 | -------------------------------------------------------------------------------- /lib/flex-2.5.37/tests/test-bison-yylval/test.input: -------------------------------------------------------------------------------- 1 | 2 | 3 | This is a test 4 | 5 | 6 | -------------------------------------------------------------------------------- /lib/flex-2.5.37/tests/test-c++-basic/test.input: -------------------------------------------------------------------------------- 1 | 0000 foo 1111 foo 0000 bar 2 | 0000 foo 1111 foo 0000 bar 3 | -------------------------------------------------------------------------------- /lib/flex-2.5.37/tests/test-c++-multiple-scanners/test.input: -------------------------------------------------------------------------------- 1 | foo on bar off 2 | -------------------------------------------------------------------------------- /lib/flex-2.5.37/tests/test-c++-yywrap/test.input: -------------------------------------------------------------------------------- 1 | 0000 foo 1111 foo 0000 bar 2 | 0000 foo 1111 foo 0000 bar 3 | -------------------------------------------------------------------------------- /lib/flex-2.5.37/tests/test-c-cpp-nr/test.input: -------------------------------------------------------------------------------- 1 | 0000 foo 1111 foo 0000 bar 2 | 0000 foo 1111 foo 0000 bar 3 | -------------------------------------------------------------------------------- /lib/flex-2.5.37/tests/test-c-cpp-r/test.input: -------------------------------------------------------------------------------- 1 | 0000 foo 1111 foo 0000 bar 2 | 0000 foo 1111 foo 0000 bar 3 | -------------------------------------------------------------------------------- /lib/flex-2.5.37/tests/test-debug-nr/test.input: -------------------------------------------------------------------------------- 1 | Any input will do for this test. 2 | We are only testing if it actually runs in debug mode. 3 | -------------------------------------------------------------------------------- /lib/flex-2.5.37/tests/test-debug-r/test.input: -------------------------------------------------------------------------------- 1 | Any input will do for this test. 2 | We are only testing if it actually runs in debug mode. 3 | -------------------------------------------------------------------------------- /lib/flex-2.5.37/tests/test-extended/test.input: -------------------------------------------------------------------------------- 1 | abcdefghijklmnopqrstuvwxyz 2 | ABCD 3 | -------------------------------------------------------------------------------- /lib/flex-2.5.37/tests/test-header-nr/test.input: -------------------------------------------------------------------------------- 1 | Any input is ok for this scanner. 2 | We only care if it links. 3 | 4 | -------------------------------------------------------------------------------- /lib/flex-2.5.37/tests/test-header-r/test.input: -------------------------------------------------------------------------------- 1 | Any input is ok for this scanner. 2 | We only care if it links. 3 | 4 | -------------------------------------------------------------------------------- /lib/flex-2.5.37/tests/test-include-by-buffer/test-1.input: -------------------------------------------------------------------------------- 1 | Beginning of "test-1.input". 2 | #include 3 | End of "test-1.input". 4 | -------------------------------------------------------------------------------- /lib/flex-2.5.37/tests/test-include-by-buffer/test-2.input: -------------------------------------------------------------------------------- 1 | Beginning of "test-2.input". 2 | #include 3 | End of "test-2.input". 4 | -------------------------------------------------------------------------------- /lib/flex-2.5.37/tests/test-include-by-buffer/test-3.input: -------------------------------------------------------------------------------- 1 | Beginning of "test-3.input". 2 | End of "test-3.input". 3 | -------------------------------------------------------------------------------- /lib/flex-2.5.37/tests/test-include-by-push/test-1.input: -------------------------------------------------------------------------------- 1 | Beginning of "test-1.input". 2 | #include 3 | End of "test-1.input". 4 | -------------------------------------------------------------------------------- /lib/flex-2.5.37/tests/test-include-by-push/test-2.input: -------------------------------------------------------------------------------- 1 | Beginning of "test-2.input". 2 | #include 3 | End of "test-2.input". 4 | -------------------------------------------------------------------------------- /lib/flex-2.5.37/tests/test-include-by-push/test-3.input: -------------------------------------------------------------------------------- 1 | Beginning of "test-3.input". 2 | End of "test-3.input". 3 | -------------------------------------------------------------------------------- /lib/flex-2.5.37/tests/test-include-by-reentrant/test-1.input: -------------------------------------------------------------------------------- 1 | Beginning of "test-1.input". 2 | #include 3 | End of "test-1.input". 4 | -------------------------------------------------------------------------------- /lib/flex-2.5.37/tests/test-include-by-reentrant/test-2.input: -------------------------------------------------------------------------------- 1 | Beginning of "test-2.input". 2 | #include 3 | End of "test-2.input". 4 | -------------------------------------------------------------------------------- /lib/flex-2.5.37/tests/test-include-by-reentrant/test-3.input: -------------------------------------------------------------------------------- 1 | Beginning of "test-3.input". 2 | End of "test-3.input". 3 | -------------------------------------------------------------------------------- /lib/flex-2.5.37/tests/test-linedir-r/check-lines.awk: -------------------------------------------------------------------------------- 1 | { 2 | if( /#line/ && $1 != ($3 - 1)) { 3 | printf "Line directive mismatch at line %d: %s\n", NR, $0; 4 | exit 1; 5 | } 6 | } 7 | 8 | -------------------------------------------------------------------------------- /lib/flex-2.5.37/tests/test-linedir-r/test.input: -------------------------------------------------------------------------------- 1 | Any input is ok for this scanner. 2 | We only care if it links. 3 | 4 | -------------------------------------------------------------------------------- /lib/flex-2.5.37/tests/test-lineno-nr/test.input: -------------------------------------------------------------------------------- 1 | These words 2 | are separated 3 | by newlines 4 | and sometimes 5 | spaces 6 | too. 7 | The next three lines are numbers with only intervening newlines 8 | 01123 9 | 581321 10 | 34 11 | And now for some blank lines.... 12 | 13 | 14 | Finally, we directly modify yylineno, but then change it back afterwards 15 | (see scanner.l): 16 | 17 | yylineno++ 18 | 19 | yylineno-- 20 | -------------------------------------------------------------------------------- /lib/flex-2.5.37/tests/test-lineno-r/test.input: -------------------------------------------------------------------------------- 1 | These words 2 | are separated 3 | by newlines 4 | and sometimes 5 | spaces 6 | too. 7 | The next three lines are numbers with only intervening newlines 8 | 01123 9 | 581321 10 | 34 11 | And now for some blank lines.... 12 | 13 | 14 | Finally, we directly modify yylineno, but then change it back afterwards 15 | (see scanner.l): 16 | 17 | yylineno++ 18 | 19 | yylineno-- 20 | -------------------------------------------------------------------------------- /lib/flex-2.5.37/tests/test-noansi-nr/test.input: -------------------------------------------------------------------------------- 1 | # this is a comment 2 | foo = "bar" 3 | num = 43 4 | setting = false 5 | 6 | -------------------------------------------------------------------------------- /lib/flex-2.5.37/tests/test-noansi-r/test.input: -------------------------------------------------------------------------------- 1 | # this is a comment 2 | foo = "bar" 3 | num = 43 4 | setting = false 5 | -------------------------------------------------------------------------------- /lib/flex-2.5.37/tests/test-prefix-nr/README: -------------------------------------------------------------------------------- 1 | This check is to make sure the prefix "yy" is substituted where it should be. 2 | 3 | -------------------------------------------------------------------------------- /lib/flex-2.5.37/tests/test-prefix-nr/test.input: -------------------------------------------------------------------------------- 1 | Dummy input. 2 | -------------------------------------------------------------------------------- /lib/flex-2.5.37/tests/test-prefix-r/README: -------------------------------------------------------------------------------- 1 | This check is to make sure the prefix "yy" is substituted where it should be. 2 | 3 | -------------------------------------------------------------------------------- /lib/flex-2.5.37/tests/test-prefix-r/test.input: -------------------------------------------------------------------------------- 1 | Dummy input. 2 | -------------------------------------------------------------------------------- /lib/flex-2.5.37/tests/test-quotes/test.input: -------------------------------------------------------------------------------- 1 | 0000 foo 1111 foo 0000 bar 2 | 0000 foo 1111 foo 0000 bar 3 | -------------------------------------------------------------------------------- /lib/flex-2.5.37/tests/test-reject/test.input: -------------------------------------------------------------------------------- 1 | 0000 foo 1111 foo 0000 bar 2 | 0000 foo 1111 foo 0000 bar 3 | -------------------------------------------------------------------------------- /lib/flex-2.5.37/tests/test-rescan-nr/test.input: -------------------------------------------------------------------------------- 1 | 0000 foo 1111 foo 0000 bar 2 | 0000 foo 1111 foo 0000 bar 3 | -------------------------------------------------------------------------------- /lib/flex-2.5.37/tests/test-rescan-r/test.input: -------------------------------------------------------------------------------- 1 | 0000 foo 1111 foo 0000 bar 2 | 0000 foo 1111 foo 0000 bar 3 | -------------------------------------------------------------------------------- /lib/flex-2.5.37/tests/test-table-opts/test.input: -------------------------------------------------------------------------------- 1 | 0000 foo 1111 foo 0000 bar foobar 2 | 0000 foo 1111 foo 0000 bar foobar 3 | -------------------------------------------------------------------------------- /lib/flex-2.5.37/tests/test-top/test.input: -------------------------------------------------------------------------------- 1 | Any input is ok for this scanner. 2 | We only care if it links. 3 | 4 | -------------------------------------------------------------------------------- /lib/flex-2.5.37/tools/Makefile.am: -------------------------------------------------------------------------------- 1 | EXTRA_DIST = \ 2 | git2cl 3 | 4 | -------------------------------------------------------------------------------- /lib/flex-2.5.37/version.h: -------------------------------------------------------------------------------- 1 | #define FLEX_VERSION VERSION 2 | -------------------------------------------------------------------------------- /runtests.bat: -------------------------------------------------------------------------------- 1 | for %%f in (src\test\parse\*.in) do ( 2 | parseex -i src\test\parse\%%~nf.in -o src\test\parse\%%~nf.tmp 3 | fc src\test\parse\%%~nf.out src\test\parse\%%~nf.tmp 4 | ) -------------------------------------------------------------------------------- /src/absyn/Absyn.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Absyn.cpp 3 | * 4 | * Created on: Oct 28, 2013 5 | * Author: leili 6 | */ 7 | 8 | #include "Absyn.h" 9 | 10 | namespace swift { 11 | namespace absyn { 12 | 13 | Absyn::Absyn(int l, int c) : 14 | line(l), col(c) { 15 | } 16 | 17 | Absyn::~Absyn() { 18 | // TODO Auto-generated destructor stub 19 | } 20 | 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/absyn/ArrayExpr.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ArrayExpr.h 3 | * 4 | * Created on: Oct 30, 2013 5 | * Author: yiwu 6 | */ 7 | 8 | #pragma once 9 | 10 | #include "Expr.h" 11 | 12 | namespace swift { 13 | namespace absyn { 14 | 15 | class ArrayExpr: public Expr { 16 | int dim; 17 | public: 18 | ArrayExpr(int l, int c, int dim = 1); 19 | virtual ~ArrayExpr(); 20 | 21 | int getDim(); 22 | void setDim(int d); 23 | 24 | // For Debugging Use 25 | void print(FILE* file, int indent); 26 | std::string toString(); 27 | 28 | Expr* clone(); 29 | }; 30 | 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/absyn/BoolLiteral.h: -------------------------------------------------------------------------------- 1 | /* 2 | * BoolLiteral.h 3 | * 4 | * Created on: Oct 29, 2013 5 | * Author: yiwu 6 | */ 7 | 8 | #pragma once 9 | 10 | #include "Literal.h" 11 | 12 | namespace swift { 13 | namespace absyn { 14 | 15 | class BoolLiteral: public Literal { 16 | bool value; 17 | public: 18 | BoolLiteral(int l, int c, bool value); 19 | virtual ~BoolLiteral(); 20 | 21 | bool getValue(); 22 | 23 | // For Debugging Use 24 | void print(FILE* file, int indent); 25 | std::string toString(); 26 | 27 | Expr* clone(); 28 | }; 29 | 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/absyn/CardinalityExpr.h: -------------------------------------------------------------------------------- 1 | /* 2 | * CardinalityExpr.h 3 | * 4 | * Created on: Oct 30, 2013 5 | * Author: yiwu 6 | */ 7 | 8 | #pragma once 9 | 10 | #include "Expr.h" 11 | 12 | namespace swift { 13 | namespace absyn { 14 | 15 | class CardinalityExpr: public Expr { 16 | public: 17 | CardinalityExpr(int l, int c, Expr* e); 18 | virtual ~CardinalityExpr(); 19 | 20 | // For Debugging Use 21 | void print(FILE* file, int indent); 22 | std::string toString(); 23 | 24 | Expr* clone(); 25 | }; 26 | 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/absyn/CaseExpr.h: -------------------------------------------------------------------------------- 1 | /* 2 | * CaseExpr.h 3 | * 4 | * Created on: July 12, 2014 5 | * Author: tejas 6 | */ 7 | 8 | #pragma once 9 | 10 | #include "MapExpr.h" 11 | 12 | namespace swift { 13 | namespace absyn { 14 | class CaseExpr: public Expr { 15 | public: 16 | CaseExpr(int l, int c, Expr* test, MapExpr* m); 17 | virtual ~CaseExpr(); 18 | 19 | Expr* getTest(); 20 | MapExpr* getMap(); 21 | 22 | // For Debugging Use 23 | void print(FILE *file, int indent); 24 | std::string toString(); 25 | 26 | Expr* clone(); 27 | }; 28 | 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/absyn/CondSet.h: -------------------------------------------------------------------------------- 1 | /* 2 | * CondSet.h 3 | * 4 | * Created on: Oct 31, 2013 5 | * Author: yiwu 6 | */ 7 | 8 | #pragma once 9 | 10 | #include "SetExpr.h" 11 | #include "VarDecl.h" 12 | 13 | namespace swift { 14 | namespace absyn { 15 | class CondSet: public SetExpr { 16 | public: 17 | CondSet(int l, int c, VarDecl var, Expr *cond = NULL); 18 | virtual ~CondSet(); 19 | 20 | Expr* getCond(); 21 | VarDecl& getVar(); 22 | 23 | void setCond(Expr* c); 24 | 25 | // For Debugging Use 26 | void print(FILE *file, int indent); 27 | std::string toString(); 28 | 29 | Expr* clone(); 30 | private: 31 | VarDecl var; 32 | }; 33 | 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/absyn/Decl.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Decl.cpp 3 | * 4 | * Created on: Oct 30, 2013 5 | * Author: yiwu 6 | */ 7 | 8 | #include "Decl.h" 9 | 10 | namespace swift { 11 | namespace absyn { 12 | 13 | Decl::Decl(int l, int c) : 14 | Stmt(l, c) { 15 | } 16 | 17 | Decl::~Decl() { 18 | } 19 | 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/absyn/Decl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Decl.h 3 | * 4 | * Created on: Oct 30, 2013 5 | * Author: yiwu 6 | */ 7 | 8 | #pragma once 9 | 10 | #include "Absyn.h" 11 | #include "Stmt.h" 12 | 13 | namespace swift { 14 | namespace absyn { 15 | class Decl: public Stmt { 16 | public: 17 | Decl(int l, int c); 18 | virtual ~Decl(); 19 | }; 20 | 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/absyn/DistinctDecl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * DistinctDecl.h 3 | * 4 | * Created on: Oct 30, 2013 5 | * Author: yiwu 6 | */ 7 | 8 | #pragma once 9 | 10 | #include 11 | 12 | #include "Decl.h" 13 | #include "Symbol.h" 14 | 15 | namespace swift { 16 | namespace absyn { 17 | 18 | class DistinctDecl: public Decl { 19 | Symbol typ; 20 | std::vector var; 21 | std::vector len; 22 | public: 23 | DistinctDecl(int l, int c, Symbol typ); 24 | virtual ~DistinctDecl(); 25 | 26 | size_t size(); 27 | const Symbol& getTyp(); 28 | const Symbol& getVar(int k); 29 | int getLen(int k); 30 | void add(Symbol v, int l = 1); 31 | 32 | // For Debugging Use 33 | void print(FILE* file, int indent); 34 | }; 35 | 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/absyn/DistrExpr.h: -------------------------------------------------------------------------------- 1 | /* 2 | * DistrExpr.h 3 | * 4 | * Created on: Oct 29, 2013 5 | * Author: yiwu 6 | */ 7 | 8 | #pragma once 9 | 10 | #include "Expr.h" 11 | #include "Symbol.h" 12 | 13 | namespace swift { 14 | namespace absyn { 15 | 16 | class DistrExpr: public Expr { 17 | Symbol distr; 18 | public: 19 | DistrExpr(int l, int c, Symbol distr); 20 | virtual ~DistrExpr(); 21 | 22 | const Symbol& getDistrName(); 23 | 24 | // For Debugging Use 25 | void print(FILE* file, int indent); 26 | std::string toString(); 27 | 28 | Expr* clone(); 29 | }; 30 | 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/absyn/DoubleLiteral.h: -------------------------------------------------------------------------------- 1 | /* 2 | * DoubleLiteral.h 3 | * 4 | * Created on: Oct 29, 2013 5 | * Author: yiwu 6 | */ 7 | 8 | #pragma once 9 | 10 | #include "Literal.h" 11 | 12 | namespace swift { 13 | namespace absyn { 14 | 15 | class DoubleLiteral: public Literal { 16 | double value; 17 | public: 18 | DoubleLiteral(int l, int c, double value); 19 | virtual ~DoubleLiteral(); 20 | 21 | double getValue(); 22 | 23 | // For Debugging Use 24 | void print(FILE* file, int indent); 25 | std::string toString(); 26 | 27 | Expr* clone(); 28 | }; 29 | 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/absyn/Expr.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Expr.h 3 | * 4 | * Created on: Oct 28, 2013 5 | * Author: leili 6 | */ 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | #include "Absyn.h" 13 | 14 | namespace swift { 15 | namespace absyn { 16 | 17 | class Expr: public Absyn { 18 | public: 19 | Expr(int l, int c); 20 | virtual ~Expr(); 21 | 22 | void add(Expr* e); 23 | void add_front(Expr* e); 24 | Expr* get(size_t id); 25 | std::vector& getAllExpr(); 26 | size_t size(); 27 | void clearArgs(); 28 | 29 | virtual std::string toString() = 0; 30 | virtual Expr* clone() = 0; 31 | 32 | protected: 33 | std::vector args; 34 | 35 | virtual void cloneArgs(); 36 | }; 37 | 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/absyn/FuncApp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * FuncApp.h 3 | * 4 | * Created on: Oct 29, 2013 5 | * Author: yiwu 6 | */ 7 | 8 | #pragma once 9 | 10 | #include "Expr.h" 11 | #include "Symbol.h" 12 | 13 | namespace swift { 14 | namespace absyn { 15 | 16 | class FuncApp: public Expr { 17 | Symbol func; 18 | public: 19 | FuncApp(int l, int c, Symbol func); 20 | virtual ~FuncApp(); 21 | 22 | const Symbol& getFuncName(); 23 | 24 | // For Debugging Use 25 | void print(FILE* file, int indent); 26 | std::string toString(); 27 | 28 | Expr* clone(); 29 | }; 30 | 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/absyn/IfExpr.h: -------------------------------------------------------------------------------- 1 | /* 2 | * IfExpr.h 3 | * 4 | * Created on: Oct 28, 2013 5 | * Author: leili 6 | */ 7 | 8 | #pragma once 9 | 10 | #include "Expr.h" 11 | 12 | namespace swift { 13 | namespace absyn { 14 | 15 | class IfExpr: public Expr { 16 | public: 17 | IfExpr(int l, int c, Expr* cond, Expr* then_clause, Expr* else_clause = NULL); 18 | virtual ~IfExpr(); 19 | 20 | Expr* getCond(); 21 | Expr* getThen(); 22 | Expr* getElse(); 23 | 24 | // For Debugging Use 25 | void print(FILE* file, int indent); 26 | std::string toString(); 27 | 28 | Expr* clone(); 29 | }; 30 | 31 | } 32 | } /* namespace swift */ 33 | -------------------------------------------------------------------------------- /src/absyn/IntLiteral.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * IntLiteral.cpp 3 | * 4 | * Created on: Oct 29, 2013 5 | * Author: yiwu 6 | */ 7 | 8 | #include "IntLiteral.h" 9 | 10 | namespace swift { 11 | namespace absyn { 12 | 13 | IntLiteral::IntLiteral(int l, int c, int value) : 14 | Literal(l, c), value(value) { 15 | } 16 | 17 | IntLiteral::~IntLiteral() { 18 | } 19 | 20 | int IntLiteral::getValue() { 21 | return value; 22 | } 23 | 24 | // For Debugging Use 25 | void IntLiteral::print(FILE* file, int indent) { 26 | fprintf(file, "%*s(IntLiteral: %d )\n", indent, "", value); 27 | } 28 | 29 | std::string IntLiteral::toString() { 30 | return std::to_string(value); 31 | } 32 | 33 | Expr* IntLiteral::clone() { 34 | return new IntLiteral(line, col, value); 35 | } 36 | 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/absyn/IntLiteral.h: -------------------------------------------------------------------------------- 1 | /* 2 | * IntLiteral.h 3 | * 4 | * Created on: Oct 29, 2013 5 | * Author: yiwu 6 | */ 7 | 8 | #pragma once 9 | 10 | #include "Literal.h" 11 | 12 | namespace swift { 13 | namespace absyn { 14 | 15 | class IntLiteral: public Literal { 16 | int value; 17 | public: 18 | IntLiteral(int l, int c, int value); 19 | virtual ~IntLiteral(); 20 | 21 | int getValue(); 22 | 23 | // For Debugging Use 24 | void print(FILE* file, int indent); 25 | std::string toString(); 26 | 27 | Expr* clone(); 28 | }; 29 | 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/absyn/ListSet.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ListSet.h 3 | * 4 | * Created on: Oct 31, 2013 5 | * Author: yiwu 6 | */ 7 | 8 | #pragma once 9 | 10 | #include "SetExpr.h" 11 | 12 | namespace swift { 13 | namespace absyn { 14 | 15 | class ListSet: public SetExpr { 16 | public: 17 | ListSet(int l, int c); 18 | virtual ~ListSet(); 19 | 20 | // For Debugging Use 21 | void print(FILE *file, int indent); 22 | std::string toString(); 23 | 24 | Expr* clone(); 25 | }; 26 | 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/absyn/Literal.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Literal.cpp 3 | * 4 | * Created on: Oct 29, 2013 5 | * Author: yiwu 6 | */ 7 | 8 | #include "Literal.h" 9 | 10 | namespace swift { 11 | namespace absyn { 12 | 13 | Literal::Literal(int l, int c) : 14 | Expr(l, c) { 15 | } 16 | 17 | Literal::~Literal() { 18 | } 19 | 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/absyn/Literal.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Literal.h 3 | * 4 | * Created on: Oct 29, 2013 5 | * Author: yiwu 6 | */ 7 | 8 | #pragma once 9 | 10 | #include "Expr.h" 11 | 12 | namespace swift { 13 | namespace absyn { 14 | 15 | class Literal: public Expr { 16 | public: 17 | Literal(int l, int c); 18 | virtual ~Literal(); 19 | }; 20 | 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/absyn/MapExpr.h: -------------------------------------------------------------------------------- 1 | /* 2 | * MapExpr.h 3 | * 4 | * Created on: Oct 29, 2013 5 | * Author: yiwu 6 | */ 7 | 8 | #pragma once 9 | 10 | #include "Expr.h" 11 | 12 | namespace swift { 13 | namespace absyn { 14 | 15 | class MapExpr: public Expr { 16 | public: 17 | MapExpr(int l, int c); 18 | virtual ~MapExpr(); 19 | 20 | size_t mapSize(); 21 | Expr* getFrom(size_t k); 22 | Expr* getTo(size_t k); 23 | void addMap(Expr* from, Expr* to); 24 | 25 | // For Debugging Use 26 | void print(FILE* file, int indent); 27 | std::string toString(); 28 | 29 | Expr* clone(); 30 | }; 31 | 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/absyn/NullLiteral.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * NullLiteral.cpp 3 | * 4 | * Created on: Oct 29, 2013 5 | * Author: yiwu 6 | */ 7 | 8 | #include "NullLiteral.h" 9 | 10 | namespace swift { 11 | namespace absyn { 12 | NullLiteral::NullLiteral(int l, int c) : 13 | Literal(l, c) { 14 | } 15 | 16 | NullLiteral::~NullLiteral() { 17 | } 18 | 19 | // For Debugging Use 20 | void NullLiteral::print(FILE* file, int indent) { 21 | fprintf(file, "%*s(NullLiteral: NULL )\n", indent, ""); 22 | } 23 | 24 | std::string NullLiteral::toString() { 25 | return "NULL"; 26 | } 27 | 28 | Expr* NullLiteral::clone() { 29 | return new NullLiteral(line, col); 30 | } 31 | 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/absyn/NullLiteral.h: -------------------------------------------------------------------------------- 1 | /* 2 | * NullLiteral.h 3 | * 4 | * Created on: Oct 29, 2013 5 | * Author: yiwu 6 | */ 7 | 8 | #pragma once 9 | 10 | #include "Literal.h" 11 | 12 | namespace swift { 13 | namespace absyn { 14 | 15 | class NullLiteral: public Literal { 16 | public: 17 | NullLiteral(int l, int c); 18 | virtual ~NullLiteral(); 19 | 20 | // For Debugging Use 21 | void print(FILE* file, int indent); 22 | std::string toString(); 23 | 24 | Expr* clone(); 25 | }; 26 | 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/absyn/OpExpr.h: -------------------------------------------------------------------------------- 1 | /* 2 | * OpExpr.h 3 | * 4 | * Created on: Oct 29, 2013 5 | * Author: yiwu 6 | * 7 | * Note: 8 | * When Dealing with Unary Operator e.g. NOT 9 | * Left Child should be set NULL 10 | */ 11 | 12 | #pragma once 13 | 14 | #include "Expr.h" 15 | 16 | namespace swift { 17 | namespace absyn { 18 | 19 | class OpExpr: public Expr { 20 | AbsynConstant op; 21 | public: 22 | OpExpr(int l, int c, AbsynConstant op, Expr* left, Expr* right); 23 | virtual ~OpExpr(); 24 | 25 | AbsynConstant getOp(); 26 | Expr* getLeft(); 27 | Expr* getRight(); 28 | 29 | // For Debugging Use 30 | void print(FILE* file, int indent); 31 | std::string toString(); 32 | 33 | Expr* clone(); 34 | }; 35 | 36 | } 37 | } /* namespace swift */ 38 | -------------------------------------------------------------------------------- /src/absyn/OriginDecl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * OriginDecl.h 3 | * 4 | * Created on: Oct 30, 2013 5 | * Author: yiwu 6 | */ 7 | 8 | #pragma once 9 | 10 | #include "Decl.h" 11 | #include "Symbol.h" 12 | 13 | namespace swift { 14 | namespace absyn { 15 | 16 | class OriginDecl: public Decl { 17 | public: 18 | OriginDecl(int l, int c, Symbol typ, Symbol func, Symbol arg); 19 | virtual ~OriginDecl(); 20 | 21 | const Symbol& getFunc() const; 22 | const Symbol& getArg() const; 23 | const Symbol& getTyp() const; 24 | 25 | // For Debugging Use 26 | void print(FILE* file, int indent); 27 | private: 28 | Symbol typ; 29 | Symbol func; 30 | Symbol arg; 31 | }; 32 | 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/absyn/QuantExpr.h: -------------------------------------------------------------------------------- 1 | /* 2 | * QuantExpr.h 3 | * 4 | * Created on: Oct 30, 2013 5 | * Author: yiwu 6 | */ 7 | 8 | #pragma once 9 | 10 | #include "Expr.h" 11 | #include "Symbol.h" 12 | #include "VarDecl.h" 13 | 14 | namespace swift { 15 | namespace absyn { 16 | 17 | class QuantExpr: public Expr { 18 | AbsynConstant typ; 19 | VarDecl var; 20 | public: 21 | QuantExpr(int l, int c, AbsynConstant typ, VarDecl var, Expr* cond); 22 | virtual ~QuantExpr(); 23 | 24 | AbsynConstant getTyp(); 25 | const VarDecl& getVar(); 26 | Expr* getCond(); 27 | 28 | // For Debugging Use 29 | void print(FILE* file, int indent); 30 | std::string toString(); 31 | 32 | Expr* clone(); 33 | }; 34 | 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/absyn/SetExpr.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SetExpr.cpp 3 | * 4 | * Created on: Oct 29, 2013 5 | * Author: yiwu 6 | */ 7 | 8 | #include "SetExpr.h" 9 | 10 | namespace swift { 11 | namespace absyn { 12 | 13 | SetExpr::SetExpr(int l, int c) : 14 | Expr(l, c) { 15 | } 16 | 17 | SetExpr::~SetExpr() { 18 | } 19 | 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/absyn/SetExpr.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SetExpr.h 3 | * 4 | * Created on: Oct 29, 2013 5 | * Author: yiwu 6 | */ 7 | 8 | #pragma once 9 | 10 | #include "Expr.h" 11 | #include "Symbol.h" 12 | 13 | namespace swift { 14 | namespace absyn { 15 | 16 | class SetExpr: public Expr { 17 | public: 18 | SetExpr(int l, int c); 19 | virtual ~SetExpr(); 20 | }; 21 | 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/absyn/Stmt.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Stmt.cpp 3 | * 4 | * Created on: Oct 31, 2013 5 | * Author: yiwu 6 | */ 7 | 8 | #include "Stmt.h" 9 | 10 | namespace swift { 11 | namespace absyn { 12 | 13 | Stmt::Stmt(int l, int c) : 14 | Absyn(l, c) { 15 | } 16 | 17 | Stmt::~Stmt() { 18 | } 19 | 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/absyn/Stmt.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Stmt.h 3 | * 4 | * Created on: Oct 31, 2013 5 | * Author: yiwu 6 | */ 7 | 8 | #pragma once 9 | 10 | #include "Absyn.h" 11 | 12 | namespace swift { 13 | namespace absyn { 14 | 15 | class Stmt: public Absyn { 16 | public: 17 | Stmt(int l, int c); 18 | virtual ~Stmt(); 19 | }; 20 | 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/absyn/StringLiteral.h: -------------------------------------------------------------------------------- 1 | /* 2 | * StringLiteral.h 3 | * 4 | * Created on: Oct 29, 2013 5 | * Author: yiwu 6 | */ 7 | 8 | #pragma once 9 | 10 | #include 11 | 12 | #include "Literal.h" 13 | 14 | namespace swift { 15 | namespace absyn { 16 | class StringLiteral: public Literal { 17 | std::string value; 18 | public: 19 | StringLiteral(int l, int c, std::string value); 20 | virtual ~StringLiteral(); 21 | 22 | const std::string& getValue(); 23 | 24 | // For Debugging Use 25 | void print(FILE* file, int indent); 26 | std::string toString(); 27 | 28 | Expr* clone(); 29 | }; 30 | 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/absyn/Symbol.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Symbol.cpp 3 | * 4 | * Created on: Oct 29, 2013 5 | * Author: yiwu 6 | */ 7 | 8 | #include "Symbol.h" 9 | 10 | namespace swift { 11 | namespace absyn { 12 | 13 | Symbol::Symbol(std::string v) : 14 | value(v) { 15 | } 16 | 17 | Symbol::~Symbol() { 18 | } 19 | 20 | const std::string& Symbol::getValue() const { 21 | return value; 22 | } 23 | 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/absyn/Symbol.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Symbol.h 3 | * 4 | * Created on: Oct 29, 2013 5 | * Author: yiwu 6 | */ 7 | 8 | #pragma once 9 | 10 | #include 11 | 12 | namespace swift { 13 | namespace absyn { 14 | 15 | class Symbol { 16 | std::string value; 17 | public: 18 | Symbol(std::string v = ""); 19 | ~Symbol(); 20 | 21 | const std::string& getValue() const; 22 | }; 23 | 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/absyn/TimeStampLiteral.h: -------------------------------------------------------------------------------- 1 | /* 2 | * TimeStampLiteral.h 3 | * 4 | * Created on: Oct 29, 2013 5 | * Author: yiwu 6 | */ 7 | 8 | #pragma once 9 | 10 | #include "Literal.h" 11 | 12 | namespace swift { 13 | namespace absyn { 14 | 15 | class TimeStampLiteral: public Literal { 16 | int value; 17 | public: 18 | TimeStampLiteral(int l, int c, int value); 19 | virtual ~TimeStampLiteral(); 20 | 21 | int getValue(); 22 | 23 | // For Debugging Use 24 | void print(FILE* file, int indent); 25 | std::string toString(); 26 | 27 | Expr* clone(); 28 | }; 29 | 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/absyn/Ty.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Ty.cpp 3 | * 4 | * Created on: Oct 31, 2013 5 | * Author: yiwu 6 | */ 7 | 8 | #include "Ty.h" 9 | 10 | namespace swift { 11 | namespace absyn { 12 | 13 | Ty::Ty(Symbol typ, int dim) : 14 | line(0), col(0), typ(typ), dim(dim) { 15 | } 16 | 17 | Ty::Ty(int l, int c, Symbol typ, int dim) : 18 | line(l), col(c), typ(typ), dim(dim) { 19 | } 20 | 21 | Ty::~Ty() { 22 | } 23 | 24 | const Symbol& Ty::getTyp() const { 25 | return typ; 26 | } 27 | 28 | int Ty::getDim() const { 29 | return dim; 30 | } 31 | 32 | void Ty::setDim(int d) { 33 | dim = d; 34 | } 35 | 36 | std::string Ty::toString() const { 37 | std::string ret(typ.getValue()); 38 | for (int i = 0; i < dim; i++) 39 | ret.append("[]"); 40 | return ret; 41 | } 42 | 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/absyn/Ty.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Ty.h 3 | * 4 | * Created on: Oct 31, 2013 5 | * Author: yiwu 6 | */ 7 | 8 | #pragma once 9 | 10 | #include 11 | 12 | #include "Symbol.h" 13 | 14 | namespace swift { 15 | namespace absyn { 16 | class Ty { 17 | public: 18 | int line; // line number in original file 19 | int col; // column number in original file 20 | 21 | Ty(Symbol typ, int dim = 0); 22 | Ty(int l, int c, Symbol typ, int dim = 0); 23 | virtual ~Ty(); 24 | 25 | const Symbol& getTyp() const; 26 | int getDim() const; 27 | 28 | void setDim(int d); 29 | 30 | // For Debugging Use 31 | std::string toString() const; 32 | 33 | private: 34 | Symbol typ; 35 | int dim; 36 | }; 37 | 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/absyn/TypDecl.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * TypDecl.cpp 3 | * 4 | * Created on: Oct 30, 2013 5 | * Author: yiwu 6 | */ 7 | 8 | #include "TypDecl.h" 9 | 10 | namespace swift { 11 | namespace absyn { 12 | 13 | TypDecl::TypDecl(int l, int c, Symbol arg) : 14 | Decl(l, c), arg(arg) { 15 | } 16 | 17 | TypDecl::~TypDecl() { 18 | } 19 | 20 | const Symbol& TypDecl::get() { 21 | return arg; 22 | } 23 | 24 | // For Debugging Use 25 | void TypDecl::print(FILE* file, int indent) { 26 | fprintf(file, "%*s(TypDecl: %s )\n", indent, "", arg.getValue().c_str()); 27 | } 28 | 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/absyn/TypDecl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * TypDecl.h 3 | * 4 | * Created on: Oct 29, 2013 5 | * Author: yiwu 6 | */ 7 | 8 | #pragma once 9 | 10 | #include 11 | 12 | #include "Decl.h" 13 | #include "Symbol.h" 14 | 15 | namespace swift { 16 | namespace absyn { 17 | 18 | class TypDecl: public Decl { 19 | Symbol arg; 20 | public: 21 | TypDecl(int l, int c, Symbol arg); 22 | virtual ~TypDecl(); 23 | 24 | const Symbol& get(); 25 | 26 | // For Debugging Use 27 | void print(FILE* file, int indent); 28 | }; 29 | 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/absyn/VarDecl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * VarDecl.h 3 | * 4 | * Created on: Oct 29, 2013 5 | * Author: yiwu 6 | * 7 | * Note : 8 | * This is not a DECL but an EXPR 9 | * 10 | */ 11 | 12 | #pragma once 13 | 14 | #include "Expr.h" 15 | #include "Symbol.h" 16 | #include "Ty.h" 17 | 18 | namespace swift { 19 | namespace absyn { 20 | 21 | // TODO, VarDecl needs not be Expr 22 | class VarDecl: public Expr { 23 | Ty typ; 24 | Symbol var; 25 | public: 26 | VarDecl(int l, int c, Ty typ, Symbol var = Symbol()); 27 | virtual ~VarDecl(); 28 | 29 | const Ty& getTyp() const; 30 | const Symbol& getVar() const; 31 | 32 | //For Debugging Use 33 | void print(FILE *file, int indent); 34 | std::string toString(); 35 | 36 | Expr* clone(); 37 | }; 38 | 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/absyn/VarRef.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * VarRef.cpp 3 | * 4 | * Created on: Oct 29, 2013 5 | * Author: yiwu 6 | */ 7 | 8 | #include "VarRef.h" 9 | 10 | namespace swift { 11 | namespace absyn { 12 | 13 | VarRef::VarRef(int l, int c, Symbol var) : 14 | Expr(l, c), var(var) { 15 | } 16 | 17 | VarRef::~VarRef() { 18 | } 19 | 20 | const Symbol& VarRef::getVar() { 21 | return var; 22 | } 23 | 24 | // For Debugging Use 25 | void VarRef::print(FILE* file, int indent) { 26 | fprintf(file, "%*s(VarRef: %s )\n", indent, "", var.getValue().c_str()); 27 | } 28 | 29 | std::string VarRef::toString() { 30 | return var.getValue(); 31 | } 32 | 33 | Expr* VarRef::clone() { 34 | return new VarRef(line, col, var); 35 | } 36 | 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/absyn/VarRef.h: -------------------------------------------------------------------------------- 1 | /* 2 | * VarRef.h 3 | * 4 | * Created on: Oct 29, 2013 5 | * Author: yiwu 6 | */ 7 | 8 | #pragma once 9 | 10 | #include "Expr.h" 11 | #include "Symbol.h" 12 | 13 | namespace swift { 14 | namespace absyn { 15 | 16 | class VarRef: public Expr { 17 | Symbol var; 18 | public: 19 | VarRef(int l, int c, Symbol var); 20 | virtual ~VarRef(); 21 | 22 | const Symbol& getVar(); 23 | 24 | // For Debugging Use 25 | void print(FILE* file, int indent); 26 | std::string toString(); 27 | 28 | Expr* clone(); 29 | }; 30 | 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/analyzer/Analyzer.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Analyzer.cpp 3 | * 4 | * Created on: Apr 16, 2015 5 | * Author: yiwu 6 | */ 7 | 8 | #include "Analyzer.h" 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | namespace swift { 17 | namespace analyzer { 18 | 19 | Analyzer::Analyzer(std::shared_ptr _model) 20 | : model(_model), errMsg(stderr) { 21 | } 22 | 23 | Analyzer::~Analyzer() { 24 | } 25 | 26 | void Analyzer::setModel(std::shared_ptr _model) { 27 | model = _model; 28 | } 29 | 30 | } 31 | } /* namespace swift */ 32 | -------------------------------------------------------------------------------- /src/analyzer/Analyzer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Analyzer.h 3 | * 4 | * Created on: Apr 16, 2015 5 | * Author: yiwu 6 | */ 7 | 8 | #pragma once 9 | 10 | #include 11 | #include "../ir/BlogModel.h" 12 | #include "../msg/ErrorMsg.h" 13 | 14 | namespace swift { 15 | namespace analyzer { 16 | 17 | class Analyzer { 18 | public: 19 | Analyzer(std::shared_ptr _model = nullptr); 20 | virtual ~Analyzer(); 21 | 22 | virtual bool process() = 0; 23 | 24 | virtual void setModel(std::shared_ptr _model); 25 | 26 | protected: 27 | std::shared_ptr model; 28 | msg::ErrorMsg errMsg; 29 | }; 30 | 31 | } 32 | } /* namespace swift */ 33 | -------------------------------------------------------------------------------- /src/analyzer/ConjugatePriors/ConjugatePrior.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * ConjugatePrior.cpp 3 | * 4 | * Created on: Apr 30, 2015 5 | * Author: yiwu 6 | */ 7 | 8 | #include "ConjugatePrior.h" 9 | 10 | #include "../../ir/IRHeader.h" 11 | 12 | namespace swift { 13 | namespace analyzer { 14 | namespace conjugate { 15 | 16 | ConjugatePrior::ConjugatePrior(std::string _distrb) 17 | : distrb(_distrb) { 18 | } 19 | 20 | std::string ConjugatePrior::getDistr() {return distrb;} 21 | 22 | } 23 | } 24 | } /* namespace swift */ 25 | -------------------------------------------------------------------------------- /src/analyzer/ConjugatePriors/ConjugatePrior.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ConjugatePrior.h 3 | * 4 | * Created on: Apr 30, 2015 5 | * Author: yiwu 6 | */ 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include "../Analyzer.h" 15 | 16 | namespace swift { 17 | namespace analyzer { 18 | namespace conjugate { 19 | 20 | class ConjugatePrior{ 21 | public: 22 | ConjugatePrior(std::string _distrib = std::string("")); 23 | 24 | std::string getDistr(); 25 | 26 | virtual std::shared_ptr process( 27 | std::shared_ptr fun, 28 | std::set> child) = 0; 29 | 30 | private: 31 | std::string distrb; 32 | }; 33 | 34 | } 35 | } 36 | } /* namespace swift */ 37 | -------------------------------------------------------------------------------- /src/analyzer/ConjugatePriors/ConjugatePriorList.cpp: -------------------------------------------------------------------------------- 1 | #include "ConjugatePriorList.h" 2 | 3 | namespace swift { 4 | namespace analyzer { 5 | namespace conjugate { 6 | 7 | // PreDecl Conjugate Priors 8 | 9 | std::map>> 10 | ConjugatePriorList::initPriorStore() { 11 | std::map>> ret; 12 | return ret; 13 | } 14 | 15 | std::map>> 16 | ConjugatePriorList::priorStore = ConjugatePriorList::initPriorStore(); 17 | 18 | ConjugatePriorList::ConjugatePriorList() { 19 | } 20 | 21 | ConjugatePriorList::~ConjugatePriorList() { 22 | } 23 | 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/analyzer/ConjugatePriors/InvGammaPrior.h: -------------------------------------------------------------------------------- 1 | /* 2 | * InvGammaPrior.h 3 | * 4 | * Created on: Apr 30, 2015 5 | * Author: yiwu 6 | */ 7 | 8 | #pragma once 9 | 10 | #include "ConjugatePrior.h" 11 | 12 | namespace swift { 13 | namespace analyzer { 14 | namespace conjugate { 15 | 16 | class InvGammaPrior: public ConjugatePrior{ 17 | public: 18 | InvGammaPrior(); 19 | 20 | virtual std::shared_ptr process( 21 | std::shared_ptr fun, 22 | std::set> child); 23 | 24 | private: 25 | }; 26 | 27 | } 28 | } 29 | } /* namespace swift */ 30 | -------------------------------------------------------------------------------- /src/benchmark/handcompile/execute_hurricane.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * execute.cpp 3 | * 4 | * Created on: Nov 19, 2013 5 | * Author: yiwu 6 | */ 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #include "lwsampler_hurricane.h" 13 | #include "rejsampler_hurricane.h" 14 | 15 | using namespace std; 16 | int main() { 17 | LWSAMPLER::run(); 18 | REJECTSAMPLER::run(); 19 | // std::system("pause"); 20 | return 0; 21 | } 22 | -------------------------------------------------------------------------------- /src/benchmark/handcompile/lwsampler_hurricane.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lwsampler_hurricane.h 3 | * 4 | * Created on: Nov 19, 2013 5 | * Author: leili 6 | */ 7 | 8 | #pragma once 9 | 10 | namespace LWSAMPLER { 11 | void run(); 12 | } 13 | -------------------------------------------------------------------------------- /src/benchmark/handcompile/makefile: -------------------------------------------------------------------------------- 1 | FLAGS=-O2 -std=c++11 2 | 3 | BENCHMARK_DIR=src/benchmark/handcompile/ 4 | 5 | all: urnball hurricane 6 | 7 | urnball: 8 | g++ ${FLAGS} rejsampler_urnball.cpp LWSamplerUrnBall.cpp execute_urnball.cpp -o execute_urnball 9 | 10 | hurricane: 11 | g++ ${FLAGS} rejsampler_hurricane.cpp lwsampler_hurricane.cpp execute_hurricane.cpp -o execute_hurricane 12 | 13 | burglary: 14 | g++ ${FLAGS} LWSamplerBurglary.cpp -o execute_burglary 15 | 16 | csi: 17 | g++ ${FLAGS} LWSamplerCSI.cpp -o execute_csi 18 | 19 | run: 20 | ./execute_urnball 1000000 21 | ./execute_burglary 22 | ./execute_csi 23 | ./execute_hurricane -------------------------------------------------------------------------------- /src/benchmark/handcompile/rejsampler_hurricane.h: -------------------------------------------------------------------------------- 1 | /* 2 | * rejsampler_hurricane.h 3 | * 4 | * Created on: Nov 19, 2013 5 | * Author: leili 6 | */ 7 | 8 | #pragma once 9 | 10 | namespace REJECTSAMPLER { 11 | void run(); 12 | } 13 | 14 | -------------------------------------------------------------------------------- /src/benchmark/handcompile/rejsampler_urnball.h: -------------------------------------------------------------------------------- 1 | /* 2 | * rejsampler_urnball.h 3 | * 4 | * Created on: Nov 21, 2013 5 | * Author: yiwu 6 | */ 7 | 8 | #pragma once 9 | 10 | namespace URNBALL_REJ { 11 | void run(int N); 12 | } 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/code/ArraySubscriptExpr.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * ArraySubscriptExpr.cpp 3 | * 4 | * Created on: Nov 24, 2013 5 | * Author: leili 6 | */ 7 | 8 | #include "ArraySubscriptExpr.h" 9 | 10 | namespace swift { 11 | namespace code { 12 | 13 | ArraySubscriptExpr::ArraySubscriptExpr(Expr* lhs, Expr* rhs) : 14 | Expr(std::vector( { lhs, rhs })) { 15 | } 16 | 17 | ArraySubscriptExpr::~ArraySubscriptExpr() { 18 | } 19 | 20 | Expr* ArraySubscriptExpr::getLeft() { 21 | return args[0]; 22 | } 23 | 24 | Expr* ArraySubscriptExpr::getRight() { 25 | return args[1]; 26 | } 27 | 28 | // For Printer 29 | void ArraySubscriptExpr::print(printer::Printer* prt) { 30 | prt->print(this); 31 | } 32 | 33 | } /* namespace code */ 34 | } /* namespace swift */ 35 | -------------------------------------------------------------------------------- /src/code/ArraySubscriptExpr.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ArraySubscriptExpr.h 3 | * 4 | * Created on: Nov 24, 2013 5 | * Author: leili 6 | */ 7 | 8 | #pragma once 9 | 10 | #include "Expr.h" 11 | 12 | namespace swift { 13 | namespace code { 14 | 15 | class ArraySubscriptExpr: public swift::code::Expr { 16 | public: 17 | ArraySubscriptExpr(Expr* lhs, Expr* rhs); 18 | ~ArraySubscriptExpr(); 19 | 20 | Expr* getLeft(); 21 | Expr* getRight(); 22 | 23 | // For Printer 24 | void print(printer::Printer* prt); 25 | }; 26 | 27 | } /* namespace code */ 28 | } /* namespace swift */ 29 | -------------------------------------------------------------------------------- /src/code/BinaryOperator.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * BinaryOperator.cpp 3 | * 4 | * Created on: Nov 23, 2013 5 | * Author: leili 6 | */ 7 | #include 8 | #include "BinaryOperator.h" 9 | 10 | namespace swift { 11 | namespace code { 12 | 13 | BinaryOperator::BinaryOperator(Expr* lhs, Expr* rhs, OpKind op) : 14 | Expr(std::vector( { lhs, rhs })), op(op) { 15 | } 16 | 17 | BinaryOperator::~BinaryOperator() { 18 | } 19 | 20 | Expr* BinaryOperator::getLeft() const { 21 | return args[0]; 22 | } 23 | 24 | Expr* BinaryOperator::getRight() const { 25 | return args[1]; 26 | } 27 | 28 | const OpKind& BinaryOperator::getOp() const { 29 | return op; 30 | } 31 | 32 | void BinaryOperator::print(printer::Printer* prt) { 33 | prt->print(this); 34 | } 35 | 36 | } /* namespace code */ 37 | } /* namespace swift */ 38 | -------------------------------------------------------------------------------- /src/code/BooleanLiteral.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * IntegerLiteral.cpp 3 | * 4 | * Created on: Nov 23, 2013 5 | * Author: leili 6 | */ 7 | 8 | #include "BooleanLiteral.h" 9 | 10 | namespace swift { 11 | namespace code { 12 | 13 | BooleanLiteral::BooleanLiteral(bool v) : 14 | val(v) { 15 | } 16 | 17 | BooleanLiteral::~BooleanLiteral() { 18 | } 19 | 20 | bool BooleanLiteral::getVal() const { 21 | return val; 22 | } 23 | 24 | // For Printer 25 | void BooleanLiteral::print(printer::Printer* prt) { 26 | prt->print(this); 27 | } 28 | 29 | } /* namespace code */ 30 | } /* namespace swift */ 31 | -------------------------------------------------------------------------------- /src/code/BooleanLiteral.h: -------------------------------------------------------------------------------- 1 | /* 2 | * IntegerLiteral.h 3 | * 4 | * Created on: Nov 23, 2013 5 | * Author: leili 6 | */ 7 | 8 | #pragma once 9 | 10 | #include "Expr.h" 11 | 12 | namespace swift { 13 | namespace code { 14 | 15 | class BooleanLiteral: public swift::code::Expr { 16 | public: 17 | BooleanLiteral(bool v); 18 | ~BooleanLiteral(); 19 | 20 | bool getVal() const; 21 | // For Printer 22 | void print(printer::Printer* prt); 23 | private: 24 | bool val; 25 | }; 26 | 27 | } /* namespace code */ 28 | } /* namespace swift */ 29 | -------------------------------------------------------------------------------- /src/code/BreakStmt.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * BreakStmt.cpp 3 | * 4 | * Created on: Nov 24, 2013 5 | * Author: leili 6 | */ 7 | 8 | #include "BreakStmt.h" 9 | 10 | namespace swift { 11 | namespace code { 12 | 13 | BreakStmt::BreakStmt() { 14 | } 15 | 16 | BreakStmt::~BreakStmt() { 17 | } 18 | 19 | void BreakStmt::print(printer::Printer* prt) { 20 | prt->print(this); 21 | } 22 | } /* namespace code */ 23 | } /* namespace swift */ 24 | -------------------------------------------------------------------------------- /src/code/BreakStmt.h: -------------------------------------------------------------------------------- 1 | /* 2 | * BreakStmt.h 3 | * 4 | * Created on: Nov 24, 2013 5 | * Author: leili 6 | */ 7 | 8 | #pragma once 9 | 10 | #include "Stmt.h" 11 | 12 | namespace swift { 13 | namespace code { 14 | 15 | /** 16 | * Representing a statement which can be used in for, while, and switch statements 17 | */ 18 | class BreakStmt: public swift::code::Stmt { 19 | public: 20 | BreakStmt(); 21 | ~BreakStmt(); 22 | 23 | // For Printer 24 | void print(printer::Printer* prt); 25 | }; 26 | 27 | } /* namespace code */ 28 | } /* namespace swift */ 29 | -------------------------------------------------------------------------------- /src/code/CallClassConstructor.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * CallClassConstructor.cpp 3 | * 4 | * Created on: Jan 22, 2014 5 | * Author: leili 6 | */ 7 | 8 | #include "CallClassConstructor.h" 9 | 10 | namespace swift { 11 | namespace code { 12 | 13 | CallClassConstructor::CallClassConstructor(Type type, std::vector args) : 14 | Expr(args), type(type) { 15 | } 16 | 17 | CallClassConstructor::~CallClassConstructor() { 18 | } 19 | 20 | Type& CallClassConstructor::getType() { 21 | return type; 22 | } 23 | 24 | void CallClassConstructor::print(printer::Printer* prt) { 25 | prt->print(this); 26 | } 27 | 28 | } /* namespace code */ 29 | } /* namespace swift */ 30 | -------------------------------------------------------------------------------- /src/code/CallClassConstructor.h: -------------------------------------------------------------------------------- 1 | /* 2 | * CallClassConstructor.h 3 | * 4 | * Created on: Jan 22, 2014 5 | * Author: leili 6 | */ 7 | 8 | #pragma once 9 | 10 | #include "Expr.h" 11 | #include "Type.h" 12 | #include "../printer/Printer.h" 13 | 14 | namespace swift { 15 | namespace code { 16 | 17 | class CallClassConstructor: public swift::code::Expr { 18 | public: 19 | CallClassConstructor(Type type, std::vector args = 20 | std::vector()); 21 | virtual ~CallClassConstructor(); 22 | Type& getType(); 23 | void print(printer::Printer* prt); 24 | protected: 25 | Type type; 26 | }; 27 | 28 | } /* namespace code */ 29 | } /* namespace swift */ 30 | -------------------------------------------------------------------------------- /src/code/CaseStmt.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * CaseStmt.cpp 3 | * 4 | * Created on: Nov 24, 2013 5 | * Author: leili 6 | */ 7 | 8 | #include "CaseStmt.h" 9 | 10 | namespace swift { 11 | namespace code { 12 | 13 | CaseStmt::CaseStmt(Expr* val, Stmt* stmt) : 14 | val(val), sub(stmt) { 15 | } 16 | 17 | CaseStmt::~CaseStmt() { 18 | delete val; 19 | if (sub != NULL) 20 | delete sub; 21 | } 22 | 23 | Expr* CaseStmt::getVal() const { 24 | return val; 25 | } 26 | 27 | Stmt* CaseStmt::getSub() const { 28 | return sub; 29 | } 30 | 31 | // For Printer 32 | void CaseStmt::print(printer::Printer* prt) { 33 | prt->print(this); 34 | } 35 | 36 | } /* namespace code */ 37 | } /* namespace swift */ 38 | -------------------------------------------------------------------------------- /src/code/CaseStmt.h: -------------------------------------------------------------------------------- 1 | /* 2 | * CaseStmt.h 3 | * 4 | * Created on: Nov 24, 2013 5 | * Author: leili 6 | */ 7 | 8 | #pragma once 9 | 10 | #include "Stmt.h" 11 | #include "Expr.h" 12 | #include "CompoundStmt.h" 13 | 14 | namespace swift { 15 | namespace code { 16 | 17 | /** 18 | * A statement that can only be used inside switch statement. 19 | */ 20 | class CaseStmt: public swift::code::Stmt { 21 | public: 22 | CaseStmt(Expr* val, Stmt* stmt = NULL); 23 | ~CaseStmt(); 24 | 25 | Stmt* getSub() const; 26 | Expr* getVal() const; 27 | 28 | // For Printer 29 | void print(printer::Printer* prt); 30 | private: 31 | Expr* val; 32 | Stmt* sub; 33 | }; 34 | 35 | } /* namespace code */ 36 | } /* namespace swift */ 37 | -------------------------------------------------------------------------------- /src/code/CompoundStmt.h: -------------------------------------------------------------------------------- 1 | /* 2 | * CompoundStmt.h 3 | * 4 | * Created on: Nov 23, 2013 5 | * Author: leili 6 | */ 7 | 8 | #pragma once 9 | 10 | #include 11 | #include "Stmt.h" 12 | 13 | namespace swift { 14 | namespace code { 15 | 16 | class CompoundStmt: public swift::code::Stmt { 17 | public: 18 | CompoundStmt(); 19 | ~CompoundStmt(); 20 | void addStmt(Stmt* st); 21 | size_t size() const; 22 | Stmt* get(int k) const; 23 | const std::vector& getAll() const; 24 | 25 | // For Printer 26 | void print(printer::Printer* prt); 27 | 28 | private: 29 | std::vector body; 30 | }; 31 | 32 | } /* namespace code */ 33 | } /* namespace swift */ 34 | -------------------------------------------------------------------------------- /src/code/ContinueStmt.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * ContinueStmt.cpp 3 | * 4 | * Created on: Nov 24, 2013 5 | * Author: leili 6 | */ 7 | 8 | #include "ContinueStmt.h" 9 | 10 | namespace swift { 11 | namespace code { 12 | 13 | ContinueStmt::ContinueStmt() { 14 | } 15 | 16 | ContinueStmt::~ContinueStmt() { 17 | } 18 | 19 | void ContinueStmt::print(printer::Printer* prt) { 20 | prt->print(this); 21 | } 22 | } /* namespace code */ 23 | } /* namespace swift */ 24 | -------------------------------------------------------------------------------- /src/code/ContinueStmt.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ContinueStmt.h 3 | * 4 | * Created on: Nov 24, 2013 5 | * Author: leili 6 | */ 7 | 8 | #pragma once 9 | 10 | #include "Stmt.h" 11 | 12 | namespace swift { 13 | namespace code { 14 | 15 | class ContinueStmt: public swift::code::Stmt { 16 | public: 17 | ContinueStmt(); 18 | ~ContinueStmt(); 19 | 20 | // For Printer 21 | void print(printer::Printer* prt); 22 | }; 23 | 24 | } /* namespace code */ 25 | } /* namespace swift */ 26 | -------------------------------------------------------------------------------- /src/code/Decl.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Decl.cpp 3 | * 4 | * Created on: Nov 23, 2013 5 | * Author: leili 6 | */ 7 | 8 | #include "Decl.h" 9 | 10 | namespace swift { 11 | namespace code { 12 | 13 | Decl::Decl() { 14 | // TODO Auto-generated constructor stub 15 | 16 | } 17 | 18 | Decl::~Decl() { 19 | // TODO Auto-generated destructor stub 20 | } 21 | 22 | } /* namespace code */ 23 | } /* namespace swift */ 24 | -------------------------------------------------------------------------------- /src/code/Decl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Decl.h 3 | * 4 | * Created on: Nov 23, 2013 5 | * Author: leili 6 | */ 7 | 8 | #pragma once 9 | 10 | #include "../printer/Printer.h" 11 | 12 | namespace swift { 13 | namespace code { 14 | 15 | class Decl { 16 | public: 17 | Decl(); 18 | virtual ~Decl(); 19 | 20 | // For Printer 21 | virtual void print(printer::Printer* prt) = 0; 22 | }; 23 | 24 | } /* namespace code */ 25 | } /* namespace swift */ 26 | -------------------------------------------------------------------------------- /src/code/DeclContext.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * DeclContext.cpp 3 | * 4 | * Created on: Nov 23, 2013 5 | * Author: leili 6 | */ 7 | 8 | #include "DeclContext.h" 9 | 10 | namespace swift { 11 | namespace code { 12 | 13 | DeclContext::DeclContext() { 14 | } 15 | 16 | DeclContext::~DeclContext() { 17 | for (auto d : members) { 18 | delete d; 19 | } 20 | } 21 | 22 | //Decl* DeclContext::getMem(int k) { 23 | // return members[k]; 24 | //} 25 | 26 | std::vector& DeclContext::getAllDecls() { 27 | return members; 28 | } 29 | 30 | void DeclContext::addDecl(Decl* decl) { 31 | members.push_back(decl); 32 | } 33 | 34 | void DeclContext::addDeclFront(Decl* decl) { 35 | members.insert(members.begin(), decl); 36 | } 37 | 38 | } /* namespace code */ 39 | } /* namespace swift */ 40 | -------------------------------------------------------------------------------- /src/code/DeclStmt.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * DeclStmt.cpp 3 | * 4 | * Created on: Nov 23, 2013 5 | * Author: leili 6 | */ 7 | 8 | #include "DeclStmt.h" 9 | 10 | namespace swift { 11 | namespace code { 12 | 13 | DeclStmt::DeclStmt(Decl* dec) : 14 | dec(dec) { 15 | } 16 | 17 | DeclStmt::~DeclStmt() { 18 | delete dec; 19 | } 20 | 21 | Decl* DeclStmt::getDecl() { 22 | return dec; 23 | } 24 | 25 | // For Printer 26 | void DeclStmt::print(printer::Printer* prt) { 27 | prt->print(this); 28 | } 29 | 30 | } /* namespace code */ 31 | } /* namespace swift */ 32 | -------------------------------------------------------------------------------- /src/code/DeclStmt.h: -------------------------------------------------------------------------------- 1 | /* 2 | * DeclStmt.h 3 | * 4 | * Created on: Nov 23, 2013 5 | * Author: leili 6 | */ 7 | 8 | #pragma once 9 | 10 | #include "Stmt.h" 11 | #include "Decl.h" 12 | 13 | namespace swift { 14 | namespace code { 15 | 16 | class DeclStmt: public swift::code::Stmt { 17 | public: 18 | DeclStmt(Decl* dec); 19 | ~DeclStmt(); 20 | 21 | Decl* getDecl(); 22 | 23 | // For Printer 24 | void print(printer::Printer* prt); 25 | 26 | private: 27 | Decl* dec; 28 | }; 29 | 30 | } /* namespace code */ 31 | } /* namespace swift */ 32 | -------------------------------------------------------------------------------- /src/code/Expr.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Expr.cpp 3 | * 4 | * Created on: Nov 23, 2013 5 | * Author: leili 6 | */ 7 | 8 | #include "Expr.h" 9 | 10 | namespace swift { 11 | namespace code { 12 | 13 | Expr::Expr(std::vector args) : 14 | args(args) { 15 | } 16 | 17 | Expr::~Expr() { 18 | for (auto& a : args) 19 | if(a != NULL) delete a; 20 | args.clear(); 21 | } 22 | 23 | std::vector& Expr::getArgs() { 24 | return args; 25 | } 26 | 27 | void Expr::clearArgs() { 28 | args.clear(); 29 | } 30 | 31 | } /* namespace code */ 32 | } /* namespace swift */ 33 | -------------------------------------------------------------------------------- /src/code/Expr.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Expr.h 3 | * 4 | * Created on: Nov 23, 2013 5 | * Author: leili 6 | */ 7 | 8 | #pragma once 9 | #include 10 | #include "Stmt.h" 11 | 12 | namespace swift { 13 | namespace code { 14 | 15 | class Expr: public swift::code::Stmt { 16 | public: 17 | Expr(std::vector args = std::vector()); 18 | virtual ~Expr(); 19 | 20 | virtual std::vector& getArgs(); 21 | virtual void clearArgs(); // only clear, will not remove the pointers 22 | 23 | // For Printer 24 | virtual void print(printer::Printer* prt) = 0; 25 | protected: 26 | std::vector args; 27 | }; 28 | 29 | } /* namespace code */ 30 | } /* namespace swift */ 31 | -------------------------------------------------------------------------------- /src/code/FloatingLiteral.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * FloatingLiteral.cpp 3 | * 4 | * Created on: Nov 23, 2013 5 | * Author: leili 6 | */ 7 | 8 | #include "FloatingLiteral.h" 9 | 10 | namespace swift { 11 | namespace code { 12 | 13 | FloatingLiteral::FloatingLiteral(double val) : 14 | val(val) { 15 | // TODO Auto-generated constructor stub 16 | 17 | } 18 | 19 | FloatingLiteral::~FloatingLiteral() { 20 | // TODO Auto-generated destructor stub 21 | } 22 | 23 | double FloatingLiteral::getVal() const { 24 | return val; 25 | } 26 | 27 | // For Printer 28 | void FloatingLiteral::print(printer::Printer* prt) { 29 | prt->print(this); 30 | } 31 | 32 | } /* namespace code */ 33 | } /* namespace swift */ 34 | -------------------------------------------------------------------------------- /src/code/FloatingLiteral.h: -------------------------------------------------------------------------------- 1 | /* 2 | * FloatingLiteral.h 3 | * 4 | * Created on: Nov 23, 2013 5 | * Author: leili 6 | */ 7 | 8 | #pragma once 9 | 10 | #include "Expr.h" 11 | 12 | namespace swift { 13 | namespace code { 14 | 15 | class FloatingLiteral: public swift::code::Expr { 16 | public: 17 | FloatingLiteral(double val); 18 | ~FloatingLiteral(); 19 | 20 | double getVal() const; 21 | 22 | // For Printer 23 | void print(printer::Printer* prt); 24 | 25 | private: 26 | double val; 27 | }; 28 | 29 | } /* namespace code */ 30 | } /* namespace swift */ 31 | -------------------------------------------------------------------------------- /src/code/Identifier.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Identifier.cpp 3 | * 4 | * Created on: Nov 23, 2013 5 | * Author: leili 6 | */ 7 | 8 | #include "Identifier.h" 9 | 10 | namespace swift { 11 | namespace code { 12 | 13 | Identifier::Identifier(std::string id) : 14 | id(id) { 15 | } 16 | 17 | Identifier::~Identifier() { 18 | } 19 | 20 | const std::string& Identifier::getId() const { 21 | return id; 22 | } 23 | 24 | // For Printer 25 | void Identifier::print(printer::Printer* prt) { 26 | prt->print(this); 27 | } 28 | 29 | } /* namespace code */ 30 | } /* namespace swift */ 31 | -------------------------------------------------------------------------------- /src/code/Identifier.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Identifier.h 3 | * 4 | * Created on: Nov 23, 2013 5 | * Author: leili 6 | */ 7 | 8 | #pragma once 9 | 10 | #include 11 | #include "Expr.h" 12 | 13 | namespace swift { 14 | namespace code { 15 | 16 | class Identifier: public swift::code::Expr { 17 | public: 18 | Identifier(std::string id); 19 | ~Identifier(); 20 | 21 | const std::string& getId() const; 22 | 23 | // For Printer 24 | void print(printer::Printer* prt); 25 | private: 26 | std::string id; 27 | }; 28 | 29 | } /* namespace code */ 30 | } /* namespace swift */ 31 | -------------------------------------------------------------------------------- /src/code/IfStmt.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * IfStmt.cpp 3 | * 4 | * Created on: Nov 23, 2013 5 | * Author: leili 6 | */ 7 | 8 | #include "IfStmt.h" 9 | 10 | namespace swift { 11 | namespace code { 12 | 13 | IfStmt::IfStmt(Expr* cond, Stmt* th, Stmt* el) : 14 | cond(cond), th(th), el(el) { 15 | } 16 | 17 | IfStmt::~IfStmt() { 18 | delete cond; 19 | } 20 | 21 | Expr* IfStmt::getCond() { 22 | return cond; 23 | } 24 | 25 | Stmt* IfStmt::getThen() { 26 | return th; 27 | } 28 | 29 | Stmt* IfStmt::getElse() { 30 | return el; 31 | } 32 | 33 | // For Printer 34 | void IfStmt::print(printer::Printer* prt) { 35 | prt->print(this); 36 | } 37 | 38 | } /* namespace code */ 39 | } /* namespace swift */ 40 | -------------------------------------------------------------------------------- /src/code/IfStmt.h: -------------------------------------------------------------------------------- 1 | /* 2 | * IfStmt.h 3 | * 4 | * Created on: Nov 23, 2013 5 | * Author: leili 6 | */ 7 | 8 | #pragma once 9 | #include "Stmt.h" 10 | #include "Expr.h" 11 | 12 | #include "CompoundStmt.h" 13 | 14 | namespace swift { 15 | namespace code { 16 | 17 | class IfStmt: public swift::code::Stmt { 18 | public: 19 | IfStmt(Expr* cond, Stmt* th, Stmt* el = NULL); 20 | ~IfStmt(); 21 | 22 | Expr* getCond(); 23 | Stmt* getThen(); 24 | Stmt* getElse(); 25 | 26 | // For Printer 27 | void print(printer::Printer* prt); 28 | private: 29 | Expr* cond; 30 | Stmt* th; 31 | Stmt* el; 32 | }; 33 | 34 | } /* namespace code */ 35 | } /* namespace swift */ 36 | -------------------------------------------------------------------------------- /src/code/IntegerLiteral.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * IntegerLiteral.cpp 3 | * 4 | * Created on: Nov 23, 2013 5 | * Author: leili 6 | */ 7 | 8 | #include "IntegerLiteral.h" 9 | 10 | namespace swift { 11 | namespace code { 12 | 13 | IntegerLiteral::IntegerLiteral(int v) : 14 | val(v) { 15 | } 16 | 17 | IntegerLiteral::~IntegerLiteral() { 18 | } 19 | 20 | int IntegerLiteral::getVal() const { 21 | return val; 22 | } 23 | 24 | // For Printer 25 | void IntegerLiteral::print(printer::Printer* prt) { 26 | prt->print(this); 27 | } 28 | 29 | } /* namespace code */ 30 | } /* namespace swift */ 31 | -------------------------------------------------------------------------------- /src/code/IntegerLiteral.h: -------------------------------------------------------------------------------- 1 | /* 2 | * IntegerLiteral.h 3 | * 4 | * Created on: Nov 23, 2013 5 | * Author: leili 6 | */ 7 | 8 | #pragma once 9 | 10 | #include "Expr.h" 11 | 12 | namespace swift { 13 | namespace code { 14 | 15 | class IntegerLiteral: public swift::code::Expr { 16 | public: 17 | IntegerLiteral(int v); 18 | ~IntegerLiteral(); 19 | 20 | int getVal() const; 21 | // For Printer 22 | void print(printer::Printer* prt); 23 | private: 24 | int val; 25 | }; 26 | 27 | } /* namespace code */ 28 | } /* namespace swift */ 29 | -------------------------------------------------------------------------------- /src/code/ListInitExpr.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // ListInitExpr.cpp 3 | // swift-project 4 | // 5 | // Created by Lei Li on 1/16/14. 6 | // 7 | // 8 | 9 | #include "ListInitExpr.h" 10 | 11 | namespace swift { 12 | namespace code { 13 | 14 | ListInitExpr::ListInitExpr(std::vector subExprs) : 15 | Expr(subExprs) { 16 | } 17 | 18 | ListInitExpr::~ListInitExpr() { 19 | } 20 | 21 | void ListInitExpr::print(printer::Printer* prt) { 22 | prt->print(this); 23 | } 24 | 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/code/ListInitExpr.h: -------------------------------------------------------------------------------- 1 | // 2 | // ListInitExpr.h 3 | // swift-project 4 | // 5 | // Created by Lei Li on 1/16/14. 6 | // 7 | // 8 | 9 | #pragma once 10 | 11 | #include 12 | #include 13 | #include "Expr.h" 14 | 15 | namespace swift { 16 | namespace code { 17 | 18 | class ListInitExpr: public Expr { 19 | public: 20 | ListInitExpr(std::vector subExprs); 21 | ~ListInitExpr(); 22 | // For Printer 23 | void print(printer::Printer* prt); 24 | }; 25 | 26 | } /* namespace code */ 27 | } /* namespace swift */ 28 | -------------------------------------------------------------------------------- /src/code/NamespaceDecl.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * NamespaceDecl.cpp 3 | * 4 | * Created on: Nov 23, 2013 5 | * Author: leili 6 | */ 7 | 8 | #include "NamespaceDecl.h" 9 | 10 | namespace swift { 11 | namespace code { 12 | 13 | NamespaceDecl::NamespaceDecl(std::string name) : 14 | name(name) { 15 | } 16 | 17 | NamespaceDecl::~NamespaceDecl() { 18 | } 19 | 20 | const std::string& NamespaceDecl::getName() { 21 | return name; 22 | } 23 | 24 | // For Printer 25 | void NamespaceDecl::print(printer::Printer* prt) { 26 | prt->print(this); 27 | } 28 | 29 | } /* namespace code */ 30 | } /* namespace swift */ 31 | -------------------------------------------------------------------------------- /src/code/NamespaceDecl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * NamespaceDecl.h 3 | * 4 | * Created on: Nov 23, 2013 5 | * Author: leili 6 | */ 7 | 8 | #pragma once 9 | 10 | #include 11 | 12 | #include "Decl.h" 13 | #include "DeclContext.h" 14 | 15 | namespace swift { 16 | namespace code { 17 | 18 | class NamespaceDecl: public Decl, public DeclContext { 19 | public: 20 | NamespaceDecl(std::string name = std::string()); 21 | ~NamespaceDecl(); 22 | 23 | const std::string& getName(); 24 | 25 | // For Printer 26 | void print(printer::Printer* prt); 27 | 28 | private: 29 | std::string name; 30 | }; 31 | 32 | } /* namespace code */ 33 | } /* namespace swift */ 34 | -------------------------------------------------------------------------------- /src/code/NewExpr.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * NewExpr.cpp 3 | * 4 | * Created on: Apr 15, 2015 5 | * Author: yiwu 6 | */ 7 | #include 8 | #include "NewExpr.h" 9 | 10 | namespace swift { 11 | namespace code { 12 | 13 | NewExpr::NewExpr(Expr* expr) : 14 | Expr(std::vector( { expr })) { 15 | } 16 | 17 | NewExpr::~NewExpr() { 18 | } 19 | 20 | Expr* NewExpr::getExpr() const { 21 | return args[0]; 22 | } 23 | 24 | void NewExpr::print(printer::Printer* prt) { 25 | prt->print(this); 26 | } 27 | 28 | } /* namespace code */ 29 | } /* namespace swift */ 30 | -------------------------------------------------------------------------------- /src/code/NewExpr.h: -------------------------------------------------------------------------------- 1 | /* 2 | * NewExpr.h 3 | * 4 | * Created on: Apr 15, 2015 5 | * Author: yiwu 6 | */ 7 | 8 | #pragma once 9 | 10 | #include "Expr.h" 11 | 12 | namespace swift { 13 | namespace code { 14 | 15 | class NewExpr: public swift::code::Expr { 16 | public: 17 | NewExpr(Expr* expr); 18 | ~NewExpr(); 19 | 20 | Expr* getExpr() const; 21 | 22 | // For Printer 23 | void print(printer::Printer* prt); 24 | }; 25 | 26 | } /* namespace code */ 27 | } /* namespace swift */ 28 | -------------------------------------------------------------------------------- /src/code/NullLiteral.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * NullLiteral.cpp 3 | * 4 | * Created on: Jan 17, 2014 5 | * Author: leili 6 | */ 7 | 8 | #include "NullLiteral.h" 9 | 10 | namespace swift { 11 | namespace code { 12 | 13 | NullLiteral::NullLiteral() { 14 | } 15 | 16 | NullLiteral::~NullLiteral() { 17 | } 18 | 19 | void NullLiteral::print(printer::Printer* prt) { 20 | prt->print(this); 21 | } 22 | 23 | } /* namespace code */ 24 | } /* namespace swift */ 25 | -------------------------------------------------------------------------------- /src/code/NullLiteral.h: -------------------------------------------------------------------------------- 1 | /* 2 | * NullLiteral.h 3 | * 4 | * Created on: Jan 17, 2014 5 | * Author: leili 6 | */ 7 | 8 | #pragma once 9 | 10 | #include "Expr.h" 11 | #include "../printer/Printer.h" 12 | 13 | namespace swift { 14 | namespace code { 15 | 16 | class NullLiteral: public swift::code::Expr { 17 | public: 18 | NullLiteral(); 19 | ~NullLiteral(); 20 | void print(printer::Printer* prt); 21 | }; 22 | 23 | } /* namespace code */ 24 | } /* namespace swift */ 25 | -------------------------------------------------------------------------------- /src/code/ParamVarDecl.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * ParamVarDecl.cpp 3 | * 4 | * Created on: Nov 23, 2013 5 | * Author: leili 6 | */ 7 | 8 | #include "ParamVarDecl.h" 9 | 10 | namespace swift { 11 | namespace code { 12 | 13 | ParamVarDecl::ParamVarDecl(DeclContext * context, std::string id, Type ty, 14 | Expr* value) : 15 | VarDecl(context, id, ty, value) { 16 | } 17 | 18 | ParamVarDecl::~ParamVarDecl() { 19 | } 20 | 21 | // For Printer 22 | void ParamVarDecl::print(printer::Printer* prt) { 23 | prt->print(this); 24 | } 25 | 26 | } /* namespace code */ 27 | } /* namespace swift */ 28 | -------------------------------------------------------------------------------- /src/code/ParamVarDecl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ParamVarDecl.h 3 | * 4 | * Created on: Nov 23, 2013 5 | * Author: leili 6 | */ 7 | 8 | #pragma once 9 | 10 | #include "VarDecl.h" 11 | 12 | namespace swift { 13 | namespace code { 14 | 15 | class ParamVarDecl: public swift::code::VarDecl { 16 | public: 17 | ParamVarDecl(DeclContext * context, std::string id, Type ty, Expr* value = 18 | NULL); 19 | ~ParamVarDecl(); 20 | 21 | // For Printer 22 | void print(printer::Printer* prt); 23 | }; 24 | 25 | } /* namespace code */ 26 | } /* namespace swift */ 27 | -------------------------------------------------------------------------------- /src/code/ReturnStmt.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * ReturnStmt.cpp 3 | * 4 | * Created on: Nov 23, 2013 5 | * Author: leili 6 | */ 7 | 8 | #include "ReturnStmt.h" 9 | 10 | namespace swift { 11 | namespace code { 12 | 13 | ReturnStmt::ReturnStmt(Expr* expr) : 14 | expr(expr) { 15 | } 16 | 17 | ReturnStmt::~ReturnStmt() { 18 | if (expr != NULL) 19 | delete expr; 20 | } 21 | 22 | Expr* ReturnStmt::getExpr() const { 23 | return expr; 24 | } 25 | 26 | // For Printer 27 | void ReturnStmt::print(printer::Printer* prt) { 28 | prt->print(this); 29 | } 30 | 31 | } /* namespace code */ 32 | } /* namespace swift */ 33 | -------------------------------------------------------------------------------- /src/code/ReturnStmt.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ReturnStmt.h 3 | * 4 | * Created on: Nov 23, 2013 5 | * Author: leili 6 | */ 7 | 8 | #pragma once 9 | 10 | #include "Stmt.h" 11 | #include "Expr.h" 12 | 13 | namespace swift { 14 | namespace code { 15 | 16 | class ReturnStmt: public swift::code::Stmt { 17 | public: 18 | ReturnStmt(Expr* expr = NULL); 19 | ~ReturnStmt(); 20 | 21 | Expr* getExpr() const; 22 | 23 | // For Printer 24 | void print(printer::Printer* prt); 25 | private: 26 | Expr* expr; 27 | }; 28 | 29 | } /* namespace code */ 30 | } /* namespace swift */ 31 | -------------------------------------------------------------------------------- /src/code/SpecialMacro.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SpecialMacro.cpp 3 | * 4 | * Created on: Nov 24, 2013 5 | * Author: leili 6 | */ 7 | 8 | #include "SpecialMacro.h" 9 | 10 | namespace swift { 11 | namespace code { 12 | 13 | SpecialMacro::SpecialMacro(std::string stmt) : 14 | stmt(stmt) { 15 | } 16 | 17 | SpecialMacro::~SpecialMacro() { 18 | } 19 | 20 | const std::string& SpecialMacro::getMacro() const { 21 | return stmt; 22 | } 23 | 24 | void SpecialMacro::print(printer::Printer* prt) { 25 | prt->print(this); 26 | } 27 | } /* namespace code */ 28 | } /* namespace swift */ 29 | -------------------------------------------------------------------------------- /src/code/Stmt.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Stmt.cpp 3 | * 4 | * Created on: Nov 23, 2013 5 | * Author: leili 6 | */ 7 | 8 | #include "Stmt.h" 9 | 10 | namespace swift { 11 | namespace code { 12 | 13 | Stmt::Stmt() { 14 | } 15 | 16 | Stmt::~Stmt() { 17 | } 18 | 19 | } /* namespace code */ 20 | } /* namespace swift */ 21 | 22 | -------------------------------------------------------------------------------- /src/code/Stmt.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Stmt.h 3 | * 4 | * Created on: Nov 23, 2013 5 | * Author: leili 6 | */ 7 | 8 | #pragma once 9 | 10 | #include "../printer/Printer.h" 11 | 12 | namespace swift { 13 | namespace code { 14 | 15 | class Stmt { 16 | public: 17 | Stmt(); 18 | virtual ~Stmt(); 19 | // For Printer 20 | virtual void print(printer::Printer* prt) = 0; 21 | }; 22 | 23 | } /* namespace code */ 24 | } /* namespace swift */ 25 | -------------------------------------------------------------------------------- /src/code/StringLiteral.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * IntegerLiteral.cpp 3 | * 4 | * Created on: Nov 23, 2013 5 | * Author: leili 6 | */ 7 | 8 | #include "StringLiteral.h" 9 | 10 | namespace swift { 11 | namespace code { 12 | 13 | StringLiteral::StringLiteral(std::string v) : 14 | val(v) { 15 | } 16 | 17 | StringLiteral::~StringLiteral() { 18 | } 19 | 20 | const std::string& StringLiteral::getVal() const { 21 | return val; 22 | } 23 | 24 | // For Printer 25 | void StringLiteral::print(printer::Printer* prt) { 26 | prt->print(this); 27 | } 28 | 29 | } /* namespace code */ 30 | } /* namespace swift */ 31 | -------------------------------------------------------------------------------- /src/code/StringLiteral.h: -------------------------------------------------------------------------------- 1 | /* 2 | * IntegerLiteral.h 3 | * 4 | * Created on: Nov 23, 2013 5 | * Author: leili 6 | */ 7 | 8 | #pragma once 9 | 10 | #include "Expr.h" 11 | 12 | #include 13 | 14 | namespace swift { 15 | namespace code { 16 | 17 | class StringLiteral: public swift::code::Expr { 18 | public: 19 | StringLiteral(std::string v); 20 | ~StringLiteral(); 21 | 22 | const std::string& getVal() const; 23 | // For Printer 24 | void print(printer::Printer* prt); 25 | private: 26 | std::string val; 27 | }; 28 | 29 | } /* namespace code */ 30 | } /* namespace swift */ 31 | -------------------------------------------------------------------------------- /src/code/SwitchStmt.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SwitchStmt.cpp 3 | * 4 | * Created on: Nov 24, 2013 5 | * Author: leili 6 | */ 7 | 8 | #include "SwitchStmt.h" 9 | 10 | namespace swift { 11 | namespace code { 12 | 13 | SwitchStmt::SwitchStmt(Expr * cond) : 14 | cond(cond) { 15 | } 16 | 17 | SwitchStmt::~SwitchStmt() { 18 | delete cond; 19 | } 20 | 21 | Expr* SwitchStmt::getCond() const { 22 | return cond; 23 | } 24 | 25 | void SwitchStmt::addStmt(Stmt* st) { 26 | body.addStmt(st); 27 | } 28 | 29 | CompoundStmt* SwitchStmt::getBody() { 30 | return &body; 31 | } 32 | 33 | // For Printer 34 | void SwitchStmt::print(printer::Printer* prt) { 35 | prt->print(this); 36 | } 37 | 38 | } /* namespace code */ 39 | } /* namespace swift */ 40 | -------------------------------------------------------------------------------- /src/code/TemplateExpr.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * TemplateExpr.cpp 3 | * 4 | * Created on: Oct 13, 2014 5 | * Author: yiwu 6 | */ 7 | 8 | #include "TemplateExpr.h" 9 | #include "Identifier.h" 10 | #include "BinaryOperator.h" 11 | 12 | namespace swift { 13 | namespace code { 14 | 15 | TemplateExpr::TemplateExpr(code::Expr* var, std::vector tempArgs) : 16 | Expr(tempArgs), var(var){ 17 | } 18 | 19 | TemplateExpr::~TemplateExpr() { 20 | } 21 | 22 | Expr* TemplateExpr::getVar() const { 23 | return var; 24 | } 25 | 26 | // For Printer 27 | void TemplateExpr::print(printer::Printer* prt) { 28 | prt->print(this); 29 | } 30 | 31 | } /* namespace code */ 32 | } /* namespace swift */ 33 | 34 | -------------------------------------------------------------------------------- /src/code/TemplateExpr.h: -------------------------------------------------------------------------------- 1 | /* 2 | * TemplateExpr.h 3 | * 4 | * Created on: Oct 13, 2014 5 | * Author: yiwu 6 | */ 7 | 8 | #pragma once 9 | #include "Expr.h" 10 | 11 | namespace swift { 12 | namespace code { 13 | 14 | class TemplateExpr: public Expr { 15 | public: 16 | TemplateExpr(Expr* var, std::vector tempArgs = std::vector()); 17 | ~TemplateExpr(); 18 | 19 | Expr* getVar() const ; 20 | 21 | // For Printer 22 | void print(printer::Printer* prt); 23 | 24 | protected: 25 | Expr* var; 26 | }; 27 | 28 | } /* namespace code */ 29 | } /* namespace swift */ 30 | -------------------------------------------------------------------------------- /src/codegen/LWTranslator.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * LWTranslator.cpp 3 | * 4 | * Created on: Mar 4, 2014 5 | * Author: leili 6 | */ 7 | 8 | #include "LWTranslator.h" 9 | 10 | namespace swift { 11 | namespace codegen { 12 | 13 | LWTranslator::LWTranslator() { 14 | // TODO Auto-generated constructor stub 15 | 16 | } 17 | 18 | LWTranslator::~LWTranslator() { 19 | // TODO Auto-generated destructor stub 20 | } 21 | 22 | } /* namespace codegen */ 23 | } /* namespace swift */ 24 | -------------------------------------------------------------------------------- /src/codegen/LWTranslator.h: -------------------------------------------------------------------------------- 1 | /* 2 | * LWTranslator.h 3 | * 4 | * Created on: Mar 4, 2014 5 | * Author: leili 6 | */ 7 | 8 | #pragma once 9 | 10 | #include "Translator.h" 11 | 12 | namespace swift { 13 | namespace codegen { 14 | 15 | class LWTranslator: public swift::codegen::Translator { 16 | public: 17 | LWTranslator(); 18 | ~LWTranslator(); 19 | }; 20 | 21 | } /* namespace codegen */ 22 | } /* namespace swift */ 23 | -------------------------------------------------------------------------------- /src/fabrica/PreDeclFactory.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include "../predecl/PreDecl.h" 7 | 8 | namespace swift { 9 | namespace fabrica { 10 | 11 | class PreDeclFactory { 12 | public: 13 | PreDeclFactory(); 14 | ~PreDeclFactory(); 15 | 16 | const predecl::PreDecl* getDecl(std::string name); 17 | 18 | private: 19 | std::map decls; 20 | }; 21 | 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/ir/ArrayExpr.cpp: -------------------------------------------------------------------------------- 1 | #include "ArrayExpr.h" 2 | 3 | namespace swift { 4 | namespace ir { 5 | 6 | ArrayExpr::ArrayExpr() { 7 | } 8 | 9 | ArrayExpr::~ArrayExpr() { 10 | } 11 | 12 | void ArrayExpr::print(FILE* file, int indent) const { 13 | fprintf(file, "%*sArrayExpr:\n", indent, ""); 14 | for (size_t i = 0; i < argSize(); i++) { 15 | fprintf(file, "%*sarg%d: \n", indent + 2, "", (int)i); 16 | get(i)->print(file, indent + 4); 17 | } 18 | } 19 | 20 | std::string ArrayExpr::toString() { 21 | std::string ret = "["; 22 | for (size_t i = 0; i < args.size(); ++i) { 23 | if (i > 0) ret.push_back(','); 24 | ret.append(args[i]->toString()); 25 | } 26 | ret.push_back(']'); 27 | return ret; 28 | } 29 | 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/ir/ArrayExpr.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Expr.h" 3 | #include "IRForwardDecl.h" 4 | 5 | namespace swift { 6 | namespace ir { 7 | class ArrayExpr: public swift::ir::Expr { 8 | public: 9 | ArrayExpr(); 10 | virtual ~ArrayExpr(); 11 | virtual std::string toString(); 12 | // For Debugging Use 13 | void print(FILE* file, int indent) const; 14 | }; 15 | 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/ir/ArrayTy.cpp: -------------------------------------------------------------------------------- 1 | #include "ArrayTy.h" 2 | 3 | namespace swift { 4 | namespace ir { 5 | ArrayTy::ArrayTy(const Ty* base, int dim) : 6 | Ty(ir::IRConstant::ARRAY), base(base), dim(dim) { 7 | } 8 | 9 | ArrayTy::~ArrayTy() { 10 | } 11 | 12 | const Ty* ArrayTy::getBase() const { 13 | return base; 14 | } 15 | 16 | int ArrayTy::getDim() const { 17 | return dim; 18 | } 19 | 20 | std::string ArrayTy::toString() const { 21 | std::string ret; 22 | for (int i = 0; i < dim; i++) 23 | ret.append("vector<"); 24 | ret.append(base->toString()); 25 | for (int i = 0; i < dim; i++) 26 | ret.push_back('>'); 27 | return ret; 28 | } 29 | 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/ir/ArrayTy.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "IRForwardDecl.h" 6 | #include "Ty.h" 7 | 8 | namespace swift { 9 | namespace ir { 10 | 11 | class ArrayTy: public swift::ir::Ty { 12 | public: 13 | ArrayTy(const Ty* base, int dim); 14 | virtual ~ArrayTy(); 15 | 16 | const Ty* getBase() const; 17 | int getDim() const; 18 | 19 | virtual std::string toString() const; 20 | 21 | private: 22 | const Ty* base; 23 | int dim; 24 | }; 25 | 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/ir/BoolLiteral.cpp: -------------------------------------------------------------------------------- 1 | #include "BoolLiteral.h" 2 | 3 | #include "IRConst.h" 4 | 5 | namespace swift { 6 | namespace ir { 7 | BoolLiteral::BoolLiteral(bool v) : 8 | ConstSymbol(IRConstant::BOOLLITERAL), value(v) { 9 | } 10 | 11 | BoolLiteral::~BoolLiteral() { 12 | } 13 | 14 | bool BoolLiteral::getValue() const { 15 | return value; 16 | } 17 | 18 | void BoolLiteral::print(FILE* file, int indent) const { 19 | fprintf(file, "%*sBoolLiteral: %s\n", indent, "", 20 | (value ? "true" : "false")); 21 | } 22 | 23 | std::string BoolLiteral::toString() { 24 | return value ? "'true" : "'false"; 25 | } 26 | 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/ir/BoolLiteral.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ConstSymbol.h" 3 | 4 | namespace swift { 5 | namespace ir { 6 | 7 | class BoolLiteral: public swift::ir::ConstSymbol { 8 | public: 9 | BoolLiteral(bool v = false); 10 | virtual ~BoolLiteral(); 11 | 12 | bool getValue() const; 13 | 14 | virtual std::string toString(); 15 | void print(FILE* file, int indent) const; 16 | 17 | private: 18 | bool value; 19 | }; 20 | 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/ir/CardExpr.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Expr.h" 3 | #include "IRForwardDecl.h" 4 | 5 | namespace swift { 6 | namespace ir { 7 | 8 | class CardExpr: public swift::ir::Expr { 9 | public: 10 | CardExpr(); 11 | virtual ~CardExpr(); 12 | 13 | const Ty* getType() const; 14 | void setBody(std::shared_ptr b); 15 | std::shared_ptr getBody() const; 16 | 17 | virtual std::string toString(); 18 | void print(FILE* file, int indent) const; 19 | 20 | private: 21 | const Ty* referTyp; 22 | std::shared_ptr body; 23 | }; 24 | 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/ir/Clause.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Semant.cpp 3 | * 4 | * Created on: Nov 2, 2013 5 | * Author: leili 6 | */ 7 | #include "Clause.h" 8 | 9 | #include "Ty.h" 10 | #include "ArrayTy.h" 11 | #include "SetTy.h" 12 | 13 | namespace swift { 14 | namespace ir { 15 | Clause::Clause(const Ty* typ) : 16 | typ(typ) { 17 | _is_random = false; 18 | } 19 | 20 | Clause::~Clause() { 21 | } 22 | 23 | void Clause::setTyp(const Ty* ty) { 24 | typ = ty; 25 | } 26 | 27 | const Ty* Clause::getTyp() const { 28 | return typ; 29 | } 30 | 31 | void Clause::setRandom(bool r) { 32 | _is_random = r; 33 | } 34 | 35 | bool Clause::isRandom() { 36 | return _is_random; 37 | } 38 | 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/ir/Clause.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Semant.h 3 | * 4 | * Created on: Nov 2, 2013 5 | * Author: leili 6 | */ 7 | 8 | #pragma once 9 | 10 | #include "IRForwardDecl.h" 11 | 12 | namespace swift { 13 | namespace ir { 14 | 15 | class Clause { 16 | public: 17 | Clause(const Ty* typ = NULL); 18 | virtual ~Clause(); 19 | void setTyp(const Ty* typ); 20 | const Ty* getTyp() const; 21 | 22 | void setRandom(bool r); 23 | bool isRandom(); 24 | 25 | // For Debugging Use 26 | virtual void print(FILE* file, int indent) const { 27 | } 28 | ; 29 | private: 30 | const Ty* typ; 31 | bool _is_random; 32 | }; 33 | 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/ir/CondSet.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "IRForwardDecl.h" 4 | #include "SetExpr.h" 5 | 6 | #include 7 | 8 | namespace swift { 9 | namespace ir { 10 | 11 | class CondSet: public swift::ir::SetExpr { 12 | public: 13 | CondSet(std::shared_ptr var, std::shared_ptr func, std::shared_ptr cond = nullptr); 14 | virtual ~CondSet(); 15 | 16 | const std::shared_ptr& getVar() const; 17 | std::shared_ptr getFunc() const; 18 | void setFunc(std::shared_ptr f); 19 | std::shared_ptr getCond() const; 20 | void setCond(std::shared_ptr c); 21 | 22 | virtual std::string toString(); 23 | void print(FILE* file, int indent) const; 24 | 25 | private: 26 | std::shared_ptr var; 27 | int func_id, cond_id; 28 | }; 29 | 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/ir/ConstSymbol.cpp: -------------------------------------------------------------------------------- 1 | #include "ConstSymbol.h" 2 | 3 | namespace swift { 4 | namespace ir { 5 | ConstSymbol::ConstSymbol(IRConstant kind) : 6 | kind(kind) { 7 | } 8 | 9 | ConstSymbol::~ConstSymbol() { 10 | } 11 | 12 | IRConstant ConstSymbol::getKind() const { 13 | return kind; 14 | } 15 | 16 | void ConstSymbol::print(FILE* file, int indent) const { 17 | fprintf(file, "%*s(ConstSymbol: %d\n", indent, "", kind); 18 | if (argSize() > 0 && get(0) != NULL) { 19 | get(0)->print(file, indent + 2); 20 | } 21 | fprintf(file, "%*s)\n", indent, ""); 22 | } 23 | 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/ir/ConstSymbol.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Expr.h" 4 | #include "IRConst.h" 5 | #include "IRForwardDecl.h" 6 | 7 | namespace swift { 8 | namespace ir { 9 | 10 | class ConstSymbol: public swift::ir::Expr { 11 | public: 12 | ConstSymbol(IRConstant typ); 13 | virtual ~ConstSymbol(); 14 | 15 | IRConstant getKind() const; 16 | 17 | virtual void print(FILE* file, int indent) const; 18 | 19 | private: 20 | IRConstant kind; 21 | }; 22 | 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/ir/DoubleLiteral.cpp: -------------------------------------------------------------------------------- 1 | #include "DoubleLiteral.h" 2 | 3 | #include "IRConst.h" 4 | 5 | namespace swift { 6 | namespace ir { 7 | 8 | DoubleLiteral::DoubleLiteral(double v) : 9 | ConstSymbol(IRConstant::DOUBLELITERAL), value(v) { 10 | } 11 | 12 | DoubleLiteral::~DoubleLiteral() { 13 | } 14 | 15 | double DoubleLiteral::getValue() const { 16 | return value; 17 | } 18 | 19 | void DoubleLiteral::print(FILE* file, int indent) const { 20 | fprintf(file, "%*sDoubleLiteral: %f \n", indent, "", value); 21 | } 22 | 23 | std::string DoubleLiteral::toString() { 24 | return std::to_string(value); 25 | } 26 | 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/ir/DoubleLiteral.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ConstSymbol.h" 3 | 4 | namespace swift { 5 | namespace ir { 6 | 7 | class DoubleLiteral: public swift::ir::ConstSymbol { 8 | public: 9 | DoubleLiteral(double v = 0); 10 | virtual ~DoubleLiteral(); 11 | 12 | double getValue() const; 13 | 14 | virtual std::string toString(); 15 | void print(FILE* file, int indent) const; 16 | 17 | private: 18 | double value; 19 | }; 20 | 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/ir/Expr.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Expr.cpp 3 | * 4 | * Created on: Nov 2, 2013 5 | * Author: leili 6 | */ 7 | #include "Expr.h" 8 | 9 | namespace swift { 10 | namespace ir { 11 | Expr::Expr() { 12 | } 13 | 14 | Expr::~Expr() { 15 | } 16 | 17 | void Expr::addArg(std::shared_ptr expr) { 18 | args.push_back(expr); 19 | } 20 | 21 | void Expr::setArgs(std::vector> a) { 22 | args = a; 23 | } 24 | 25 | const std::vector>& Expr::getArgs() const { 26 | return args; 27 | } 28 | 29 | size_t Expr::argSize() const { 30 | return args.size(); 31 | } 32 | 33 | std::shared_ptr Expr::get(size_t k) const { 34 | return args[k]; 35 | } 36 | 37 | std::string Expr::toString() { 38 | return ""; 39 | } 40 | 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/ir/Expr.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Expr.h 3 | * 4 | * Created on: Nov 2, 2013 5 | * Author: leili 6 | */ 7 | 8 | #pragma once 9 | #include 10 | #include 11 | 12 | #include "Clause.h" 13 | #include "IRForwardDecl.h" 14 | 15 | namespace swift { 16 | namespace ir { 17 | class Expr: public Clause { 18 | public: 19 | Expr(); 20 | virtual ~Expr(); 21 | virtual void addArg(std::shared_ptr expr); 22 | void setArgs(std::vector > a); 23 | const std::vector >& getArgs() const; 24 | std::shared_ptr get(size_t k) const; 25 | size_t argSize() const; 26 | virtual std::string toString(); 27 | protected: 28 | std::vector > args; 29 | }; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/ir/InstSymbol.cpp: -------------------------------------------------------------------------------- 1 | #include "InstSymbol.h" 2 | 3 | #include "TypeDomain.h" 4 | 5 | namespace swift { 6 | namespace ir { 7 | InstSymbol::InstSymbol(std::shared_ptr refer, size_t id) : 8 | refer(refer), id(id) { 9 | } 10 | 11 | InstSymbol::~InstSymbol() { 12 | } 13 | 14 | std::shared_ptr InstSymbol::getRefer() const { 15 | return refer; 16 | } 17 | 18 | size_t InstSymbol::getID() const { 19 | return id; 20 | } 21 | 22 | void InstSymbol::print(FILE* file, int indent) const { 23 | fprintf(file, "%*sInstSymbol: %s[%d]\n", indent, "", 24 | refer->getName().c_str(), (int)id); 25 | } 26 | 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/ir/InstSymbol.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include "IRForwardDecl.h" 4 | 5 | namespace swift { 6 | namespace ir { 7 | class InstSymbol { 8 | public: 9 | InstSymbol(std::shared_ptr refer, size_t id); 10 | virtual ~InstSymbol(); 11 | 12 | std::shared_ptr getRefer() const; 13 | size_t getID() const; 14 | void print(FILE*, int) const; 15 | 16 | private: 17 | std::shared_ptr refer; 18 | size_t id; 19 | }; 20 | 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/ir/InstSymbolRef.cpp: -------------------------------------------------------------------------------- 1 | #include "InstSymbolRef.h" 2 | #include "TypeDomain.h" 3 | 4 | namespace swift { 5 | namespace ir { 6 | InstSymbolRef::InstSymbolRef(const InstSymbol* inst) : 7 | ConstSymbol(IRConstant::INSTANCE), inst(inst) { 8 | } 9 | 10 | InstSymbolRef::~InstSymbolRef() { 11 | } 12 | 13 | const InstSymbol* InstSymbolRef::getInst() const { 14 | return inst; 15 | } 16 | 17 | void InstSymbolRef::print(FILE* file, int indent) const { 18 | fprintf(file, "%*sInstSymbolRef: \n", indent, ""); 19 | inst->print(file, indent + 2); 20 | } 21 | 22 | std::string InstSymbolRef::toString() { 23 | return inst->getRefer()->getInstName(inst->getID()); 24 | } 25 | 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/ir/InstSymbolRef.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include "ConstSymbol.h" 4 | #include "InstSymbol.h" 5 | 6 | namespace swift { 7 | namespace ir { 8 | class InstSymbolRef: public swift::ir::ConstSymbol { 9 | public: 10 | InstSymbolRef(const InstSymbol* inst = NULL); 11 | virtual ~InstSymbolRef(); 12 | 13 | const InstSymbol* getInst() const; 14 | 15 | virtual std::string toString(); 16 | void print(FILE*, int) const; 17 | 18 | private: 19 | const InstSymbol* inst; 20 | }; 21 | 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/ir/IntLiteral.cpp: -------------------------------------------------------------------------------- 1 | #include "IntLiteral.h" 2 | 3 | #include "IRConst.h" 4 | 5 | namespace swift { 6 | namespace ir { 7 | 8 | IntLiteral::IntLiteral(int v) : 9 | ConstSymbol(IRConstant::INTLITERAL), value(v) { 10 | } 11 | 12 | IntLiteral::~IntLiteral() { 13 | } 14 | 15 | int IntLiteral::getValue() const { 16 | return value; 17 | } 18 | 19 | void IntLiteral::print(FILE* file, int indent) const { 20 | fprintf(file, "%*sIntLiteral: %d\n", indent, "", value); 21 | } 22 | 23 | std::string IntLiteral::toString() { 24 | return std::to_string(value); 25 | } 26 | 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/ir/IntLiteral.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ConstSymbol.h" 4 | 5 | namespace swift { 6 | namespace ir { 7 | 8 | class IntLiteral: public swift::ir::ConstSymbol { 9 | public: 10 | IntLiteral(int v = 0); 11 | virtual ~IntLiteral(); 12 | 13 | int getValue() const; 14 | 15 | virtual std::string toString(); 16 | void print(FILE* file, int indent) const; 17 | private: 18 | int value; 19 | }; 20 | 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/ir/ListSet.cpp: -------------------------------------------------------------------------------- 1 | #include "ListSet.h" 2 | 3 | namespace swift { 4 | namespace ir { 5 | 6 | ListSet::ListSet() : 7 | SetExpr(IRConstant::LISTSET) { 8 | } 9 | 10 | ListSet::~ListSet() { 11 | } 12 | 13 | void ListSet::print(FILE* file, int indent) const { 14 | fprintf(file, "%*sListSet: \n", indent, ""); 15 | for (size_t i = 0; i < argSize(); i++) 16 | if (get(i) != NULL) 17 | get(i)->print(file, indent + 2); 18 | } 19 | 20 | std::string ListSet::toString() { 21 | std::string ret = "{"; 22 | for (size_t i = 0; i < argSize(); ++i) { 23 | if (i > 0) ret.push_back(','); 24 | if (get(i)!=nullptr) 25 | ret.append(get(i)->toString()); 26 | } 27 | ret.push_back('}'); 28 | return ret; 29 | } 30 | 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/ir/ListSet.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "SetExpr.h" 3 | 4 | namespace swift { 5 | namespace ir { 6 | 7 | class ListSet: public swift::ir::SetExpr { 8 | public: 9 | ListSet(); 10 | virtual ~ListSet(); 11 | 12 | virtual std::string toString(); 13 | void print(FILE* file, int indent) const; 14 | }; 15 | 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/ir/MapExpr.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Expr.h" 3 | #include "IRForwardDecl.h" 4 | 5 | namespace swift { 6 | namespace ir { 7 | class MapExpr: public swift::ir::Expr { 8 | public: 9 | MapExpr(); 10 | virtual ~MapExpr(); 11 | 12 | size_t mapSize() const; 13 | void addMap(std::shared_ptr a, std::shared_ptr b); 14 | std::shared_ptr getFrom(size_t k) const; 15 | std::shared_ptr getTo(size_t k) const; 16 | const Ty* getFromTyp() const; 17 | const Ty* getToTyp() const; 18 | void setFromTyp(const Ty* t); 19 | void setToTyp(const Ty* t); 20 | 21 | virtual std::string toString(); 22 | void print(FILE* file, int indent) const; 23 | 24 | private: 25 | const Ty* fromTyp; 26 | const Ty* toTyp; 27 | }; 28 | 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/ir/MapTy.cpp: -------------------------------------------------------------------------------- 1 | #include "MapTy.h" 2 | 3 | namespace swift { 4 | namespace ir { 5 | 6 | MapTy::MapTy(const Ty* from, const Ty* to) : 7 | Ty(IRConstant::MAP), from(from), to(to) { 8 | } 9 | 10 | MapTy::~MapTy() { 11 | } 12 | 13 | const Ty* MapTy::getFrom() const { 14 | return from; 15 | } 16 | 17 | const Ty* MapTy::getTo() const { 18 | return to; 19 | } 20 | 21 | std::string MapTy::toString() const { 22 | return std::string("map<") + (from == NULL ? "NULL" : from->toString()) + "," 23 | + (to == NULL ? "NULL" : to->toString()) + std::string(">"); 24 | } 25 | 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/ir/MapTy.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "IRForwardDecl.h" 4 | #include "Ty.h" 5 | 6 | namespace swift { 7 | namespace ir { 8 | 9 | class MapTy: public swift::ir::Ty { 10 | public: 11 | MapTy(const Ty* from, const Ty* to); 12 | virtual ~MapTy(); 13 | 14 | const Ty* getFrom() const; 15 | const Ty* getTo() const; 16 | 17 | virtual std::string toString() const; 18 | 19 | private: 20 | const Ty* from; 21 | const Ty* to; 22 | }; 23 | 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/ir/MatrixExpr.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Expr.h" 3 | #include "IRForwardDecl.h" 4 | 5 | namespace swift { 6 | namespace ir { 7 | class MatrixExpr: public swift::ir::Expr { 8 | public: 9 | MatrixExpr(); 10 | virtual ~MatrixExpr(); 11 | 12 | virtual std::string toString(); 13 | // For Debugging Use 14 | void print(FILE* file, int indent) const; 15 | 16 | void setRowVecFlag(bool flag); 17 | bool isRowVec(); 18 | void setColVecFlag(bool flag); 19 | bool isColVec(); 20 | 21 | private: 22 | bool flag_colvec; 23 | bool flag_rowvec; 24 | }; 25 | 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/ir/NameTy.cpp: -------------------------------------------------------------------------------- 1 | #include "NameTy.h" 2 | 3 | #include "TypeDomain.h" 4 | 5 | namespace swift { 6 | namespace ir { 7 | NameTy::NameTy(std::shared_ptr refer) : 8 | Ty(IRConstant::NAMETY), refer(refer) { 9 | refer->setType(this); 10 | } 11 | 12 | NameTy::~NameTy() { 13 | } 14 | 15 | std::shared_ptr NameTy::getRefer() const { 16 | return refer; 17 | } 18 | 19 | std::string NameTy::toString() const { 20 | return refer->getName(); 21 | } 22 | 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/ir/NameTy.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include "IRForwardDecl.h" 4 | #include "Ty.h" 5 | 6 | namespace swift { 7 | namespace ir { 8 | 9 | class NameTy: public Ty { 10 | public: 11 | NameTy(std::shared_ptr refer); 12 | virtual ~NameTy(); 13 | 14 | std::shared_ptr getRefer() const; 15 | 16 | virtual std::string toString() const; 17 | 18 | private: 19 | std::shared_ptr refer; 20 | }; 21 | 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/ir/NullSymbol.cpp: -------------------------------------------------------------------------------- 1 | #include "NullSymbol.h" 2 | 3 | #include "IRConst.h" 4 | 5 | namespace swift { 6 | namespace ir { 7 | 8 | NullSymbol::NullSymbol() : 9 | ConstSymbol(IRConstant::NULLSYMBOL) { 10 | } 11 | 12 | NullSymbol::~NullSymbol() { 13 | } 14 | 15 | void NullSymbol::print(FILE* file, int indent) const{ 16 | fprintf(file, "%*sNullSymbol\n", indent, ""); 17 | } 18 | 19 | 20 | std::string NullSymbol::toString() { 21 | return "NULL"; 22 | } 23 | 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/ir/NullSymbol.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ConstSymbol.h" 3 | 4 | namespace swift { 5 | namespace ir { 6 | 7 | class NullSymbol: public swift::ir::ConstSymbol { 8 | public: 9 | NullSymbol(); 10 | virtual ~NullSymbol(); 11 | 12 | virtual std::string toString(); 13 | void print(FILE* file, int indent) const; 14 | }; 15 | 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/ir/OprExpr.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Expr.h" 4 | #include "IRConst.h" 5 | 6 | namespace swift { 7 | namespace ir { 8 | 9 | class OprExpr: public swift::ir::Expr { 10 | public: 11 | OprExpr(IRConstant op); 12 | virtual ~OprExpr(); 13 | 14 | IRConstant getOp() const; 15 | 16 | virtual std::string toString(); 17 | void print(FILE* file, int indent) const ; 18 | 19 | private: 20 | IRConstant op; 21 | }; 22 | 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/ir/SetExpr.cpp: -------------------------------------------------------------------------------- 1 | #include "SetExpr.h" 2 | 3 | namespace swift { 4 | namespace ir { 5 | 6 | SetExpr::SetExpr(IRConstant kind) : 7 | kind(kind) { 8 | } 9 | 10 | SetExpr::~SetExpr() { 11 | } 12 | 13 | IRConstant SetExpr::getKind() const { 14 | return kind; 15 | } 16 | 17 | void SetExpr::print(FILE* file, int indent) const { 18 | 19 | } 20 | 21 | std::string SetExpr::toString() { 22 | return ""; 23 | } 24 | 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/ir/SetExpr.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Expr.h" 3 | #include "IRConst.h" 4 | 5 | namespace swift { 6 | namespace ir { 7 | 8 | class SetExpr: public swift::ir::Expr { 9 | public: 10 | SetExpr(IRConstant kind); 11 | virtual ~SetExpr(); 12 | 13 | IRConstant getKind() const; 14 | virtual void print(FILE* file, int indent) const; 15 | std::string toString(); 16 | private: 17 | IRConstant kind; 18 | }; 19 | 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/ir/SetTy.cpp: -------------------------------------------------------------------------------- 1 | #include "SetTy.h" 2 | 3 | #include "IRConst.h" 4 | 5 | namespace swift { 6 | namespace ir { 7 | SetTy::SetTy(const Ty* refer) : 8 | Ty(IRConstant::SET), refer(refer) { 9 | } 10 | 11 | SetTy::~SetTy() { 12 | } 13 | 14 | const Ty* SetTy::getRefer() const { 15 | return refer; 16 | } 17 | 18 | std::string SetTy::toString() const { 19 | return std::string("set<") + (refer == NULL ? "NULL" : refer->toString()) 20 | + std::string(">"); 21 | } 22 | 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/ir/SetTy.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Ty.h" 3 | #include "IRForwardDecl.h" 4 | 5 | namespace swift { 6 | namespace ir { 7 | 8 | class SetTy: public swift::ir::Ty { 9 | public: 10 | SetTy(const Ty* refer); 11 | virtual ~SetTy(); 12 | 13 | const Ty* getRefer() const; 14 | 15 | virtual std::string toString() const; 16 | 17 | private: 18 | const Ty* refer; 19 | }; 20 | 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/ir/StringLiteral.cpp: -------------------------------------------------------------------------------- 1 | #include "StringLiteral.h" 2 | 3 | #include "IRConst.h" 4 | 5 | namespace swift { 6 | namespace ir { 7 | StringLiteral::StringLiteral(const std::string& v) : 8 | ConstSymbol(IRConstant::STRINGLITERAL), value(v) { 9 | } 10 | 11 | StringLiteral::~StringLiteral() { 12 | } 13 | 14 | const std::string& StringLiteral::getValue() const { 15 | return value; 16 | } 17 | 18 | void StringLiteral::print(FILE* file, int indent) const { 19 | fprintf(file, "%*s(StringLitera: %s)\n", indent, "", value.c_str()); 20 | } 21 | 22 | std::string StringLiteral::toString() { 23 | return "\"" + value + "\""; 24 | } 25 | 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/ir/StringLiteral.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "ConstSymbol.h" 6 | 7 | namespace swift { 8 | namespace ir { 9 | 10 | class StringLiteral: public swift::ir::ConstSymbol { 11 | public: 12 | StringLiteral(const std::string& v = std::string("")); 13 | virtual ~StringLiteral(); 14 | 15 | const std::string& getValue() const; 16 | 17 | virtual std::string toString(); 18 | void print(FILE* file, int indent) const; 19 | 20 | private: 21 | std::string value; 22 | }; 23 | 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/ir/TimestepLiteral.cpp: -------------------------------------------------------------------------------- 1 | #include "TimestepLiteral.h" 2 | 3 | #include "IRConst.h" 4 | 5 | namespace swift { 6 | namespace ir { 7 | 8 | TimestepLiteral::TimestepLiteral(unsigned v) : 9 | ConstSymbol(IRConstant::TIMESTEP), value(v) { 10 | } 11 | 12 | TimestepLiteral::~TimestepLiteral() { 13 | } 14 | 15 | unsigned TimestepLiteral::getValue() const { 16 | return value; 17 | } 18 | 19 | void TimestepLiteral::print(FILE* file, int indent) const { 20 | fprintf(file, "%*sTimestepLiteral: %u\n", indent, "", value); 21 | } 22 | 23 | std::string TimestepLiteral::toString() { 24 | return "@" + std::to_string(value); 25 | } 26 | 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/ir/TimestepLiteral.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ConstSymbol.h" 4 | 5 | namespace swift { 6 | namespace ir { 7 | 8 | class TimestepLiteral: public swift::ir::ConstSymbol { 9 | public: 10 | TimestepLiteral(unsigned v = 0); 11 | virtual ~TimestepLiteral(); 12 | 13 | unsigned getValue() const; 14 | 15 | virtual std::string toString(); 16 | void print(FILE* file, int indent) const ; 17 | private: 18 | unsigned value; 19 | }; 20 | 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/ir/Ty.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Type.h 3 | * 4 | * Created on: Nov 2, 2013 5 | * Author: leili 6 | */ 7 | 8 | #pragma once 9 | 10 | #include 11 | 12 | #include "IRConst.h" 13 | #include "IRForwardDecl.h" 14 | 15 | namespace swift { 16 | namespace ir { 17 | class Ty { 18 | public: 19 | Ty(IRConstant typ = IRConstant::NA); 20 | virtual ~Ty(); 21 | 22 | IRConstant getTyp() const; 23 | 24 | virtual std::string toString() const; 25 | 26 | private: 27 | IRConstant typ; 28 | }; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/ir/UniformChoiceDistr.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Distribution.h" 3 | #include 4 | 5 | namespace swift { 6 | namespace ir { 7 | 8 | class UniformChoiceDistr: public swift::ir::Distribution { 9 | public: 10 | UniformChoiceDistr(std::shared_ptr b); 11 | virtual ~UniformChoiceDistr(); 12 | 13 | std::shared_ptr getBody() const; 14 | 15 | virtual std::string toString(); 16 | void print(FILE* file, int indent) const; 17 | 18 | // Special Randomness checking for Arguments 19 | virtual void processArgRandomness(); 20 | private: 21 | std::shared_ptr body; 22 | }; 23 | 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/ir/VarDecl.cpp: -------------------------------------------------------------------------------- 1 | #include "VarDecl.h" 2 | 3 | #include "Ty.h" 4 | 5 | namespace swift { 6 | namespace ir { 7 | 8 | VarDecl::VarDecl(const Ty* typ, const std::string& var) : 9 | typ(typ), var(var) { 10 | } 11 | 12 | VarDecl::~VarDecl() { 13 | } 14 | 15 | const Ty* VarDecl::getTyp() const { 16 | return typ; 17 | } 18 | 19 | const std::string& VarDecl::getVarName() const { 20 | return var; 21 | } 22 | 23 | std::string VarDecl::toString() const { 24 | return (typ == NULL ? std::string("NULL") : typ->toString()) + " " + var; 25 | } 26 | 27 | std::string VarDecl::toSignature() const { 28 | return (typ == NULL ? std::string("NULL") : typ->toString()); 29 | } 30 | 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/ir/VarDecl.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "IRForwardDecl.h" 6 | 7 | namespace swift { 8 | namespace ir { 9 | 10 | class VarDecl { 11 | public: 12 | VarDecl(const Ty* typ, const std::string& var); 13 | virtual ~VarDecl(); 14 | 15 | const Ty* getTyp() const; 16 | const std::string& getVarName() const; 17 | 18 | virtual std::string toString() const; 19 | virtual std::string toSignature() const; 20 | 21 | private: 22 | const Ty* typ; 23 | std::string var; 24 | }; 25 | 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/ir/VarRefer.cpp: -------------------------------------------------------------------------------- 1 | #include "VarRefer.h" 2 | #include "VarDecl.h" 3 | 4 | namespace swift { 5 | namespace ir { 6 | VarRefer::VarRefer(std::shared_ptr refer) : 7 | refer(refer) { 8 | } 9 | 10 | VarRefer::~VarRefer() { 11 | } 12 | 13 | std::shared_ptr VarRefer::getRefer() const { 14 | return refer; 15 | } 16 | 17 | void VarRefer::print(FILE* file, int indent) const { 18 | fprintf(file, "%*sVarRefer: %s\n", indent, "", refer->toString().c_str()); 19 | } 20 | 21 | std::string VarRefer::toString() { 22 | return refer->toString(); 23 | } 24 | 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/ir/VarRefer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include "Expr.h" 4 | #include "IRForwardDecl.h" 5 | 6 | namespace swift { 7 | namespace ir { 8 | class VarRefer: public swift::ir::Expr { 9 | public: 10 | VarRefer(std::shared_ptr refer = NULL); 11 | virtual ~VarRefer(); 12 | 13 | std::shared_ptr getRefer() const; 14 | 15 | virtual std::string toString(); 16 | void print(FILE* file, int indent) const; 17 | 18 | private: 19 | std::shared_ptr refer; 20 | }; 21 | 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/msg/ErrorMsg.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ErrorMsg.h 3 | * 4 | * Created on: Nov 3, 2013 5 | * Author: leili 6 | */ 7 | 8 | #pragma once 9 | #include 10 | #include 11 | 12 | namespace swift { 13 | namespace msg { 14 | 15 | class ErrorMsg { 16 | public: 17 | ErrorMsg(FILE* file); 18 | ~ErrorMsg(); 19 | void error(int line, int col, const std::string & info); 20 | void warning(int line, int col, const std::string & info); 21 | 22 | bool Okay(); 23 | private: 24 | FILE* file; 25 | int numError; 26 | int numWarn; 27 | }; 28 | 29 | } /* namespace msg */ 30 | } /* namespace swift */ 31 | -------------------------------------------------------------------------------- /src/parse/BLOGSymbol.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | using namespace std; 4 | template 5 | class BLOGSymbol { 6 | int line; 7 | int column; 8 | Object val; 9 | public: 10 | BLOGSymbol(int l, int c, Object v) { 11 | line = l; 12 | column = c; 13 | val = v; 14 | } 15 | int getLine(void) { 16 | return line; 17 | } 18 | int getColumn(void) { 19 | return column; 20 | } 21 | Object getValue(void) { 22 | return val; 23 | } 24 | }; 25 | -------------------------------------------------------------------------------- /src/predecl/BernoulliDistrDecl.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "PreDecl.h" 3 | 4 | namespace swift { 5 | namespace predecl { 6 | 7 | class BernoulliDistrDecl: public swift::predecl::PreDecl { 8 | public: 9 | BernoulliDistrDecl(); 10 | virtual ~BernoulliDistrDecl(); 11 | 12 | virtual std::shared_ptr 13 | getNew(std::vector>& args, 14 | fabrica::TypeFactory* fact) const; 15 | }; 16 | 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/predecl/BetaDistrDecl.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "PreDecl.h" 3 | 4 | namespace swift { 5 | namespace predecl { 6 | 7 | class BetaDistrDecl: public swift::predecl::PreDecl { 8 | public: 9 | BetaDistrDecl(); 10 | virtual ~BetaDistrDecl(); 11 | 12 | virtual std::shared_ptr 13 | getNew(std::vector>& args, 14 | fabrica::TypeFactory* fact) const; 15 | }; 16 | 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/predecl/BinomialDistrDecl.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "PreDecl.h" 3 | 4 | namespace swift { 5 | namespace predecl { 6 | 7 | class BinomialDistrDecl: public swift::predecl::PreDecl { 8 | public: 9 | BinomialDistrDecl(); 10 | virtual ~BinomialDistrDecl(); 11 | 12 | virtual std::shared_ptr 13 | getNew(std::vector>& args, 14 | fabrica::TypeFactory* fact) const; 15 | }; 16 | 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/predecl/BooleanDistrDecl.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "PreDecl.h" 3 | 4 | namespace swift { 5 | namespace predecl { 6 | 7 | class BooleanDistrDecl: public swift::predecl::PreDecl { 8 | public: 9 | BooleanDistrDecl(); 10 | virtual ~BooleanDistrDecl(); 11 | 12 | virtual std::shared_ptr 13 | getNew(std::vector>& args, 14 | fabrica::TypeFactory* fact) const; 15 | }; 16 | 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/predecl/CategoricalDistrDecl.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "PreDecl.h" 3 | 4 | namespace swift { 5 | namespace predecl { 6 | 7 | class CategoricalDistrDecl: public swift::predecl::PreDecl { 8 | public: 9 | CategoricalDistrDecl(); 10 | virtual ~CategoricalDistrDecl(); 11 | 12 | virtual std::shared_ptr 13 | getNew(std::vector>& args, 14 | fabrica::TypeFactory* fact) const; 15 | }; 16 | 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/predecl/DiagGaussianDistrDecl.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "PreDecl.h" 3 | 4 | namespace swift { 5 | namespace predecl { 6 | 7 | class DiagGaussianDistrDecl: public swift::predecl::PreDecl { 8 | public: 9 | DiagGaussianDistrDecl(); 10 | virtual ~DiagGaussianDistrDecl(); 11 | 12 | virtual std::shared_ptr 13 | getNew(std::vector>& args, 14 | fabrica::TypeFactory* fact) const; 15 | }; 16 | 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/predecl/DirichletDistrDecl.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "PreDecl.h" 3 | 4 | namespace swift { 5 | namespace predecl { 6 | 7 | class DirichletDistrDecl: public swift::predecl::PreDecl { 8 | public: 9 | DirichletDistrDecl(); 10 | virtual ~DirichletDistrDecl(); 11 | 12 | virtual std::shared_ptr 13 | getNew(std::vector>& args, 14 | fabrica::TypeFactory* fact) const; 15 | }; 16 | 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/predecl/DiscreteDistrDecl.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "PreDecl.h" 3 | 4 | namespace swift { 5 | namespace predecl { 6 | 7 | class DiscreteDistrDecl: public swift::predecl::PreDecl { 8 | public: 9 | DiscreteDistrDecl(); 10 | virtual ~DiscreteDistrDecl(); 11 | 12 | virtual std::shared_ptr 13 | getNew(std::vector>& args, 14 | fabrica::TypeFactory* fact) const; 15 | }; 16 | 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/predecl/ExponentialDistrDecl.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "PreDecl.h" 3 | 4 | namespace swift { 5 | namespace predecl { 6 | 7 | class ExponentialDistrDecl: public swift::predecl::PreDecl { 8 | public: 9 | ExponentialDistrDecl(); 10 | virtual ~ExponentialDistrDecl(); 11 | 12 | virtual std::shared_ptr 13 | getNew(std::vector>& args, 14 | fabrica::TypeFactory* fact) const; 15 | }; 16 | 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/predecl/GammaDistrDecl.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "PreDecl.h" 3 | 4 | namespace swift { 5 | namespace predecl { 6 | 7 | class GammaDistrDecl: public swift::predecl::PreDecl { 8 | public: 9 | GammaDistrDecl(); 10 | virtual ~GammaDistrDecl(); 11 | 12 | virtual std::shared_ptr 13 | getNew(std::vector>& args, 14 | fabrica::TypeFactory* fact) const; 15 | }; 16 | 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/predecl/GaussianDistrDecl.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "PreDecl.h" 3 | 4 | namespace swift { 5 | namespace predecl { 6 | 7 | class GaussianDistrDecl: public swift::predecl::PreDecl { 8 | public: 9 | GaussianDistrDecl(); 10 | virtual ~GaussianDistrDecl(); 11 | 12 | virtual std::shared_ptr 13 | getNew(std::vector>& args, 14 | fabrica::TypeFactory* fact) const; 15 | }; 16 | 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/predecl/GeometricDistrDecl.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "PreDecl.h" 3 | 4 | namespace swift { 5 | namespace predecl { 6 | 7 | class GeometricDistrDecl: public swift::predecl::PreDecl { 8 | public: 9 | GeometricDistrDecl(); 10 | virtual ~GeometricDistrDecl(); 11 | 12 | virtual std::shared_ptr 13 | getNew(std::vector>& args, 14 | fabrica::TypeFactory* fact) const; 15 | }; 16 | 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/predecl/InvGammaDistrDecl.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "PreDecl.h" 3 | 4 | namespace swift { 5 | namespace predecl { 6 | 7 | class InvGammaDistrDecl: public swift::predecl::PreDecl { 8 | public: 9 | InvGammaDistrDecl(); 10 | virtual ~InvGammaDistrDecl(); 11 | 12 | virtual std::shared_ptr 13 | getNew(std::vector>& args, 14 | fabrica::TypeFactory* fact) const; 15 | }; 16 | 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/predecl/InvWishartDistrDecl.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "PreDecl.h" 3 | 4 | namespace swift { 5 | namespace predecl { 6 | 7 | class InvWishartDistrDecl: public swift::predecl::PreDecl { 8 | public: 9 | InvWishartDistrDecl(); 10 | virtual ~InvWishartDistrDecl(); 11 | 12 | virtual std::shared_ptr 13 | getNew(std::vector>& args, 14 | fabrica::TypeFactory* fact) const; 15 | }; 16 | 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/predecl/LaplaceDistrDecl.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "PreDecl.h" 3 | 4 | namespace swift { 5 | namespace predecl { 6 | 7 | class LaplaceDistrDecl: public swift::predecl::PreDecl { 8 | public: 9 | LaplaceDistrDecl(); 10 | virtual ~LaplaceDistrDecl(); 11 | 12 | virtual std::shared_ptr 13 | getNew(std::vector>& args, 14 | fabrica::TypeFactory* fact) const; 15 | }; 16 | 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/predecl/LoadRealMatrixFuncDecl.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "PreDecl.h" 3 | 4 | namespace swift { 5 | namespace predecl { 6 | 7 | class LoadRealMatrixFuncDecl: public swift::predecl::PreDecl { 8 | public: 9 | LoadRealMatrixFuncDecl(); 10 | virtual ~LoadRealMatrixFuncDecl(); 11 | 12 | virtual std::shared_ptr 13 | getNew(std::vector>& args, 14 | fabrica::TypeFactory* fact) const; 15 | }; 16 | 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/predecl/MathFuncDecl.h: -------------------------------------------------------------------------------- 1 | /* 2 | Interface for all math functions 3 | 1. Real/Int -> Real 4 | 2. Matrix -> Matrix 5 | */ 6 | 7 | #pragma once 8 | #include "PreDecl.h" 9 | 10 | namespace swift { 11 | namespace predecl { 12 | 13 | class MathFuncDecl: public swift::predecl::PreDecl { 14 | public: 15 | MathFuncDecl(std::string name); 16 | virtual ~MathFuncDecl(); 17 | 18 | virtual std::shared_ptr 19 | getNew(std::vector>& args, 20 | fabrica::TypeFactory* fact) const; 21 | }; 22 | 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/predecl/MatrixConstructFuncDecl.h: -------------------------------------------------------------------------------- 1 | /* 2 | Interface for matrix initialization functions 3 | */ 4 | 5 | #pragma once 6 | #include "PreDecl.h" 7 | 8 | namespace swift { 9 | namespace predecl { 10 | 11 | class MatrixConstructFuncDecl: public swift::predecl::PreDecl { 12 | public: 13 | MatrixConstructFuncDecl(std::string name); 14 | virtual ~MatrixConstructFuncDecl(); 15 | 16 | virtual std::shared_ptr 17 | getNew(std::vector>& args, 18 | fabrica::TypeFactory* fact) const; 19 | }; 20 | 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/predecl/MatrixIntFuncDecl.h: -------------------------------------------------------------------------------- 1 | /* 2 | Interface for all matrix functions whose return value is Real 3 | */ 4 | 5 | #pragma once 6 | #include "PreDecl.h" 7 | 8 | namespace swift { 9 | namespace predecl { 10 | 11 | class MatrixIntFuncDecl: public swift::predecl::PreDecl { 12 | public: 13 | MatrixIntFuncDecl(std::string name); 14 | virtual ~MatrixIntFuncDecl(); 15 | 16 | virtual std::shared_ptr 17 | getNew(std::vector>& args, 18 | fabrica::TypeFactory* fact) const; 19 | }; 20 | 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/predecl/MatrixMatrixFuncDecl.h: -------------------------------------------------------------------------------- 1 | /* 2 | Interface for all matrix functions whose return value is also matrix 3 | */ 4 | 5 | #pragma once 6 | #include "PreDecl.h" 7 | 8 | namespace swift { 9 | namespace predecl { 10 | 11 | class MatrixMatrixFuncDecl: public swift::predecl::PreDecl { 12 | public: 13 | MatrixMatrixFuncDecl(std::string name); 14 | virtual ~MatrixMatrixFuncDecl(); 15 | 16 | virtual std::shared_ptr 17 | getNew(std::vector>& args, 18 | fabrica::TypeFactory* fact) const; 19 | }; 20 | 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/predecl/MatrixRealFuncDecl.h: -------------------------------------------------------------------------------- 1 | /* 2 | Interface for all matrix functions whose return value is Real 3 | */ 4 | 5 | #pragma once 6 | #include "PreDecl.h" 7 | 8 | namespace swift { 9 | namespace predecl { 10 | 11 | class MatrixRealFuncDecl: public swift::predecl::PreDecl { 12 | public: 13 | MatrixRealFuncDecl(std::string name); 14 | virtual ~MatrixRealFuncDecl(); 15 | 16 | virtual std::shared_ptr 17 | getNew(std::vector>& args, 18 | fabrica::TypeFactory* fact) const; 19 | }; 20 | 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/predecl/MatrixStackFuncDecl.h: -------------------------------------------------------------------------------- 1 | /* 2 | Interface for matrix stacking functions which takes in a list of matrix 3 | and returns a matrix 4 | */ 5 | 6 | #pragma once 7 | #include "PreDecl.h" 8 | 9 | namespace swift { 10 | namespace predecl { 11 | 12 | class MatrixStackFuncDecl: public swift::predecl::PreDecl { 13 | public: 14 | MatrixStackFuncDecl(std::string name); 15 | virtual ~MatrixStackFuncDecl(); 16 | 17 | virtual std::shared_ptr 18 | getNew(std::vector>& args, 19 | fabrica::TypeFactory* fact) const; 20 | }; 21 | 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/predecl/MatrixSubsetFuncDecl.h: -------------------------------------------------------------------------------- 1 | /* 2 | Interface for matrix subset functions 3 | */ 4 | 5 | #pragma once 6 | #include "PreDecl.h" 7 | 8 | namespace swift { 9 | namespace predecl { 10 | 11 | class MatrixSubsetFuncDecl: public swift::predecl::PreDecl { 12 | private: 13 | int n_args; 14 | public: 15 | MatrixSubsetFuncDecl(std::string name, int n_args); 16 | virtual ~MatrixSubsetFuncDecl(); 17 | 18 | virtual std::shared_ptr 19 | getNew(std::vector>& args, 20 | fabrica::TypeFactory* fact) const; 21 | }; 22 | 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/predecl/MultinomialDistrDecl.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "PreDecl.h" 3 | 4 | namespace swift { 5 | namespace predecl { 6 | 7 | class MultinomialDistrDecl: public swift::predecl::PreDecl { 8 | public: 9 | MultinomialDistrDecl(); 10 | virtual ~MultinomialDistrDecl(); 11 | 12 | virtual std::shared_ptr 13 | getNew(std::vector>& args, 14 | fabrica::TypeFactory* fact) const; 15 | }; 16 | 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/predecl/MultivarGaussianDistrDecl.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "PreDecl.h" 3 | 4 | namespace swift { 5 | namespace predecl { 6 | 7 | class MultivarGaussianDistrDecl: public swift::predecl::PreDecl { 8 | public: 9 | MultivarGaussianDistrDecl(); 10 | virtual ~MultivarGaussianDistrDecl(); 11 | 12 | virtual std::shared_ptr 13 | getNew(std::vector>& args, 14 | fabrica::TypeFactory* fact) const; 15 | }; 16 | 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/predecl/PoissonDistrDecl.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "PreDecl.h" 3 | 4 | namespace swift { 5 | namespace predecl { 6 | 7 | class PoissonDistrDecl: public swift::predecl::PreDecl { 8 | public: 9 | PoissonDistrDecl(); 10 | virtual ~PoissonDistrDecl(); 11 | 12 | virtual std::shared_ptr 13 | getNew(std::vector>& args, 14 | fabrica::TypeFactory* fact) const; 15 | }; 16 | 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/predecl/PreDecl.cpp: -------------------------------------------------------------------------------- 1 | #include "PreDecl.h" 2 | 3 | namespace swift { 4 | namespace predecl { 5 | 6 | PreDecl::PreDecl(const std::string& name) : 7 | name(name) { 8 | } 9 | 10 | PreDecl::~PreDecl() { 11 | } 12 | 13 | const std::string& PreDecl::getName() const { 14 | return name; 15 | } 16 | 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/predecl/PreDecl.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #include "../ir/Distribution.h" 8 | #include "../ir/Expr.h" 9 | #include "../fabrica/TypeFactory.h" 10 | 11 | namespace swift { 12 | namespace predecl { 13 | 14 | class PreDecl { 15 | public: 16 | PreDecl(const std::string& name); 17 | virtual ~PreDecl(); 18 | 19 | const std::string& getName() const; 20 | virtual std::shared_ptr 21 | getNew(std::vector>& args, 22 | fabrica::TypeFactory* fact) const = 0; 23 | 24 | private: 25 | std::string name; 26 | }; 27 | 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/predecl/PrecisionGaussianDistrDecl.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "PreDecl.h" 3 | 4 | namespace swift { 5 | namespace predecl { 6 | 7 | class PrecisionGaussianDistrDecl: public swift::predecl::PreDecl { 8 | public: 9 | PrecisionGaussianDistrDecl(); 10 | virtual ~PrecisionGaussianDistrDecl(); 11 | 12 | virtual std::shared_ptr 13 | getNew(std::vector>& args, 14 | fabrica::TypeFactory* fact) const; 15 | }; 16 | 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/predecl/PrevFuncDecl.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "PreDecl.h" 3 | 4 | namespace swift { 5 | namespace predecl { 6 | 7 | class PrevFuncDecl: public swift::predecl::PreDecl { 8 | public: 9 | PrevFuncDecl(); 10 | virtual ~PrevFuncDecl(); 11 | 12 | virtual std::shared_ptr 13 | getNew(std::vector>& args, 14 | fabrica::TypeFactory* fact) const; 15 | }; 16 | 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/predecl/SetAggrFuncDecl.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "PreDecl.h" 3 | 4 | namespace swift { 5 | namespace predecl { 6 | 7 | class SetAggrFuncDecl: public swift::predecl::PreDecl { 8 | public: 9 | SetAggrFuncDecl(std::string name); 10 | virtual ~SetAggrFuncDecl(); 11 | 12 | virtual std::shared_ptr 13 | getNew(std::vector>& args, 14 | fabrica::TypeFactory* fact) const; 15 | }; 16 | 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/predecl/ToIntFuncDecl.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "PreDecl.h" 3 | 4 | namespace swift { 5 | namespace predecl { 6 | 7 | class ToIntFuncDecl: public swift::predecl::PreDecl { 8 | public: 9 | ToIntFuncDecl(); 10 | virtual ~ToIntFuncDecl(); 11 | 12 | virtual std::shared_ptr 13 | getNew(std::vector>& args, 14 | fabrica::TypeFactory* fact) const; 15 | }; 16 | 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/predecl/ToMatrixFuncDecl.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "PreDecl.h" 3 | 4 | namespace swift { 5 | namespace predecl { 6 | 7 | class ToMatrixFuncDecl: public swift::predecl::PreDecl { 8 | public: 9 | ToMatrixFuncDecl(); 10 | virtual ~ToMatrixFuncDecl(); 11 | 12 | virtual std::shared_ptr 13 | getNew(std::vector>& args, 14 | fabrica::TypeFactory* fact) const; 15 | }; 16 | 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/predecl/ToRealFuncDecl.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "PreDecl.h" 3 | 4 | namespace swift { 5 | namespace predecl { 6 | 7 | class ToRealFuncDecl: public swift::predecl::PreDecl { 8 | public: 9 | ToRealFuncDecl(); 10 | virtual ~ToRealFuncDecl(); 11 | 12 | virtual std::shared_ptr 13 | getNew(std::vector>& args, 14 | fabrica::TypeFactory* fact) const; 15 | }; 16 | 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/predecl/ToStringFuncDecl.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "PreDecl.h" 3 | 4 | namespace swift { 5 | namespace predecl { 6 | 7 | class ToStringFuncDecl: public swift::predecl::PreDecl { 8 | public: 9 | ToStringFuncDecl(); 10 | virtual ~ToStringFuncDecl(); 11 | 12 | virtual std::shared_ptr 13 | getNew(std::vector>& args, 14 | fabrica::TypeFactory* fact) const; 15 | }; 16 | 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/predecl/TruncatedGaussDistrDecl.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "PreDecl.h" 3 | 4 | namespace swift { 5 | namespace predecl { 6 | 7 | class TruncatedGaussDistrDecl: public swift::predecl::PreDecl { 8 | public: 9 | TruncatedGaussDistrDecl(); 10 | virtual ~TruncatedGaussDistrDecl(); 11 | 12 | virtual std::shared_ptr 13 | getNew(std::vector>& args, 14 | fabrica::TypeFactory* fact) const; 15 | }; 16 | 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/predecl/UniformChoiceDistrDecl.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "PreDecl.h" 3 | 4 | namespace swift { 5 | namespace predecl { 6 | 7 | class UniformChoiceDistrDecl: public swift::predecl::PreDecl { 8 | public: 9 | UniformChoiceDistrDecl(); 10 | virtual ~UniformChoiceDistrDecl(); 11 | 12 | virtual std::shared_ptr 13 | getNew(std::vector>& args, 14 | fabrica::TypeFactory* fact) const; 15 | }; 16 | 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/predecl/UniformIntDistrDecl.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "PreDecl.h" 3 | 4 | namespace swift { 5 | namespace predecl { 6 | 7 | class UniformIntDistrDecl: public swift::predecl::PreDecl { 8 | public: 9 | UniformIntDistrDecl(); 10 | virtual ~UniformIntDistrDecl(); 11 | 12 | virtual std::shared_ptr 13 | getNew(std::vector>& args, 14 | fabrica::TypeFactory* fact) const; 15 | }; 16 | 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/predecl/UniformRealDistrDecl.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "PreDecl.h" 3 | 4 | namespace swift { 5 | namespace predecl { 6 | 7 | class UniformRealDistrDecl: public swift::predecl::PreDecl { 8 | public: 9 | UniformRealDistrDecl(); 10 | virtual ~UniformRealDistrDecl(); 11 | 12 | virtual std::shared_ptr 13 | getNew(std::vector>& args, 14 | fabrica::TypeFactory* fact) const; 15 | }; 16 | 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/predecl/UniformVectorDistrDecl.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "PreDecl.h" 3 | 4 | namespace swift { 5 | namespace predecl { 6 | 7 | class UniformVectorDistrDecl: public swift::predecl::PreDecl { 8 | public: 9 | UniformVectorDistrDecl(); 10 | virtual ~UniformVectorDistrDecl(); 11 | 12 | virtual std::shared_ptr 13 | getNew(std::vector>& args, 14 | fabrica::TypeFactory* fact) const; 15 | }; 16 | 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/random/Bernoulli.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Bernoulli.h 3 | * 4 | * Created on: Feb 6, 2014 5 | * Author: yiwu 6 | */ 7 | 8 | #pragma once 9 | #include 10 | #include "SwiftDistribution.h" 11 | 12 | namespace swift { 13 | namespace random { 14 | 15 | class Bernoulli: public swift::random::SwiftDistribution { 16 | public: 17 | Bernoulli(); 18 | virtual ~Bernoulli(); 19 | void init(double p); 20 | int gen(); 21 | double likeli(const int& x); 22 | double loglikeli(const int& x); 23 | private: 24 | std::uniform_real_distribution dist; 25 | double p; 26 | double logp; 27 | double log1_p; 28 | bool is_loglike_ok; 29 | }; 30 | 31 | } /* namespace random */ 32 | } /* namespace swift */ 33 | -------------------------------------------------------------------------------- /src/random/Beta.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Beta.h 3 | * 4 | * Created on: Feb 6, 2014 5 | * Author: yiwu 6 | */ 7 | 8 | #pragma once 9 | #include 10 | #include "SwiftDistribution.h" 11 | 12 | namespace swift { 13 | namespace random { 14 | 15 | class Beta: public swift::random::SwiftDistribution { 16 | public: 17 | Beta(); 18 | virtual ~Beta(); 19 | void init(double alpha = 2.0, double beta = 2.0); 20 | double gen(); 21 | double likeli(const double& x); 22 | double loglikeli(const double& x); 23 | private: 24 | std::gamma_distribution dist_alpha, dist_beta; 25 | double alpha, beta; 26 | double coef, log_coef; 27 | bool is_dist_ok, is_like_ok, is_loglike_ok; 28 | }; 29 | 30 | } /* namespace random */ 31 | } /* namespace swift */ 32 | -------------------------------------------------------------------------------- /src/random/Binomial.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Binomial.h 3 | * 4 | * Created on: Oct 8, 2014 5 | * Author: yiwu 6 | */ 7 | 8 | #pragma once 9 | #include 10 | #include "SwiftDistribution.h" 11 | 12 | namespace swift { 13 | namespace random { 14 | 15 | class Binomial: public swift::random::SwiftDistribution { 16 | public: 17 | Binomial(); 18 | virtual ~Binomial(); 19 | void init(int n, double p); 20 | int gen(); 21 | double likeli(const int& x); 22 | double loglikeli(const int& x); 23 | private: 24 | std::binomial_distribution dist; 25 | int n; 26 | double p, logp, logq; 27 | long double logfactn; 28 | bool is_dist_ok, is_loglike_ok; 29 | }; 30 | 31 | } /* namespace random */ 32 | } /* namespace swift */ 33 | -------------------------------------------------------------------------------- /src/random/BooleanDistrib.h: -------------------------------------------------------------------------------- 1 | /* 2 | * BooleanDistrib.h 3 | * 4 | * Created on: Feb 6, 2014 5 | * Author: yiwu 6 | */ 7 | 8 | #pragma once 9 | #include 10 | #include "SwiftDistribution.h" 11 | 12 | namespace swift { 13 | namespace random { 14 | 15 | class BooleanDistrib: public swift::random::SwiftDistribution { 16 | public: 17 | BooleanDistrib(); 18 | virtual ~BooleanDistrib(); 19 | void init(double p); 20 | bool gen(); 21 | double likeli(const bool& x); 22 | double loglikeli(const bool& x); 23 | private: 24 | std::uniform_real_distribution dist; 25 | double p; 26 | double logp; 27 | double log1_p; 28 | bool is_loglike_ok; 29 | }; 30 | 31 | } /* namespace random */ 32 | } /* namespace swift */ 33 | -------------------------------------------------------------------------------- /src/random/Exponential.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Exponential.h 3 | * 4 | * Created on: Feb 25, 2016 5 | * Author: nishdesai 6 | */ 7 | #pragma once 8 | #include 9 | #include "SwiftDistribution.h" 10 | 11 | namespace swift { 12 | namespace random { 13 | 14 | class Exponential: public swift::random::SwiftDistribution { 15 | public: 16 | Exponential(); 17 | virtual ~Exponential(); 18 | void init(double lambda = 1.0); 19 | double gen(); 20 | double likeli(const double& x); 21 | double loglikeli(const double& x); 22 | private: 23 | std::exponential_distribution dist; 24 | double lambda, log_lambda; 25 | bool is_loglike_ok; 26 | }; 27 | 28 | } /* namespace random */ 29 | } /* namespace swift */ 30 | -------------------------------------------------------------------------------- /src/random/Gamma.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Gamma.h 3 | * 4 | * Created on: Feb 6, 2014 5 | * Author: yiwu 6 | */ 7 | 8 | #pragma once 9 | #include 10 | #include "SwiftDistribution.h" 11 | 12 | namespace swift { 13 | namespace random { 14 | 15 | class Gamma: public swift::random::SwiftDistribution { 16 | public: 17 | Gamma(); 18 | virtual ~Gamma(); 19 | void init(double alpha = 1.0, double beta = 1.0); 20 | double gen(); 21 | double likeli(const double& x); 22 | double loglikeli(const double& x); 23 | private: 24 | std::gamma_distribution dist; 25 | double alpha, beta, inv_beta; 26 | double coef, log_coef; 27 | bool is_like_ok, is_loglike_ok; 28 | }; 29 | 30 | } /* namespace random */ 31 | } /* namespace swift */ 32 | 33 | -------------------------------------------------------------------------------- /src/random/Gaussian.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Gaussian.h 3 | * 4 | * Created on: Feb 6, 2014 5 | * Author: yiwu 6 | */ 7 | 8 | #pragma once 9 | #include 10 | #include "SwiftDistribution.h" 11 | 12 | namespace swift { 13 | namespace random { 14 | 15 | class Gaussian: public swift::random::SwiftDistribution { 16 | public: 17 | Gaussian(); 18 | virtual ~Gaussian(); 19 | void init(double mean = 0.0, double stddev = 1.0); 20 | double gen(); 21 | double likeli(const double& x); 22 | double loglikeli(const double& x); 23 | private: 24 | std::normal_distribution dist; 25 | double mean, stddev, var; 26 | double coef, log_coef, scale; 27 | bool is_like_ok, is_loglike_ok; 28 | const double sqrt_2PI; 29 | }; 30 | 31 | } /* namespace random */ 32 | } /* namespace swift */ 33 | -------------------------------------------------------------------------------- /src/random/Geometric.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Geometric.h 3 | * 4 | * Created on: Jan 24, 2014 5 | * Author: leili 6 | */ 7 | 8 | #pragma once 9 | #include 10 | #include "SwiftDistribution.h" 11 | 12 | namespace swift { 13 | namespace random { 14 | 15 | class Geometric: public swift::random::SwiftDistribution { 16 | public: 17 | Geometric(); 18 | virtual ~Geometric(); 19 | void init(double p); 20 | int gen(); 21 | double likeli(const int& x); 22 | double loglikeli(const int& x); 23 | private: 24 | std::geometric_distribution dist; 25 | double p, q; 26 | double logp, logq; 27 | bool is_loglike_ok, is_dist_ok; 28 | }; 29 | 30 | } /* namespace random */ 31 | } /* namespace swift */ 32 | -------------------------------------------------------------------------------- /src/random/InvGamma.h: -------------------------------------------------------------------------------- 1 | /* 2 | * InvGamma.h 3 | * 4 | * Created on: Feb 6, 2014 5 | * Author: yiwu 6 | */ 7 | 8 | #pragma once 9 | #include 10 | #include "SwiftDistribution.h" 11 | 12 | namespace swift { 13 | namespace random { 14 | 15 | class InvGamma: public swift::random::SwiftDistribution { 16 | public: 17 | InvGamma(); 18 | virtual ~InvGamma(); 19 | void init(double alpha = 1.0, double beta = 1.0); 20 | double gen(); 21 | double likeli(const double& x); 22 | double loglikeli(const double& x); 23 | private: 24 | std::gamma_distribution dist; 25 | double alpha, beta, inv_beta; 26 | double coef, log_coef; 27 | bool is_like_ok, is_loglike_ok; 28 | }; 29 | 30 | } /* namespace random */ 31 | } /* namespace swift */ 32 | 33 | -------------------------------------------------------------------------------- /src/random/Laplace.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Laplace.h 3 | * 4 | * Created on: Feb 25, 2016 5 | * Author: nishdesai 6 | */ 7 | #pragma once 8 | #include 9 | #include "SwiftDistribution.h" 10 | 11 | namespace swift { 12 | namespace random { 13 | 14 | class Laplace: public swift::random::SwiftDistribution { 15 | public: 16 | Laplace(); 17 | virtual ~Laplace(); 18 | void init(double mu = 0.0, double b = 1); 19 | double gen(); 20 | double likeli(const double& x); 21 | double loglikeli(const double& x); 22 | private: 23 | std::uniform_real_distribution dist; 24 | double mu, b, log_b; 25 | bool is_loglike_ok; 26 | }; 27 | 28 | } /* namespace random */ 29 | } /* namespace swift */ 30 | -------------------------------------------------------------------------------- /src/random/Poisson.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Poisson.h 3 | * 4 | * Created on: Jan 24, 2014 5 | * Author: leili 6 | */ 7 | 8 | #pragma once 9 | #include 10 | #include "SwiftDistribution.h" 11 | 12 | namespace swift { 13 | namespace random { 14 | 15 | class Poisson: public swift::random::SwiftDistribution { 16 | public: 17 | Poisson(); 18 | virtual ~Poisson(); 19 | void init(double lambda); 20 | int gen(); 21 | double likeli(const int& x); 22 | double loglikeli(const int& x); 23 | private: 24 | std::poisson_distribution dist; 25 | double lambda; 26 | double loglambda; 27 | bool is_dist_ok, is_coef_ok; 28 | }; 29 | 30 | } /* namespace random */ 31 | } /* namespace swift */ 32 | -------------------------------------------------------------------------------- /src/random/UniformInt.h: -------------------------------------------------------------------------------- 1 | /* 2 | * UniformInt.h 3 | * 4 | * Created on: Jan 24, 2014 5 | * Author: leili 6 | */ 7 | 8 | #pragma once 9 | #include 10 | #include "SwiftDistribution.h" 11 | 12 | namespace swift { 13 | namespace random { 14 | 15 | class UniformInt: public swift::random::SwiftDistribution { 16 | public: 17 | UniformInt(); 18 | virtual ~UniformInt(); 19 | void init(int a, int b); 20 | int gen(); 21 | double likeli(const int& x); 22 | double loglikeli(const int& x); 23 | private: 24 | std::uniform_int_distribution dist; 25 | int a; 26 | int b; 27 | int det, len; 28 | double loglen; 29 | bool is_loglike_ok, is_dist_ok; 30 | }; 31 | 32 | } /* namespace random */ 33 | } /* namespace swift */ 34 | -------------------------------------------------------------------------------- /src/random/UniformReal.h: -------------------------------------------------------------------------------- 1 | /* 2 | * UniformReal.h 3 | * 4 | * Created on: Mar 16, 2014 5 | * Author: yiwu 6 | */ 7 | 8 | #pragma once 9 | #include 10 | #include "SwiftDistribution.h" 11 | 12 | namespace swift { 13 | namespace random { 14 | 15 | class UniformReal: public swift::random::SwiftDistribution { 16 | public: 17 | UniformReal(); 18 | virtual ~UniformReal(); 19 | void init(double a, double b); 20 | double gen(); 21 | double likeli(const double& x); 22 | double loglikeli(const double& x); 23 | private: 24 | std::uniform_real_distribution dist; 25 | double a; 26 | double b; 27 | double scale, logscale; 28 | bool is_logscale_ok; 29 | }; 30 | 31 | } /* namespace random */ 32 | } /* namespace swift */ 33 | -------------------------------------------------------------------------------- /src/test/absyn/AircraftSimple.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../../absyn/BlogProgram.h" 4 | 5 | namespace test_absyn { 6 | 7 | class AircraftSimple { 8 | swift::absyn::BlogProgram* root; 9 | public: 10 | AircraftSimple(); 11 | ~AircraftSimple(); 12 | void test(FILE *file); 13 | void build(); 14 | swift::absyn::BlogProgram* getRoot(); 15 | }; 16 | 17 | } 18 | -------------------------------------------------------------------------------- /src/test/absyn/BiasedBall.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../../absyn/BlogProgram.h" 4 | 5 | namespace test_absyn { 6 | 7 | class BiasedBall { 8 | swift::absyn::BlogProgram* root; 9 | public: 10 | BiasedBall(); 11 | ~BiasedBall(); 12 | void test(FILE *file); 13 | void build(); 14 | swift::absyn::BlogProgram* getRoot(); 15 | }; 16 | 17 | } 18 | -------------------------------------------------------------------------------- /src/test/absyn/Birthday.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../../absyn/BlogProgram.h" 4 | 5 | namespace test_absyn { 6 | 7 | class Birthday { 8 | swift::absyn::BlogProgram* root; 9 | public: 10 | Birthday(); 11 | ~Birthday(); 12 | void test(FILE *file); 13 | void build(); 14 | swift::absyn::BlogProgram* getRoot(); 15 | }; 16 | 17 | } 18 | -------------------------------------------------------------------------------- /src/test/absyn/DirichletSimpleTest.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../../absyn/BlogProgram.h" 4 | 5 | namespace test_absyn { 6 | 7 | class DirichletSimpleTest { 8 | swift::absyn::BlogProgram* root; 9 | public: 10 | DirichletSimpleTest(); 11 | ~DirichletSimpleTest(); 12 | void test(FILE *file); 13 | void build(); 14 | swift::absyn::BlogProgram* getRoot(); 15 | }; 16 | 17 | } -------------------------------------------------------------------------------- /src/test/absyn/DirichletSimpleTest2.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../../absyn/BlogProgram.h" 4 | 5 | namespace test_absyn { 6 | 7 | class DirichletSimpleTest2 { 8 | swift::absyn::BlogProgram* root; 9 | public: 10 | DirichletSimpleTest2(); 11 | ~DirichletSimpleTest2(); 12 | void test(FILE *file); 13 | void build(); 14 | swift::absyn::BlogProgram* getRoot(); 15 | }; 16 | 17 | } -------------------------------------------------------------------------------- /src/test/absyn/HMM.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | // Test Class for Particle Filtering Algorithm 3 | #include "../../absyn/BlogProgram.h" 4 | 5 | namespace test_absyn { 6 | 7 | class HMM { 8 | swift::absyn::BlogProgram* root; 9 | public: 10 | HMM(); 11 | ~HMM(); 12 | void test(FILE *file); 13 | void build(); 14 | swift::absyn::BlogProgram* getRoot(); 15 | }; 16 | 17 | } 18 | -------------------------------------------------------------------------------- /src/test/absyn/Hurricane.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../../absyn/BlogProgram.h" 4 | 5 | namespace test_absyn { 6 | 7 | class Hurricane { 8 | swift::absyn::BlogProgram* root; 9 | public: 10 | Hurricane(); 11 | ~Hurricane(); 12 | void test(FILE *file); 13 | void build(); 14 | swift::absyn::BlogProgram* getRoot(); 15 | }; 16 | 17 | } -------------------------------------------------------------------------------- /src/test/absyn/MatrixTest.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../../absyn/BlogProgram.h" 4 | 5 | namespace test_absyn { 6 | 7 | class MatrixTest { 8 | swift::absyn::BlogProgram* root; 9 | public: 10 | MatrixTest(); 11 | ~MatrixTest(); 12 | void test(FILE *file); 13 | void build(); 14 | swift::absyn::BlogProgram* getRoot(); 15 | }; 16 | 17 | } -------------------------------------------------------------------------------- /src/test/absyn/MultiCaseSimpleTest.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../../absyn/BlogProgram.h" 4 | 5 | namespace test_absyn { 6 | 7 | class MultiCaseSimpleTest { 8 | swift::absyn::BlogProgram* root; 9 | public: 10 | MultiCaseSimpleTest(); 11 | ~MultiCaseSimpleTest(); 12 | void test(FILE *file); 13 | void build(); 14 | swift::absyn::BlogProgram* getRoot(); 15 | }; 16 | 17 | } -------------------------------------------------------------------------------- /src/test/absyn/MultinomialSimpleTest.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../../absyn/BlogProgram.h" 4 | 5 | namespace test_absyn { 6 | 7 | class MultinomialSimpleTest { 8 | swift::absyn::BlogProgram* root; 9 | public: 10 | MultinomialSimpleTest(); 11 | ~MultinomialSimpleTest(); 12 | void test(FILE *file); 13 | void build(); 14 | swift::absyn::BlogProgram* getRoot(); 15 | }; 16 | 17 | } -------------------------------------------------------------------------------- /src/test/absyn/PoissonBall.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../../absyn/BlogProgram.h" 4 | 5 | namespace test_absyn { 6 | 7 | class PoissonBall { 8 | swift::absyn::BlogProgram* root; 9 | public: 10 | PoissonBall(); 11 | ~PoissonBall(); 12 | void test(FILE *file); 13 | void build(); 14 | swift::absyn::BlogProgram* getRoot(); 15 | }; 16 | 17 | } 18 | -------------------------------------------------------------------------------- /src/test/parse/distinct.in: -------------------------------------------------------------------------------- 1 | distinct Ball a[10], b; -------------------------------------------------------------------------------- /src/test/parse/distinct.out: -------------------------------------------------------------------------------- 1 | (BlogProgram: 2 | (args: 3 | (DistinctDecl: 4 | :type Ball 5 | :var (: 6 | (: a 10 ) 7 | (: b 1 ) 8 | ) 9 | ) 10 | ) 11 | ) 12 | -------------------------------------------------------------------------------- /src/test/parse/evidence.in: -------------------------------------------------------------------------------- 1 | obs Color(b[0]) = Red; -------------------------------------------------------------------------------- /src/test/parse/evidence.out: -------------------------------------------------------------------------------- 1 | (BlogProgram: 2 | (args: 3 | (Evidence: 4 | :left 5 | (FuncApp: 6 | :func Color 7 | (args: 8 | (OpExpr: 9 | :op 16 10 | :left 11 | (VarRef: b ) 12 | :right 13 | (IntLiteral: 0 ) 14 | ) 15 | ) 16 | ) 17 | :right 18 | (VarRef: Red ) 19 | ) 20 | ) 21 | ) 22 | -------------------------------------------------------------------------------- /src/test/parse/fundec.in: -------------------------------------------------------------------------------- 1 | random Ball x ~ UniformChoice({b[0], b[1]}); -------------------------------------------------------------------------------- /src/test/parse/fundec.out: -------------------------------------------------------------------------------- 1 | (BlogProgram: 2 | (args: 3 | (FuncDecl: 4 | :kind random 5 | :type Ball 6 | :func x 7 | expr: 8 | (DistrExpr: 9 | :distr UniformChoice 10 | (args: 11 | (ListSet: (: 12 | (OpExpr: 13 | :op 16 14 | :left 15 | (VarRef: b ) 16 | :right 17 | (IntLiteral: 0 ) 18 | ) 19 | (OpExpr: 20 | :op 16 21 | :left 22 | (VarRef: b ) 23 | :right 24 | (IntLiteral: 1 ) 25 | ) 26 | ) ) 27 | ) 28 | ) 29 | ) 30 | ) 31 | ) 32 | -------------------------------------------------------------------------------- /src/test/parse/ifexp.in: -------------------------------------------------------------------------------- 1 | random PrepLevel Prep(City c) { 2 | if (First == c) then ~ Categorical({High -> 0.5, Low -> 0.5}) 3 | else ~ Categorical({High -> 0.8, Low -> 0.2}) 4 | }; -------------------------------------------------------------------------------- /src/test/parse/map.in: -------------------------------------------------------------------------------- 1 | random Ball x ~ Categorical({b[0]->0.5, b[1]->0.5}); -------------------------------------------------------------------------------- /src/test/parse/numdec.in: -------------------------------------------------------------------------------- 1 | #Blip(Source = a) ~ Poisson(1.0); -------------------------------------------------------------------------------- /src/test/parse/numdec.out: -------------------------------------------------------------------------------- 1 | (BlogProgram: 2 | (args: 3 | (NumStDecl: 4 | :type Blip 5 | (args: 6 | origin# Source var# a ) 7 | :expr 8 | (DistrExpr: 9 | :distr Poisson 10 | (args: 11 | (DoubleLiteral: 1.000000 ) 12 | ) 13 | ) 14 | ) 15 | ) 16 | ) 17 | -------------------------------------------------------------------------------- /src/test/parse/numref.in: -------------------------------------------------------------------------------- 1 | query #{Aircraft a : a != b}; -------------------------------------------------------------------------------- /src/test/parse/numref.out: -------------------------------------------------------------------------------- 1 | (BlogProgram: 2 | (args: 3 | (Query: 4 | :expr 5 | (NumStRef: 6 | (CondSet: 7 | :var 8 | (VarDecl: (: Aircraft a ) ) 9 | :cond 10 | (OpExpr: 11 | :op 7 12 | :left 13 | (VarRef: a ) 14 | :right 15 | (VarRef: b ) 16 | ) 17 | ) 18 | ) 19 | ) 20 | ) 21 | ) 22 | -------------------------------------------------------------------------------- /src/test/parse/origin.in: -------------------------------------------------------------------------------- 1 | origin Aircraft Source(Blip); -------------------------------------------------------------------------------- /src/test/parse/origin.out: -------------------------------------------------------------------------------- 1 | (BlogProgram: 2 | (args: 3 | (OriginDecl: 4 | :func Source 5 | :typ Aircraft 6 | :arg Blip 7 | ) 8 | ) 9 | ) 10 | -------------------------------------------------------------------------------- /src/test/parse/quant.in: -------------------------------------------------------------------------------- 1 | query exists Person x exists Person y (x==y); -------------------------------------------------------------------------------- /src/test/parse/quant.out: -------------------------------------------------------------------------------- 1 | (BlogProgram: 2 | (args: 3 | (Query: 4 | :expr 5 | (QuantExpr: 6 | :typ 19 7 | (VarDecl: (: Person x ) ) 8 | :cond 9 | (QuantExpr: 10 | :typ 19 11 | (VarDecl: (: Person y ) ) 12 | :cond 13 | (OpExpr: 14 | :op 6 15 | :left 16 | (VarRef: x ) 17 | :right 18 | (VarRef: y ) 19 | ) 20 | ) 21 | ) 22 | ) 23 | ) 24 | ) 25 | -------------------------------------------------------------------------------- /src/test/random/TestCategorical.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // TestCategorical.cpp 3 | // swift-project 4 | // 5 | // Created by Lei Li on 1/19/14. 6 | // 7 | // 8 | 9 | #include 10 | #include 11 | #include "../../random/CategoricalDistribution.h" 12 | using namespace std; 13 | 14 | int main() { 15 | swift::random::Categorical cat; 16 | cat.init(std::map({{0, 0.1}, {1, 0.9}})); 17 | int x[2] = {0, 0}; 18 | for (int i=0; i < 1000; i++) 19 | x[cat.gen()]++; 20 | cout << "0:" << x[0] / 1000.0 << endl; 21 | cout << "1:" << x[1] / 1000.0 << endl; 22 | } -------------------------------------------------------------------------------- /src/test/semant/Semant_test.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Semant_test.cpp 3 | * 4 | * Created on: Nov 2, 2013 5 | * Author: leili 6 | */ 7 | 8 | #include "../../semant/Semant.h" 9 | 10 | namespace swift { 11 | 12 | 13 | } /* namespace swift */ 14 | 15 | int main() { 16 | 17 | 18 | } 19 | -------------------------------------------------------------------------------- /src/util/util_conjugate.h: -------------------------------------------------------------------------------- 1 | // 2 | // util_conjugate.h 3 | // swift-project 4 | // conjugate priors for gibbs sampling 5 | // 6 | // Created by Yi Wu on 4/30/15. 7 | // 8 | // 9 | 10 | #pragma once 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | #include "MCMC.h" 24 | #include "../random/InvGamma.h" 25 | 26 | namespace swift { namespace random { 27 | 28 | // Posterior for InvGamma Prior 29 | 30 | 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /swift.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lileicc/swift/57c4a4cd065f1149f86f3d04402f8dbdce1ac5ff/swift.rc -------------------------------------------------------------------------------- /swifty-mh.bat: -------------------------------------------------------------------------------- 1 | swift -e MHSampler -i %1.blog -o %1.cpp -------------------------------------------------------------------------------- /swifty-mh.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ./swift -e MHSampler -i example/$1.blog -o src/$1.cpp --model-output out 4 | 5 | cd src 6 | 7 | g++ -Ofast -std=c++11 $1.cpp random/*.cpp -o $1 -larmadillo 8 | 9 | echo "Running "$1 10 | ./$1 11 | 12 | cd .. 13 | -------------------------------------------------------------------------------- /swifty-pf.bat: -------------------------------------------------------------------------------- 1 | swift -e ParticleFilter -i %1.blog -o %1.cpp -------------------------------------------------------------------------------- /swifty-pf.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ./swift -e ParticleFilter -i example/$1.blog -o src/$1.cpp 4 | 5 | cd src 6 | 7 | g++ -Ofast -std=c++11 $1.cpp random/*.cpp -o $1 -larmadillo 8 | 9 | echo "Running "$1 10 | ./$1 11 | 12 | cd .. 13 | -------------------------------------------------------------------------------- /swifty.bat: -------------------------------------------------------------------------------- 1 | swift -i %* -o _target.cpp 2 | 3 | g++ -std=c++11 -Wall src/random/*.cpp _target.cpp -o _target -O3 4 | 5 | _target 6 | -------------------------------------------------------------------------------- /swifty.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | fname=example/$1.blog 4 | fname=${fname##*/} 5 | fname=${fname%.*} 6 | 7 | if [[ ! -f example/$1.blog ]] ; then 8 | echo 'File' example/$1.blog ' is not there, aborting.' 9 | exit 10 | fi 11 | 12 | ./swift -i example/$1.blog -o src/$fname.cpp --model-output data 13 | 14 | cd src 15 | 16 | g++ -Ofast -std=c++11 $fname.cpp random/*.cpp -o $fname -larmadillo 17 | 18 | mv $fname.cpp ../out/$fname.cpp 19 | mv $fname ../out/$fname 20 | 21 | echo "Running "$fname 22 | cd .. 23 | 24 | ./out/$fname 25 | --------------------------------------------------------------------------------