├── RxODE ├── src │ ├── dparser │ │ ├── tests │ │ │ ├── g11.test.g.2 │ │ │ ├── g11.test.g.3 │ │ │ ├── g15.test.g.1 │ │ │ ├── g2.test.g.1 │ │ │ ├── g26.test.g.1 │ │ │ ├── g30.test.g.1 │ │ │ ├── g48.test.g.1 │ │ │ ├── g8.test.g.1 │ │ │ ├── g1.test.g.1 │ │ │ ├── g11.test.g.1 │ │ │ ├── g21.test.g.1 │ │ │ ├── g22.test.g.1 │ │ │ ├── g23.test.g.1 │ │ │ ├── g35.test.g.1 │ │ │ ├── g38.test.g.1 │ │ │ ├── g38.test.g.flags │ │ │ ├── g39.test.g.1 │ │ │ ├── g41.test.g.1 │ │ │ ├── g42.test.g.1 │ │ │ ├── g44.test.g.1 │ │ │ ├── g45.test.g.1 │ │ │ ├── g5.test.g.1 │ │ │ ├── g51.test.g.1 │ │ │ ├── g6.test.g.1 │ │ │ ├── g7.test.g.2 │ │ │ ├── utf8.test.g.1 │ │ │ ├── g13.test.g.1 │ │ │ ├── g14.test.g.1 │ │ │ ├── g16.test.g.1 │ │ │ ├── g17.test.g.1 │ │ │ ├── g18.test.g.1 │ │ │ ├── g19.test.g.1 │ │ │ ├── g20.test.g.1 │ │ │ ├── g37.test.g.1 │ │ │ ├── g38.test.g.1.flags │ │ │ ├── g4.test.g.1 │ │ │ ├── g40.test.g.1 │ │ │ ├── g42.include.g │ │ │ ├── g43.test.g.2.flags │ │ │ ├── g43.test.g.3.flags │ │ │ ├── g46.test.g.1 │ │ │ ├── g7.test.g.1 │ │ │ ├── sample.test.g.0 │ │ │ ├── sample.test.g.16 │ │ │ ├── sample.test.g.17 │ │ │ ├── sample.test.g.23 │ │ │ ├── sample.test.g.5 │ │ │ ├── sample.test.g.6 │ │ │ ├── sample.test.g.7 │ │ │ ├── g10.test.g.1 │ │ │ ├── sample.test.g.1 │ │ │ ├── sample.test.g.11 │ │ │ ├── sample.test.g.12 │ │ │ ├── sample.test.g.14 │ │ │ ├── sample.test.g.18 │ │ │ ├── sample.test.g.2 │ │ │ ├── sample.test.g.29 │ │ │ ├── sample.test.g.3 │ │ │ ├── sample.test.g.4 │ │ │ ├── g2.test.g │ │ │ ├── g25.test.g.1 │ │ │ ├── g27.test.g.1 │ │ │ ├── g3.test.g │ │ │ ├── g39.test.g │ │ │ ├── g5.test.g │ │ │ ├── sample.test.g.15 │ │ │ ├── sample.test.g.20 │ │ │ ├── sample.test.g.28 │ │ │ ├── sample.test.g.33 │ │ │ ├── g12.test.g │ │ │ ├── g13.test.g │ │ │ ├── g37.test.g │ │ │ ├── g46.test.g │ │ │ ├── sample.test.g.13 │ │ │ ├── sample.test.g.25 │ │ │ ├── sample.test.g.31 │ │ │ ├── sample.test.g.9 │ │ │ ├── g12.test.g.1 │ │ │ ├── g14.test.g │ │ │ ├── g31.test.g.1 │ │ │ ├── g33.test.g.1 │ │ │ ├── g34.test.g.1 │ │ │ ├── g43.test.g.1 │ │ │ ├── g43.test.g.2 │ │ │ ├── g43.test.g.3 │ │ │ ├── sample.test.g.19 │ │ │ ├── sample.test.g.21 │ │ │ ├── sample.test.g.27 │ │ │ ├── sample.test.g.8 │ │ │ ├── g15.test.g │ │ │ ├── g38.test.g │ │ │ ├── g41.test.g │ │ │ ├── g49.test.g.1 │ │ │ ├── g6.test.g │ │ │ ├── g8.test.g │ │ │ ├── g9.test.g │ │ │ ├── sample.test.g.24 │ │ │ ├── sample.test.g.30 │ │ │ ├── ansic.test.g.1 │ │ │ ├── g10.test.g │ │ │ ├── g36.test.g.1 │ │ │ ├── sample.test.g.32 │ │ │ ├── g11.test.g │ │ │ ├── g3.test.g.1 │ │ │ ├── g44.test.g │ │ │ ├── g9.test.g.1 │ │ │ ├── sample.test.g.26 │ │ │ ├── g28.test.g.1 │ │ │ ├── sample.test.g.10 │ │ │ ├── g24.test.g.1 │ │ │ ├── g42.test.g │ │ │ ├── g15.test.g.1.check │ │ │ ├── g16.test.g │ │ │ ├── g2.test.g.1.check │ │ │ ├── g8.test.g.1.check │ │ │ ├── g11.test.g.3.check │ │ │ ├── g38.test.g.1.check │ │ │ ├── g39.test.g.1.check │ │ │ ├── g41.test.g.1.check │ │ │ ├── g42.test.g.1.check │ │ │ ├── g44.test.g.1.check │ │ │ ├── g10.test.g.1.check │ │ │ ├── g11.test.g.1.check │ │ │ ├── g11.test.g.2.check │ │ │ ├── g21.test.g.1.check │ │ │ ├── g30.test.g.1.check │ │ │ ├── g47.test.g.1 │ │ │ ├── g5.test.g.1.check │ │ │ ├── g51.test.g.1.check │ │ │ ├── utf8.test.g │ │ │ ├── utf8.test.g.1.check │ │ │ ├── g22.test.g.1.check │ │ │ ├── g23.test.g.1.check │ │ │ ├── g26.test.g.1.check │ │ │ ├── g37.test.g.1.check │ │ │ ├── g46.test.g.1.check │ │ │ ├── g6.test.g.1.check │ │ │ ├── g13.test.g.1.check │ │ │ ├── g14.test.g.1.check │ │ │ ├── g25.test.g.1.check │ │ │ ├── g26.test.g │ │ │ ├── g32.test.g.1 │ │ │ ├── g35.test.g.1.check │ │ │ ├── g43.test.g │ │ │ ├── sample.test.g.6.check │ │ │ ├── g23.test.g │ │ │ ├── g48.test.g.1.check │ │ │ ├── g49.test.g.1.check │ │ │ ├── g7.test.g.1.check │ │ │ ├── sample.test.g.16.check │ │ │ ├── sample.test.g.17.check │ │ │ ├── sample.test.g.5.check │ │ │ ├── sample.test.g.7.check │ │ │ ├── g4.test.g.1.check │ │ │ ├── sample.test.g.1.check │ │ │ ├── sample.test.g.12.check │ │ │ ├── sample.test.g.14.check │ │ │ ├── sample.test.g.2.check │ │ │ ├── g40.test.g.1.check │ │ │ ├── g45.test.g.1.check │ │ │ ├── g7.test.g.2.check │ │ │ ├── sample.test.g.15.check │ │ │ ├── sample.test.g.3.check │ │ │ ├── sample.test.g.4.check │ │ │ ├── g16.test.g.1.check │ │ │ ├── g21.test.g │ │ │ ├── g22.test.g │ │ │ ├── g30.test.g │ │ │ ├── g18.test.g │ │ │ ├── g51.test.g │ │ │ ├── sample.test.g.11.check │ │ │ ├── g24.test.g.1.check │ │ │ ├── sample.test.g.31.check │ │ │ ├── sample.test.g.9.check │ │ │ ├── g12.test.g.1.check │ │ │ ├── g43.test.g.2.check │ │ │ ├── sample.test.g.23.check │ │ │ ├── sample.test.g.8.check │ │ │ ├── g1.test.g │ │ │ ├── g27.test.g.1.check │ │ │ ├── g35.test.g │ │ │ ├── g17.test.g │ │ │ ├── sample.test.g.32.check │ │ │ ├── g17.test.g.1.check │ │ │ ├── g18.test.g.1.check │ │ │ ├── g19.test.g.1.check │ │ │ ├── g20.test.g.1.check │ │ │ ├── g43.test.g.1.check │ │ │ ├── g20.test.g │ │ │ ├── g34.test.g.1.check │ │ │ ├── g43.test.g.3.check │ │ │ ├── g19.test.g │ │ │ ├── sample.test.g.0.check │ │ │ ├── sample.test.g.18.check │ │ │ ├── sample.test.g.21.check │ │ │ ├── g28.test.g.1.check │ │ │ ├── g1.test.g.1.check │ │ │ ├── g36.test.g.1.check │ │ │ ├── sample.test.g.33.check │ │ │ ├── sample.test.g.10.check │ │ │ ├── g28.test.g.2 │ │ │ ├── sample.test.g.29.check │ │ │ ├── g29.test.g.1 │ │ │ ├── sample.test.g.25.check │ │ │ ├── sample.test.g.30.check │ │ │ ├── ansic.test.g.1.check │ │ │ ├── g25.test.g │ │ │ ├── g49.test.g │ │ │ ├── sample.test.g.28.check │ │ │ ├── g4.test.g │ │ │ ├── sample.test.g.13.check │ │ │ ├── g27.test.g │ │ │ ├── sample.test.g.27.check │ │ │ ├── g3.test.g.1.check │ │ │ ├── g9.test.g.1.check │ │ │ ├── sample.test.g.20.check │ │ │ ├── g32.test.g.1.check │ │ │ ├── sample.test.g.19.check │ │ │ ├── g28.test.g.2.check │ │ │ ├── g34.test.g │ │ │ ├── g48.test.g │ │ │ ├── sample.test.g.24.check │ │ │ ├── g36.test.g │ │ │ ├── g31.test.g.1.check │ │ │ ├── sample.test.g.26.check │ │ │ ├── g29.test.g.1.check │ │ │ ├── g45.test.g │ │ │ ├── g47.test.g.1.check │ │ │ ├── g7.test.g │ │ │ ├── g24.test.g │ │ │ ├── g31.test.g │ │ │ ├── g47.test.g │ │ │ ├── g33.test.g.1.check │ │ │ ├── g50.test.g.1.check │ │ │ ├── g40.test.g │ │ │ ├── g28.test.g │ │ │ ├── g33.test.g │ │ │ ├── g32.test.g │ │ │ ├── g29.test.g │ │ │ ├── bnf.g │ │ │ ├── python.test.g.1 │ │ │ ├── bnf.g.1 │ │ │ ├── sample.test.g.22 │ │ │ └── sample.test.g │ │ ├── 4calc.in │ │ ├── D_BUILD_VERSION │ │ ├── driver_parsetree.c │ │ ├── baseline │ │ ├── my.g │ │ ├── verilog │ │ │ ├── verilog_tests │ │ │ ├── vparse.h │ │ │ ├── ambig.c │ │ │ ├── Makefile │ │ │ ├── README │ │ │ └── main.c │ │ ├── version.c │ │ ├── write_tables.h │ │ ├── lr.h │ │ ├── scan.h │ │ ├── my.c │ │ ├── gramgram.h │ │ ├── mkdparse.h │ │ ├── python │ │ │ ├── tests │ │ │ │ ├── test4.py │ │ │ │ ├── test3.py │ │ │ │ ├── test.py │ │ │ │ ├── test5.py │ │ │ │ ├── test6.py │ │ │ │ ├── test2.py │ │ │ │ └── test7.py │ │ │ ├── README │ │ │ ├── dparser.i │ │ │ ├── make_tables.c │ │ │ ├── setup.py │ │ │ ├── contrib │ │ │ │ ├── dparserpy-syntax_error.py │ │ │ │ └── dparserpy.el │ │ │ ├── index.html │ │ │ └── pydparser.h │ │ ├── lex.h │ │ ├── README │ │ ├── 4calc.g │ │ ├── mkdparse.c │ │ ├── read_binary.h │ │ ├── arg.h │ │ ├── parser_tests │ │ ├── COPYRIGHT │ │ ├── dparse_tree.h │ │ ├── dparse_tree.c │ │ ├── dsymtab.h │ │ ├── read_binary.c │ │ ├── dparse.h │ │ ├── faq.html │ │ ├── d.h │ │ ├── parse.h │ │ ├── sample_parser.c │ │ ├── make_dparser.1 │ │ ├── util.h │ │ ├── sample.g │ │ └── dparse_tables.h │ ├── ode │ │ └── Makefile │ ├── Makefile │ ├── Makefile.win │ └── install.libs.R ├── .gitignore ├── demo │ ├── 00Index │ └── demo1.R ├── build │ └── vignette.rds ├── vignettes │ └── Model_schematic_w500.png ├── inst │ ├── doc │ │ ├── RxODE-syntax.R │ │ ├── index.html │ │ └── RxODE-intro.R │ ├── THANKS │ ├── Porting │ ├── tran.g │ ├── TODO.txt │ ├── Changes.txt │ └── Install-windows.Rmd ├── NAMESPACE ├── tests │ ├── test-basic.R │ ├── test3.2.R │ ├── test3.1.R │ ├── Examples │ │ ├── eventTable.Rout.save │ │ └── RxODE.Rout.save │ ├── test-parsing.R │ └── test-multi.R ├── DESCRIPTION └── man │ ├── rx.initCmpMgr.Rd │ └── genShinyApp.template.Rd └── RxODEintro.pdf /RxODE/src/dparser/tests/g11.test.g.2: -------------------------------------------------------------------------------- 1 | cc 2 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g11.test.g.3: -------------------------------------------------------------------------------- 1 | c 2 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g15.test.g.1: -------------------------------------------------------------------------------- 1 | a 2 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g2.test.g.1: -------------------------------------------------------------------------------- 1 | d 2 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g26.test.g.1: -------------------------------------------------------------------------------- 1 | a 2 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g30.test.g.1: -------------------------------------------------------------------------------- 1 | ab 2 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g48.test.g.1: -------------------------------------------------------------------------------- 1 | A B C D -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g8.test.g.1: -------------------------------------------------------------------------------- 1 | d 2 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g1.test.g.1: -------------------------------------------------------------------------------- 1 | xbbb 2 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g11.test.g.1: -------------------------------------------------------------------------------- 1 | abc 2 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g21.test.g.1: -------------------------------------------------------------------------------- 1 | x + x 2 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g22.test.g.1: -------------------------------------------------------------------------------- 1 | x + x 2 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g23.test.g.1: -------------------------------------------------------------------------------- 1 | x + x 2 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g35.test.g.1: -------------------------------------------------------------------------------- 1 | asdf 2 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g38.test.g.1: -------------------------------------------------------------------------------- 1 | that 2 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g38.test.g.flags: -------------------------------------------------------------------------------- 1 | -A 2 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g39.test.g.1: -------------------------------------------------------------------------------- 1 | that 2 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g41.test.g.1: -------------------------------------------------------------------------------- 1 | a b 2 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g42.test.g.1: -------------------------------------------------------------------------------- 1 | a b 2 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g44.test.g.1: -------------------------------------------------------------------------------- 1 | 123 2 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g45.test.g.1: -------------------------------------------------------------------------------- 1 | a b 2 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g5.test.g.1: -------------------------------------------------------------------------------- 1 | i i x 2 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g51.test.g.1: -------------------------------------------------------------------------------- 1 | -!x 2 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g6.test.g.1: -------------------------------------------------------------------------------- 1 | b a a 2 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g7.test.g.2: -------------------------------------------------------------------------------- 1 | abcbcbcd 2 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/utf8.test.g.1: -------------------------------------------------------------------------------- 1 | a φ ω 2 | -------------------------------------------------------------------------------- /RxODE/src/dparser/4calc.in: -------------------------------------------------------------------------------- 1 | (2 + 2) * 2 ; 2 ; 2 | 3 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g13.test.g.1: -------------------------------------------------------------------------------- 1 | i i x e x 2 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g14.test.g.1: -------------------------------------------------------------------------------- 1 | i i x e x 2 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g16.test.g.1: -------------------------------------------------------------------------------- 1 | a b b b c 2 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g17.test.g.1: -------------------------------------------------------------------------------- 1 | abc,def,ghi; 2 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g18.test.g.1: -------------------------------------------------------------------------------- 1 | abc,def,ghi; 2 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g19.test.g.1: -------------------------------------------------------------------------------- 1 | abc,def,ghi; 2 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g20.test.g.1: -------------------------------------------------------------------------------- 1 | abc,def,ghi; 2 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g37.test.g.1: -------------------------------------------------------------------------------- 1 | THIS that 2 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g38.test.g.1.flags: -------------------------------------------------------------------------------- 1 | -S 3 2 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g4.test.g.1: -------------------------------------------------------------------------------- 1 | 1 + 2 + 2 + 2 2 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g40.test.g.1: -------------------------------------------------------------------------------- 1 | a b : b + b; 2 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g42.include.g: -------------------------------------------------------------------------------- 1 | A: 'a'; 2 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g43.test.g.2.flags: -------------------------------------------------------------------------------- 1 | -e 2 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g43.test.g.3.flags: -------------------------------------------------------------------------------- 1 | -f 2 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g46.test.g.1: -------------------------------------------------------------------------------- 1 | foobarrel 2 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g7.test.g.1: -------------------------------------------------------------------------------- 1 | a b c b c d 2 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/sample.test.g.0: -------------------------------------------------------------------------------- 1 | x++.y; 2 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/sample.test.g.16: -------------------------------------------------------------------------------- 1 | + + 1; 2 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/sample.test.g.17: -------------------------------------------------------------------------------- 1 | 1 2 + 3; 2 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/sample.test.g.23: -------------------------------------------------------------------------------- 1 | 1 + --a; 2 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/sample.test.g.5: -------------------------------------------------------------------------------- 1 | 1 2 + 3; 2 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/sample.test.g.6: -------------------------------------------------------------------------------- 1 | 1 + 2; 2 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/sample.test.g.7: -------------------------------------------------------------------------------- 1 | 1 2 + 3; 2 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g10.test.g.1: -------------------------------------------------------------------------------- 1 | a b c 2 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/sample.test.g.1: -------------------------------------------------------------------------------- 1 | 2 + 3 * 4; 2 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/sample.test.g.11: -------------------------------------------------------------------------------- 1 | +++++++++++1; 2 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/sample.test.g.12: -------------------------------------------------------------------------------- 1 | 1 * 2 + 3; 2 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/sample.test.g.14: -------------------------------------------------------------------------------- 1 | 1 + 2 + 3; 2 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/sample.test.g.18: -------------------------------------------------------------------------------- 1 | do a while b; 2 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/sample.test.g.2: -------------------------------------------------------------------------------- 1 | 1 * 2 * 3; 2 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/sample.test.g.29: -------------------------------------------------------------------------------- 1 | if (x) y z; 2 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/sample.test.g.3: -------------------------------------------------------------------------------- 1 | 1 * 2 + 3 * 4; 2 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/sample.test.g.4: -------------------------------------------------------------------------------- 1 | 1 2 + 3 * 4 5; 2 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g2.test.g: -------------------------------------------------------------------------------- 1 | A: 'd' | B; 2 | B: A; 3 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g25.test.g.1: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g27.test.g.1: -------------------------------------------------------------------------------- 1 | a b B b 2 | a 3 | a b 4 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g3.test.g: -------------------------------------------------------------------------------- 1 | E: E '+' E | "[abc]"; 2 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g39.test.g: -------------------------------------------------------------------------------- 1 | S: '\x74\d104\141t'; 2 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g5.test.g: -------------------------------------------------------------------------------- 1 | A : 'i' A ('e' A)? | 'x'; 2 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/sample.test.g.15: -------------------------------------------------------------------------------- 1 | 1 + 2 + 3 + 4; 2 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/sample.test.g.20: -------------------------------------------------------------------------------- 1 | x ? y : z ? d : e; 2 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/sample.test.g.28: -------------------------------------------------------------------------------- 1 | if (x) y z else q; 2 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/sample.test.g.33: -------------------------------------------------------------------------------- 1 | for (x = 1) h; 2 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g12.test.g: -------------------------------------------------------------------------------- 1 | P: | 'a' P 'a' | 'b' P 'b'; 2 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g13.test.g: -------------------------------------------------------------------------------- 1 | S : 'i' S ('e' S)? | 'x'; 2 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g37.test.g: -------------------------------------------------------------------------------- 1 | S: 'tHiS'/i "tH[a-z]T"/i; 2 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g46.test.g: -------------------------------------------------------------------------------- 1 | 2 | A : "foo/bar" "barrel"; 3 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/sample.test.g.13: -------------------------------------------------------------------------------- 1 | if (x) if (y) z else q; 2 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/sample.test.g.25: -------------------------------------------------------------------------------- 1 | if (x) y else z + 5; 2 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/sample.test.g.31: -------------------------------------------------------------------------------- 1 | 1 2 + 3 4 + 5 6 + 7; 2 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/sample.test.g.9: -------------------------------------------------------------------------------- 1 | 1 + 2 + 3 + 4 + 5 + 6; 2 | -------------------------------------------------------------------------------- /RxODE/.gitignore: -------------------------------------------------------------------------------- 1 | .Rproj.user 2 | .Rhistory 3 | .RData 4 | RxODE.Rproj 5 | -------------------------------------------------------------------------------- /RxODE/demo/00Index: -------------------------------------------------------------------------------- 1 | demo1 A simple indirect response PK/PD model 2 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g12.test.g.1: -------------------------------------------------------------------------------- 1 | a a a a b a b b a b a a a a 2 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g14.test.g: -------------------------------------------------------------------------------- 1 | S : 'i' S | 'i' S 'e' S | 'x'; 2 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g31.test.g.1: -------------------------------------------------------------------------------- 1 | 1; 2 | 2 + 3; 3 | b = 3 + 4; 4 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g33.test.g.1: -------------------------------------------------------------------------------- 1 | 1; 2 | 2 + 3; 3 | b = 3 + 4; 4 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g34.test.g.1: -------------------------------------------------------------------------------- 1 | dont 2 | thinkX 3 | do thinkit 4 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g43.test.g.1: -------------------------------------------------------------------------------- 1 | a 1 b 1 b 1 c 1 c 1 d 1 d 2 d 1 2 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g43.test.g.2: -------------------------------------------------------------------------------- 1 | a 1 b 1 b 1 c 1 c 1 d 1 d 2 d 1 2 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g43.test.g.3: -------------------------------------------------------------------------------- 1 | a 1 b 1 b 1 c 1 c 1 d 1 d 2 d 1 2 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/sample.test.g.19: -------------------------------------------------------------------------------- 1 | for (x = 1; x < y; x++) h; 2 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/sample.test.g.21: -------------------------------------------------------------------------------- 1 | a = 1 + 2 + 3 + 4 + 5 + 6; 2 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/sample.test.g.27: -------------------------------------------------------------------------------- 1 | if (x) if (y) if (z) zz; 2 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/sample.test.g.8: -------------------------------------------------------------------------------- 1 | 1 + 2 + 3 + 4 + 5 + 6 + 7; 2 | -------------------------------------------------------------------------------- /RxODE/src/dparser/D_BUILD_VERSION: -------------------------------------------------------------------------------- 1 | 6a201e22e57e77c297d3c43fdb245125ed3b7d64 2 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g15.test.g: -------------------------------------------------------------------------------- 1 | S : A | B; 2 | A : 'a'; 3 | B : 'a'; 4 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g38.test.g: -------------------------------------------------------------------------------- 1 | S: A B; 2 | A: 'this'; 3 | B: 'that'; 4 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g41.test.g: -------------------------------------------------------------------------------- 1 | h : h1 h2; 2 | h1 : 'a'; 3 | h2 : 'b'; 4 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g49.test.g.1: -------------------------------------------------------------------------------- 1 | A 2 | 3 | 4 | B C 5 | D 6 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g6.test.g: -------------------------------------------------------------------------------- 1 | S: 'b' A; 2 | A : 'a' A B | ; 3 | B : ; 4 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g8.test.g: -------------------------------------------------------------------------------- 1 | A: 'd' $left 2 | B $left 1; 2 | B: A; 3 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g9.test.g: -------------------------------------------------------------------------------- 1 | E: E '+' E $binary_left 1 | "[abc]"; 2 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/sample.test.g.24: -------------------------------------------------------------------------------- 1 | if (x) y + z * n else q + s * t; 2 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/sample.test.g.30: -------------------------------------------------------------------------------- 1 | 1 2 + 3 4 + 5 6 + 7 8 + 9 a + b; 2 | -------------------------------------------------------------------------------- /RxODEintro.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hallowkm/RxODE/HEAD/RxODEintro.pdf -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/ansic.test.g.1: -------------------------------------------------------------------------------- 1 | int i = 1; 2 | int x = &; 3 | int j = 2; 4 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g10.test.g: -------------------------------------------------------------------------------- 1 | S: 'a' 'b' 'c'; 2 | whitespace: "[ \t\n]*"; 3 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g36.test.g.1: -------------------------------------------------------------------------------- 1 | dont 2 | formulaX 3 | formula 4 | do form 5 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/sample.test.g.32: -------------------------------------------------------------------------------- 1 | 1 + 1.1 + 0.1 + -0.1 + -.1 + 1.0e10; 2 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g11.test.g: -------------------------------------------------------------------------------- 1 | S: A B C; 2 | A: 'a'?; 3 | B: 'b'*; 4 | C: 'c'+; 5 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g3.test.g.1: -------------------------------------------------------------------------------- 1 | b+b+b+b+b+b+b+b+b+b+b+b+b+b+b+b+b+b+b+b+b+b+b+b+b+b 2 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g44.test.g: -------------------------------------------------------------------------------- 1 | S: A; 2 | A ::= B; 3 | B ::= "[0-9]+" $name "someint"; 4 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g9.test.g.1: -------------------------------------------------------------------------------- 1 | b+b+b+b+b+b+b+b+b+b+b+b+b+b+b+b+b+b+b+b+b+b+b+b+b+b 2 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/sample.test.g.26: -------------------------------------------------------------------------------- 1 | if (x) y else if (y) z else if (z) zz else zzz; 2 | -------------------------------------------------------------------------------- /RxODE/build/vignette.rds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hallowkm/RxODE/HEAD/RxODE/build/vignette.rds -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g28.test.g.1: -------------------------------------------------------------------------------- 1 | a: 1; 2 | a; 3 | { 4 | a: 2; 5 | a; 6 | } 7 | a; 8 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/sample.test.g.10: -------------------------------------------------------------------------------- 1 | 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 1 + 2 + 3 + 4; 2 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g24.test.g.1: -------------------------------------------------------------------------------- 1 | 123.456e-10 2 | 123.456e-10J 3 | 01234 4 | 234L 5 | 0xBADFEED 6 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g42.test.g: -------------------------------------------------------------------------------- 1 | 2 | S: A B; 3 | 4 | include "g42.include.g" 5 | 6 | B: 'b'; 7 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g15.test.g.1.check: -------------------------------------------------------------------------------- 1 | 5 states 1 scans 1 shifts 4 reductions 1 compares 1 ambiguities 2 | a 3 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g16.test.g: -------------------------------------------------------------------------------- 1 | { 2 | #include 3 | } 4 | S : 'a' ('b' { printf("(b)\n"); })* 'c'; 5 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g2.test.g.1.check: -------------------------------------------------------------------------------- 1 | 4 states 1 scans 1 shifts 3 reductions 1 compares 0 ambiguities 2 | d 3 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g8.test.g.1.check: -------------------------------------------------------------------------------- 1 | 4 states 1 scans 1 shifts 3 reductions 1 compares 0 ambiguities 2 | d 3 | -------------------------------------------------------------------------------- /RxODE/src/dparser/driver_parsetree.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hallowkm/RxODE/HEAD/RxODE/src/dparser/driver_parsetree.c -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g11.test.g.3.check: -------------------------------------------------------------------------------- 1 | 9 states 4 scans 1 shifts 5 reductions 0 compares 0 ambiguities 2 | ( c ) 3 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g38.test.g.1.check: -------------------------------------------------------------------------------- 1 | 3 states 1 scans 1 shifts 1 reductions 0 compares 0 ambiguities 2 | that 3 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g39.test.g.1.check: -------------------------------------------------------------------------------- 1 | 3 states 1 scans 1 shifts 1 reductions 0 compares 0 ambiguities 2 | that 3 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g41.test.g.1.check: -------------------------------------------------------------------------------- 1 | 6 states 2 scans 2 shifts 3 reductions 0 compares 0 ambiguities 2 | ( a b ) 3 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g42.test.g.1.check: -------------------------------------------------------------------------------- 1 | 6 states 2 scans 2 shifts 3 reductions 0 compares 0 ambiguities 2 | ( a b ) 3 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g44.test.g.1.check: -------------------------------------------------------------------------------- 1 | 3 states 1 scans 1 shifts 1 reductions 0 compares 0 ambiguities 2 | 123 3 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g10.test.g.1.check: -------------------------------------------------------------------------------- 1 | 5 states 3 scans 3 shifts 1 reductions 0 compares 0 ambiguities 2 | ( a b c ) 3 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g11.test.g.1.check: -------------------------------------------------------------------------------- 1 | 17 states 8 scans 3 shifts 10 reductions 0 compares 0 ambiguities 2 | ( a b c ) 3 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g11.test.g.2.check: -------------------------------------------------------------------------------- 1 | 13 states 5 scans 2 shifts 8 reductions 0 compares 0 ambiguities 2 | (( c c )) 3 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g21.test.g.1.check: -------------------------------------------------------------------------------- 1 | 12 states 7 scans 4 shifts 5 reductions 0 compares 0 ambiguities 2 | ( x + x ) 3 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g30.test.g.1.check: -------------------------------------------------------------------------------- 1 | a.b7 states 2 scans 2 shifts 3 reductions 0 compares 0 ambiguities 2 | ( a b ) 3 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g47.test.g.1: -------------------------------------------------------------------------------- 1 | %A para.---List item 1. Item 1, para 2.%---List item 2.%---List item 3.%Final para. 2 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g5.test.g.1.check: -------------------------------------------------------------------------------- 1 | 7 states 4 scans 3 shifts 4 reductions 0 compares 0 ambiguities 2 | ( i ( i x )) 3 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g51.test.g.1.check: -------------------------------------------------------------------------------- 1 | 7 states 6 scans 3 shifts 3 reductions 0 compares 0 ambiguities 2 | ( - ( ! x )) 3 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/utf8.test.g: -------------------------------------------------------------------------------- 1 | S: character+ ; 2 | 3 | character: 4 | 'φ' 5 | | U+03c9 6 | | u+61 7 | ; 8 | 9 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/utf8.test.g.1.check: -------------------------------------------------------------------------------- 1 | 13 states 4 scans 3 shifts 9 reductions 0 compares 0 ambiguities 2 | ( a φ ω ) 3 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g22.test.g.1.check: -------------------------------------------------------------------------------- 1 | 14 states 7 scans 5 shifts 8 reductions 1 compares 0 ambiguities 2 | ( x ( + x )) 3 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g23.test.g.1.check: -------------------------------------------------------------------------------- 1 | 10 states 8 scans 5 shifts 5 reductions 1 compares 0 ambiguities 2 | ( x ( + x )) 3 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g26.test.g.1.check: -------------------------------------------------------------------------------- 1 | a 2 | S 3 | 3 states 1 scans 1 shifts 1 reductions 0 compares 0 ambiguities 4 | a 5 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g37.test.g.1.check: -------------------------------------------------------------------------------- 1 | 4 states 2 scans 2 shifts 1 reductions 0 compares 0 ambiguities 2 | ( THIS that ) 3 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g46.test.g.1.check: -------------------------------------------------------------------------------- 1 | 4 states 2 scans 2 shifts 1 reductions 0 compares 0 ambiguities 2 | ( foo barrel ) 3 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g6.test.g.1.check: -------------------------------------------------------------------------------- 1 | 14 states 4 scans 3 shifts 7 reductions 0 compares 0 ambiguities 2 | ( b ( a ( a ))) 3 | -------------------------------------------------------------------------------- /RxODE/vignettes/Model_schematic_w500.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hallowkm/RxODE/HEAD/RxODE/vignettes/Model_schematic_w500.png -------------------------------------------------------------------------------- /RxODE/inst/doc/RxODE-syntax.R: -------------------------------------------------------------------------------- 1 | ## ----setup, include = FALSE---------------------------------------------- 2 | library(knitr) 3 | 4 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g13.test.g.1.check: -------------------------------------------------------------------------------- 1 | 14 states 6 scans 5 shifts 10 reductions 1 compares 0 ambiguities 2 | ( i ( i x ( e x ))) 3 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g14.test.g.1.check: -------------------------------------------------------------------------------- 1 | 11 states 6 scans 5 shifts 7 reductions 1 compares 0 ambiguities 2 | ( i ( i x e x )) 3 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g25.test.g.1.check: -------------------------------------------------------------------------------- 1 | 5 states 3 scans 3 shifts 1 reductions 0 compares 0 ambiguities 2 | ( 3 | 4 | ) 5 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g26.test.g: -------------------------------------------------------------------------------- 1 | { 2 | #include 3 | } 4 | 5 | S: a [ printf("S\n"); ]; 6 | a ::= 'a' [ printf("a\n"); ]; 7 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g32.test.g.1: -------------------------------------------------------------------------------- 1 | /* start */ 2 | a /*some a*/ = /*after = before 1 */ 1 /* after 1 before ; */ ; 3 | /* end */ 4 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g35.test.g.1.check: -------------------------------------------------------------------------------- 1 | identifier 2 | 7 states 2 scans 1 shifts 4 reductions 0 compares 0 ambiguities 3 | asdf 4 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g43.test.g: -------------------------------------------------------------------------------- 1 | S: A B C D; 2 | A: ('a' '1')?; 3 | B: ('b' '1')*; 4 | C: ('c' '1')+; 5 | D: (('d' '1')('d' '2')?)*; 6 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/sample.test.g.6.check: -------------------------------------------------------------------------------- 1 | 22 states 8 scans 5 shifts 13 reductions 0 compares 0 ambiguities 2 | (( 1 + 2 ) ; ) 3 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g23.test.g: -------------------------------------------------------------------------------- 1 | ${declare set_op_priority_from_rule} 2 | S : S '+' S $left 2 | S S $left 1 | '+' S $unary_right 3 | 'x'; 3 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g48.test.g.1.check: -------------------------------------------------------------------------------- 1 | B C 2 | 11 states 4 scans 4 shifts 6 reductions 0 compares 0 ambiguities 3 | ( A ( B C ) D ) 4 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g49.test.g.1.check: -------------------------------------------------------------------------------- 1 | 4 12 2 | 10 states 4 scans 4 shifts 5 reductions 0 compares 0 ambiguities 3 | ( A B C D ) 4 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g7.test.g.1.check: -------------------------------------------------------------------------------- 1 | 13 states 6 scans 6 shifts 6 reductions 0 compares 0 ambiguities 2 | ( a (( b c )( b c )) d ) 3 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/sample.test.g.16.check: -------------------------------------------------------------------------------- 1 | 17 states 7 scans 4 shifts 11 reductions 0 compares 0 ambiguities 2 | (( + ( + 1 )) ; ) 3 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/sample.test.g.17.check: -------------------------------------------------------------------------------- 1 | 28 states 11 scans 7 shifts 18 reductions 0 compares 0 ambiguities 2 | (( 1 ( 2 + 3 )) ; ) 3 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/sample.test.g.5.check: -------------------------------------------------------------------------------- 1 | 28 states 11 scans 7 shifts 18 reductions 0 compares 0 ambiguities 2 | (( 1 ( 2 + 3 )) ; ) 3 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/sample.test.g.7.check: -------------------------------------------------------------------------------- 1 | 28 states 11 scans 7 shifts 18 reductions 0 compares 0 ambiguities 2 | (( 1 ( 2 + 3 )) ; ) 3 | -------------------------------------------------------------------------------- /RxODE/src/dparser/baseline: -------------------------------------------------------------------------------- 1 | #!/bin/tcsh 2 | 3 | setenv MAKE gmake 4 | parser_tests 5 | foreach f (tests/*.out) 6 | cp $f $f:r.check 7 | end 8 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g4.test.g.1.check: -------------------------------------------------------------------------------- 1 | 19 states 8 scans 7 shifts 10 reductions 0 compares 0 ambiguities 2 | ( 1 (( + 2 )( + 2 )( + 2 ))) 3 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/sample.test.g.1.check: -------------------------------------------------------------------------------- 1 | 32 states 12 scans 9 shifts 20 reductions 0 compares 0 ambiguities 2 | (( 2 + ( 3 * 4 )) ; ) 3 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/sample.test.g.12.check: -------------------------------------------------------------------------------- 1 | 32 states 12 scans 9 shifts 19 reductions 0 compares 0 ambiguities 2 | ((( 1 * 2 ) + 3 ) ; ) 3 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/sample.test.g.14.check: -------------------------------------------------------------------------------- 1 | 32 states 12 scans 9 shifts 19 reductions 0 compares 0 ambiguities 2 | ((( 1 + 2 ) + 3 ) ; ) 3 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/sample.test.g.2.check: -------------------------------------------------------------------------------- 1 | 32 states 12 scans 9 shifts 19 reductions 0 compares 0 ambiguities 2 | ((( 1 * 2 ) * 3 ) ; ) 3 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g40.test.g.1.check: -------------------------------------------------------------------------------- 1 | 59 states 41 scans 21 shifts 38 reductions 2 compares 0 ambiguities 2 | ((( a b : )( b ( + b ))) ; ) 3 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g45.test.g.1.check: -------------------------------------------------------------------------------- 1 | succeed1 2 | succeed2 3 | 6 states 2 scans 2 shifts 3 reductions 0 compares 0 ambiguities 4 | ( a b ) 5 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g7.test.g.2.check: -------------------------------------------------------------------------------- 1 | 17 states 8 scans 8 shifts 8 reductions 0 compares 0 ambiguities 2 | ( a (( b c )( b c )( b c )) d ) 3 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/sample.test.g.15.check: -------------------------------------------------------------------------------- 1 | 42 states 16 scans 13 shifts 25 reductions 0 compares 0 ambiguities 2 | (((( 1 + 2 ) + 3 ) + 4 ) ; ) 3 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/sample.test.g.3.check: -------------------------------------------------------------------------------- 1 | 42 states 16 scans 13 shifts 26 reductions 0 compares 0 ambiguities 2 | ((( 1 * 2 ) + ( 3 * 4 )) ; ) 3 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/sample.test.g.4.check: -------------------------------------------------------------------------------- 1 | 44 states 18 scans 12 shifts 30 reductions 0 compares 0 ambiguities 2 | ((( 1 ( 2 + ( 3 * 4 ))) 5 ) ; ) 3 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g16.test.g.1.check: -------------------------------------------------------------------------------- 1 | (b) 2 | (b) 3 | (b) 4 | 14 states 5 scans 5 shifts 7 reductions 0 compares 0 ambiguities 5 | ( a ( b b b ) c ) 6 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g21.test.g: -------------------------------------------------------------------------------- 1 | S : S bop S | uop S | 'x'; 2 | bop : '+' $binary_op_left 2 3 | | $binary_op_left 1; 4 | uop : '+' $unary_op_right 3; 5 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g22.test.g: -------------------------------------------------------------------------------- 1 | E : E bop F | F; 2 | bop: '+' $binary_op_left 2 | $binary_op_left 1; 3 | F : uop F | 'x'; 4 | uop: '+' $unary_op_right 3; 5 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g30.test.g: -------------------------------------------------------------------------------- 1 | { 2 | #include "stdio.h" 3 | } 4 | 5 | S: A { printf("."); } B; 6 | A: 'a' { printf("a"); }; 7 | B: 'b' { printf("b"); }; 8 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g18.test.g: -------------------------------------------------------------------------------- 1 | { 2 | #include 3 | } 4 | A: ID ( ',' ID { printf( "moreIDs\n" ); } )* ';' ; 5 | ID: "[a-z]+" { printf( "ID\n" ); } ; 6 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g51.test.g: -------------------------------------------------------------------------------- 1 | expr: 'x' 2 | | '-' expr $unary_right 3 3 | | '!' expr $unary_right 1 4 | | expr '+' expr $binary_right 2 5 | ; 6 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/sample.test.g.11.check: -------------------------------------------------------------------------------- 1 | 25 states 11 scans 8 shifts 19 reductions 0 compares 0 ambiguities 2 | (( ++ ( ++ ( ++ ( ++ ( ++ ( + 1 )))))) ; ) 3 | -------------------------------------------------------------------------------- /RxODE/src/dparser/my.g: -------------------------------------------------------------------------------- 1 | phrase : words ( ABC | AB | A ) words; 2 | words : word*; 3 | word : "[a-z]+"; 4 | A : "a[a-z]*"; 5 | AB : A "b[a-z]*"; 6 | ABC : AB "c[a-z]*"; 7 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g24.test.g.1.check: -------------------------------------------------------------------------------- 1 | 18 states 6 scans 5 shifts 11 reductions 0 compares 0 ambiguities 2 | ( 123.456e-10 123.456e-10J 01234 234L 0xBADFEED ) 3 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/sample.test.g.31.check: -------------------------------------------------------------------------------- 1 | 60 states 25 scans 17 shifts 40 reductions 0 compares 0 ambiguities 2 | (((( 1 ( 2 + 3 ))( 4 + 5 ))( 6 + 7 )) ; ) 3 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/sample.test.g.9.check: -------------------------------------------------------------------------------- 1 | 62 states 24 scans 21 shifts 37 reductions 0 compares 0 ambiguities 2 | (((((( 1 + 2 ) + 3 ) + 4 ) + 5 ) + 6 ) ; ) 3 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g12.test.g.1.check: -------------------------------------------------------------------------------- 1 | 48 states 34 scans 24 shifts 15 reductions 0 compares 0 ambiguities 2 | ( a ( a ( a ( a ( b ( a ( b b ) a ) b ) a ) a ) a ) a ) 3 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g43.test.g.2.check: -------------------------------------------------------------------------------- 1 | 63 states 27 scans 17 shifts 38 reductions 0 compares 0 ambiguities 2 | (( a 1 )( b 1 b 1 )( c 1 c 1 )( d 1 d 2 d 1 )) 3 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/sample.test.g.23.check: -------------------------------------------------------------------------------- 1 | ref Sym 'a' line 1: not found 2 | 24 states 10 scans 6 shifts 14 reductions 0 compares 0 ambiguities 3 | (( 1 + ( -- a )) ; ) 4 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/sample.test.g.8.check: -------------------------------------------------------------------------------- 1 | 72 states 28 scans 25 shifts 43 reductions 0 compares 0 ambiguities 2 | ((((((( 1 + 2 ) + 3 ) + 4 ) + 5 ) + 6 ) + 7 ) ; ) 3 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g1.test.g: -------------------------------------------------------------------------------- 1 | { 2 | #include 3 | } 4 | S: A S 'b' | 'x'; 5 | A: [ printf("speculative e-reduce A\n"); ] 6 | { printf("final e-reduce A\n"); }; 7 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g27.test.g.1.check: -------------------------------------------------------------------------------- 1 | [(b)(B)(b)] 2 | [] 3 | [(b)] 4 | 40 states 15 scans 7 shifts 29 reductions 0 compares 0 ambiguities 5 | (( a ( b B b ))( a )( a b )) 6 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g35.test.g: -------------------------------------------------------------------------------- 1 | { 2 | #include 3 | } 4 | 5 | S: identifier* 6 | { printf("identifier\n"); } 7 | ; 8 | 9 | identifier: "[a-z<>=+]+"; 10 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g17.test.g: -------------------------------------------------------------------------------- 1 | { 2 | #include 3 | } 4 | A: ID moreIDs* ';' ; 5 | moreIDs: ',' ID { printf( "moreIDs\n" ); } ; 6 | ID: "[a-z]+" { printf( "ID\n" ); } ; 7 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/sample.test.g.32.check: -------------------------------------------------------------------------------- 1 | 62 states 24 scans 21 shifts 37 reductions 0 compares 0 ambiguities 2 | (((((( 1 + 1.1 ) + 0.1 ) + -0.1 ) + -.1 ) + 1.0e10 ) ; ) 3 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g17.test.g.1.check: -------------------------------------------------------------------------------- 1 | ID 2 | ID 3 | moreIDs 4 | ID 5 | moreIDs 6 | 16 states 6 scans 6 shifts 8 reductions 0 compares 0 ambiguities 7 | ( abc (( , def )( , ghi )) ; ) 8 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g18.test.g.1.check: -------------------------------------------------------------------------------- 1 | ID 2 | ID 3 | moreIDs 4 | ID 5 | moreIDs 6 | 16 states 6 scans 6 shifts 8 reductions 0 compares 0 ambiguities 7 | ( abc (( , def )( , ghi )) ; ) 8 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g19.test.g.1.check: -------------------------------------------------------------------------------- 1 | ID 2 | ID 3 | moreIDs 4 | ID 5 | moreIDs 6 | 16 states 6 scans 6 shifts 8 reductions 0 compares 0 ambiguities 7 | ( abc (( , def )( , ghi )) ; ) 8 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g20.test.g.1.check: -------------------------------------------------------------------------------- 1 | ID 2 | ID 3 | moreIDs 4 | ID 5 | moreIDs 6 | 16 states 6 scans 6 shifts 8 reductions 0 compares 0 ambiguities 7 | ( abc (( , def )( , ghi )) ; ) 8 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g43.test.g.1.check: -------------------------------------------------------------------------------- 1 | 63 states 27 scans 17 shifts 38 reductions 0 compares 0 ambiguities 2 | (( a 1 )(( b 1 )( b 1 ))(( c 1 )( c 1 ))((( d 1 )( d 2 ))( d 1 ))) 3 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g20.test.g: -------------------------------------------------------------------------------- 1 | { 2 | #include 3 | } 4 | ${tokenize all_matches A} 5 | A: ID ( ',' ID { printf( "moreIDs\n" ); } )* ';' ; 6 | ID: "[a-z]+" { printf( "ID\n" ); } ; 7 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g34.test.g.1.check: -------------------------------------------------------------------------------- 1 | identifier 2 | identifierX 3 | do identifier 4 | 19 states 5 scans 4 shifts 13 reductions 0 compares 0 ambiguities 5 | ( dont thinkX ( do thinkit )) 6 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g43.test.g.3.check: -------------------------------------------------------------------------------- 1 | 63 states 27 scans 17 shifts 38 reductions 0 compares 0 ambiguities 2 | (( a 1 )((( b 1 ))( b 1 ))(( c 1 )( c 1 ))(((( d 1 )( d 2 )))(( d 1 )))) 3 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g19.test.g: -------------------------------------------------------------------------------- 1 | { 2 | #include 3 | } 4 | ${declare all_matches A} 5 | A: ID moreIDs* ';' ; 6 | moreIDs: ',' ID { printf( "moreIDs\n" ); } ; 7 | ID: "[a-z]+" { printf( "ID\n" ); } ; 8 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/sample.test.g.0.check: -------------------------------------------------------------------------------- 1 | ref Sym 'x' line 1: not found 2 | ref Sym 'y' line 1: not found 3 | 24 states 12 scans 6 shifts 13 reductions 0 compares 0 ambiguities 4 | ((( x ++ ) . y ) ; ) 5 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/sample.test.g.18.check: -------------------------------------------------------------------------------- 1 | ref Sym 'a' line 1: not found 2 | ref Sym 'b' line 1: not found 3 | 19 states 10 scans 6 shifts 9 reductions 0 compares 0 ambiguities 4 | (( do a while b ) ; ) 5 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/sample.test.g.21.check: -------------------------------------------------------------------------------- 1 | ref Sym 'a' line 1: not found 2 | 69 states 29 scans 24 shifts 46 reductions 0 compares 0 ambiguities 3 | (( a = ((((( 1 + 2 ) + 3 ) + 4 ) + 5 ) + 6 )) ; ) 4 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g28.test.g.1.check: -------------------------------------------------------------------------------- 1 | 1 2 | 1 3 | 2 4 | 2 5 | 1 6 | 52 states 24 scans 16 shifts 33 reductions 0 compares 0 ambiguities 7 | ((( a : 1 ) ; )( a ; )( { ((( a : 2 ) ; )( a ; )) } )( a ; )) 8 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g1.test.g.1.check: -------------------------------------------------------------------------------- 1 | speculative e-reduce A 2 | final e-reduce A 3 | final e-reduce A 4 | final e-reduce A 5 | 14 states 6 scans 5 shifts 4 reductions 0 compares 0 ambiguities 6 | ((( x b ) b ) b ) 7 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g36.test.g.1.check: -------------------------------------------------------------------------------- 1 | identifier 2 | identifierX 3 | identifier 4 | do identifier 5 | 32 states 8 scans 8 shifts 23 reductions 1 compares 0 ambiguities 6 | ( dont formulaX formula ( do form )) 7 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/sample.test.g.33.check: -------------------------------------------------------------------------------- 1 | ref Sym 'x' line 1: not found 2 | ref Sym 'h' line 1: not found 3 | 29 states 16 scans 8 shifts 14 reductions 0 compares 0 ambiguities 4 | (( for ( ( x = 1 ) ) h ) ; ) 5 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/sample.test.g.10.check: -------------------------------------------------------------------------------- 1 | 132 states 52 scans 49 shifts 79 reductions 0 compares 0 ambiguities 2 | ((((((((((((( 1 + 2 ) + 3 ) + 4 ) + 5 ) + 6 ) + 7 ) + 8 ) + 9 ) + 1 ) + 2 ) + 3 ) + 4 ) ; ) 3 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g28.test.g.2: -------------------------------------------------------------------------------- 1 | a: 1; 2 | { 3 | a: 2; 4 | a; 5 | a: 3; 6 | { 7 | a; 8 | a: 4; 9 | a; 10 | a = 5; 11 | a; 12 | } 13 | a; 14 | { 15 | a = 6; 16 | } 17 | a; 18 | } 19 | a; 20 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/sample.test.g.29.check: -------------------------------------------------------------------------------- 1 | ref Sym 'x' line 1: not found 2 | ref Sym 'y' line 1: not found 3 | ref Sym 'z' line 1: not found 4 | 25 states 14 scans 7 shifts 13 reductions 0 compares 0 ambiguities 5 | (( if ( x ) ( y z )) ; ) 6 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g29.test.g.1: -------------------------------------------------------------------------------- 1 | a: 1; 2 | { 3 | a: 2; 4 | a; 5 | a: 3; 6 | { 7 | a; 8 | a: 4; 9 | a; 10 | a = 5; 11 | a; 12 | } 13 | a; 14 | { 15 | a = 6; 16 | } 17 | a: 7; 18 | a; 19 | } 20 | a; 21 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/sample.test.g.25.check: -------------------------------------------------------------------------------- 1 | ref Sym 'x' line 1: not found 2 | ref Sym 'y' line 1: not found 3 | ref Sym 'z' line 1: not found 4 | 36 states 19 scans 12 shifts 19 reductions 0 compares 0 ambiguities 5 | (( if ( x ) y else ( z + 5 )) ; ) 6 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/sample.test.g.30.check: -------------------------------------------------------------------------------- 1 | ref Sym 'a' line 1: not found 2 | ref Sym 'b' line 1: not found 3 | 90 states 39 scans 27 shifts 60 reductions 0 compares 0 ambiguities 4 | (((((( 1 ( 2 + 3 ))( 4 + 5 ))( 6 + 7 ))( 8 + 9 ))( a + b )) ; ) 5 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/ansic.test.g.1.check: -------------------------------------------------------------------------------- 1 | ansic.test.g.1:2: syntax error after '&' 2 | 153 states 59 scans 58 shifts 97 reductions 0 compares 0 ambiguities 3 | (( int ((( i )( = ((((((((((((( 1 )))))))))))))))) ; )( int ((( j )( = ((((((((((((( 2 )))))))))))))))) ; )) 4 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g25.test.g: -------------------------------------------------------------------------------- 1 | { 2 | #include "dparse_tables.h" 3 | 4 | void mywhite(struct D_Parser *p, d_loc_t *loc, void **p_globals) { 5 | while (*loc->s == ' ') loc->s++; 6 | } 7 | 8 | } 9 | 10 | ${declare whitespace mywhite} 11 | S: '\n' '\t' '\n'; 12 | -------------------------------------------------------------------------------- /RxODE/src/dparser/verilog/verilog_tests: -------------------------------------------------------------------------------- 1 | #!/bin/csh 2 | # 3 | 4 | echo ==== TESTS ======= >! log.txt 5 | 6 | foreach file ( `find testsuite -name '*.v' -print` ) 7 | echo =================== $file ================ >> log.txt 8 | ./v $file >>& log.txt 9 | end 10 | 11 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g49.test.g: -------------------------------------------------------------------------------- 1 | { 2 | #include "stdio.h" 3 | #include "string.h" 4 | #include "stdlib.h" 5 | } 6 | top: A B C D; 7 | A: 'A'; 8 | B: 'B'; 9 | C: 'C' { printf("%i %i\n", $n.start_loc.line, $n.start_loc.col ); }; 10 | D: 'D'; 11 | whitespace: "[\t\n ]*"; 12 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/sample.test.g.28.check: -------------------------------------------------------------------------------- 1 | ref Sym 'x' line 1: not found 2 | ref Sym 'y' line 1: not found 3 | ref Sym 'z' line 1: not found 4 | ref Sym 'q' line 1: not found 5 | 31 states 18 scans 9 shifts 16 reductions 0 compares 0 ambiguities 6 | (( if ( x ) ( y z ) else q ) ; ) 7 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g4.test.g: -------------------------------------------------------------------------------- 1 | { 2 | extern char *ops; 3 | extern void *ops_cache; 4 | #include "d.h" 5 | int ops_scan(char *ops, void *ops_cache, d_loc_t *loc, 6 | unsigned char *op_assoc, int *op_priority); 7 | 8 | } 9 | 10 | X: '1' (${scan ops_scan(ops, ops_cache)} '2')*; 11 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/sample.test.g.13.check: -------------------------------------------------------------------------------- 1 | ref Sym 'x' line 1: not found 2 | ref Sym 'y' line 1: not found 3 | ref Sym 'z' line 1: not found 4 | ref Sym 'q' line 1: not found 5 | 33 states 20 scans 12 shifts 18 reductions 1 compares 0 ambiguities 6 | (( if ( x ) ( if ( y ) z else q )) ; ) 7 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g27.test.g: -------------------------------------------------------------------------------- 1 | { 2 | #include 3 | } 4 | S: A+; 5 | A: 'a' B* { 6 | int i; 7 | printf("["); 8 | for (i = 0; i < d_get_number_of_children(&$n1); i++) 9 | printf("(%c)", *d_get_child(&$n1, i)->start_loc.s); 10 | printf("]\n"); 11 | }; 12 | B: 'b' | 'B'; 13 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/sample.test.g.27.check: -------------------------------------------------------------------------------- 1 | ref Sym 'x' line 1: not found 2 | ref Sym 'y' line 1: not found 3 | ref Sym 'z' line 1: not found 4 | ref Sym 'zz' line 1: not found 5 | 33 states 20 scans 14 shifts 15 reductions 0 compares 0 ambiguities 6 | (( if ( x ) ( if ( y ) ( if ( z ) zz ))) ; ) 7 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g3.test.g.1.check: -------------------------------------------------------------------------------- 1 | 103 states 77 scans 75 shifts 9322 reductions 8419 compares 0 ambiguities 2 | ( b + ( b + ( b + ( b + ( b + ( b + ( b + ( b + ( b + ( b + ( b + ( b + ( b + ( b + ( b + ( b + ( b + ( b + ( b + ( b + ( b + ( b + ( b + ( b + ( b + b ))))))))))))))))))))))))) 3 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g9.test.g.1.check: -------------------------------------------------------------------------------- 1 | 103 states 77 scans 75 shifts 2951 reductions 0 compares 0 ambiguities 2 | ((((((((((((((((((((((((( b + b ) + b ) + b ) + b ) + b ) + b ) + b ) + b ) + b ) + b ) + b ) + b ) + b ) + b ) + b ) + b ) + b ) + b ) + b ) + b ) + b ) + b ) + b ) + b ) + b ) 3 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/sample.test.g.20.check: -------------------------------------------------------------------------------- 1 | ref Sym 'x' line 1: not found 2 | ref Sym 'y' line 1: not found 3 | ref Sym 'z' line 1: not found 4 | ref Sym 'd' line 1: not found 5 | ref Sym 'e' line 1: not found 6 | 33 states 19 scans 11 shifts 18 reductions 0 compares 0 ambiguities 7 | (( x ? y : ( z ? d : e )) ; ) 8 | -------------------------------------------------------------------------------- /RxODE/src/dparser/verilog/vparse.h: -------------------------------------------------------------------------------- 1 | /* vparse.h 2 | * 3 | * Utilities used during parsing Verilog files. 4 | * 5 | */ 6 | 7 | extern int v_iskeyword( const char *, const char * ); 8 | extern void v_parse_init( void ); 9 | extern int v_getfile( const char *, char **, int * ); 10 | 11 | extern char *v_incdirs; 12 | -------------------------------------------------------------------------------- /RxODE/src/dparser/version.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2002-2004 John Plevyak, All Rights Reserved 3 | */ 4 | #include "d.h" 5 | 6 | void 7 | d_version(char *v) { 8 | v += sprintf(v, "%d.%d", D_MAJOR_VERSION, D_MINOR_VERSION); 9 | if (strcmp("",D_BUILD_VERSION)) 10 | v += sprintf(v, ".%s", D_BUILD_VERSION); 11 | } 12 | 13 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g32.test.g.1.check: -------------------------------------------------------------------------------- 1 | (/* start */ 2 | )identifier( /*some a*/ )( /*after = before 1 */ )expression: integer( /* after 1 before ; */ )( /*some a*/ )= in expression( /*after = before 1 */ )(/* start */ 3 | )expression ;( 4 | /* end */ 5 | )14 states 6 scans 4 shifts 8 reductions 0 compares 0 ambiguities 6 | (( a = 1 ) ; ) 7 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/sample.test.g.19.check: -------------------------------------------------------------------------------- 1 | ref Sym 'x' line 1: not found 2 | ref Sym 'x' line 1: not found 3 | ref Sym 'y' line 1: not found 4 | ref Sym 'x' line 1: not found 5 | ref Sym 'h' line 1: not found 6 | 66 states 33 scans 16 shifts 37 reductions 0 compares 0 ambiguities 7 | (( for ( ( x = 1 )( ; ( x < y )( ; ( x ++ ))) ) h ) ; ) 8 | -------------------------------------------------------------------------------- /RxODE/src/dparser/write_tables.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2002-2004 John Plevyak, All Rights Reserved 3 | */ 4 | 5 | int write_c_tables(Grammar *g); 6 | int write_binary_tables(Grammar *g); 7 | int write_binary_tables_to_file(Grammar *g, FILE *fp); 8 | int write_binary_tables_to_string(Grammar *g, 9 | unsigned char **str, unsigned int *str_len); 10 | -------------------------------------------------------------------------------- /RxODE/src/dparser/lr.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2002-2004 John Plevyak, All Rights Reserved 3 | */ 4 | 5 | #ifndef _lr_H_ 6 | #define _lr_H_ 7 | 8 | void build_LR_tables(Grammar *g); 9 | void sort_VecAction(VecAction *v); 10 | uint elem_symbol(Grammar *g, Elem *e); 11 | State *goto_State(State *s, Elem *e); 12 | void free_Action(Action *a); 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /RxODE/src/ode/Makefile: -------------------------------------------------------------------------------- 1 | #CC = gcc 2 | #FC = gfortran 3 | 4 | .PHONY: all 5 | 6 | LIBODEAUX = libodeaux.a 7 | 8 | LIB_SRCS = opkda2.f dlsoda.f opkda1_abbr.f vode.f 9 | LIB_OBJS = $(LIB_SRCS:%.f=%.o) dop853.o 10 | 11 | all: $(LIBODEAUX) 12 | 13 | $(LIBODEAUX): $(LIB_OBJS) 14 | $(AR) cruv $@ $^ 15 | $(RANLIB) $@ 16 | 17 | dop853.o: dop853.c 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g28.test.g.2.check: -------------------------------------------------------------------------------- 1 | 1 2 | 2 3 | 2 4 | 3 5 | 3 6 | 4 7 | 4 8 | 5 9 | 5 10 | 3 11 | 6 12 | 6 13 | 1 14 | 129 states 64 scans 44 shifts 80 reductions 0 compares 0 ambiguities 15 | ((( a : 1 ) ; )( { ((( a : 2 ) ; )( a ; )(( a : 3 ) ; )( { (( a ; )(( a : 4 ) ; )( a ; )(( a = 5 ) ; )( a ; )) } )( a ; )( { (( a = 6 ) ; ) } )( a ; )) } )( a ; )) 16 | -------------------------------------------------------------------------------- /RxODE/src/dparser/scan.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2002-2004 John Plevyak, All Rights Reserved 3 | */ 4 | 5 | #ifndef _scan_H_ 6 | #define _scan_H_ 7 | 8 | #include "d.h" 9 | 10 | typedef struct ShiftResult { 11 | struct SNode *snode; 12 | D_Shift *shift; 13 | d_loc_t loc; 14 | } ShiftResult; 15 | 16 | int scan_buffer(d_loc_t *loc, D_State *st, ShiftResult *result); 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g34.test.g: -------------------------------------------------------------------------------- 1 | { 2 | #include 3 | } 4 | 5 | ${declare longest_match identifier} 6 | 7 | P: S*; 8 | 9 | S: 'do' identifier 10 | { printf("do identifier\n"); } 11 | | identifier 12 | { printf("identifier\n"); } 13 | | identifierX 14 | { printf("identifierX\n"); } 15 | ; 16 | 17 | identifier: "[a-z]+" $term -1; 18 | identifierX: "[a-z]+X" $term -1; 19 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g48.test.g: -------------------------------------------------------------------------------- 1 | { 2 | #include "stdio.h" 3 | #include "string.h" 4 | #include "stdlib.h" 5 | char *xdup(char *s, char *e) { 6 | char *ss = malloc( e - s + 2 ); 7 | memcpy(ss, s, e-s); 8 | ss[e-s] = 0; 9 | return ss; 10 | } 11 | } 12 | top: A ( B C { printf("%s\n", xdup($n.start_loc.s, $n.end)); } ) D; 13 | A: 'A'; 14 | B: 'B'; 15 | C: 'C'; 16 | D: 'D'; 17 | whitespace: "[\t\n ]"; 18 | -------------------------------------------------------------------------------- /RxODE/src/dparser/my.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "dparse.h" 3 | extern D_ParserTables parser_tables_gram; 4 | int 5 | main(int argc, char *argv[]) { 6 | char s[256], *ss; 7 | D_Parser *p = new_D_Parser(&parser_tables_gram, sizeof(D_ParseNode_User)); 8 | if (fgets(s,255,stdin) && dparse(p, s, strlen(s)) && !p->syntax_errors) 9 | printf("success\n"); 10 | else 11 | printf("failure\n"); 12 | } 13 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/sample.test.g.24.check: -------------------------------------------------------------------------------- 1 | ref Sym 'x' line 1: not found 2 | ref Sym 'y' line 1: not found 3 | ref Sym 'z' line 1: not found 4 | ref Sym 'n' line 1: not found 5 | ref Sym 'q' line 1: not found 6 | ref Sym 's' line 1: not found 7 | ref Sym 't' line 1: not found 8 | 65 states 34 scans 26 shifts 38 reductions 0 compares 0 ambiguities 9 | (( if ( x ) ( y + ( z * n )) else ( q + ( s * t ))) ; ) 10 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g36.test.g: -------------------------------------------------------------------------------- 1 | { 2 | #include 3 | } 4 | 5 | ${declare all_matches S} 6 | ${declare longest_match do} 7 | 8 | P: S*; 9 | 10 | S: do identifier 11 | { printf("do identifier\n"); } 12 | | identifier 13 | { printf("identifier\n"); } 14 | | identifierX 15 | { printf("identifierX\n"); } 16 | ; 17 | 18 | do ::= 'do'; 19 | identifier: "[a-z]+" $term -1; 20 | identifierX: "[a-z]+X" $term -1; 21 | -------------------------------------------------------------------------------- /RxODE/src/dparser/gramgram.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2002-2004 John Plevyak, All Rights Reserved 3 | */ 4 | struct Production; 5 | struct Rule; 6 | struct Elem; 7 | 8 | typedef struct ParseNode_User { 9 | struct Production *p; 10 | struct Rule *r; 11 | struct Elem *e; 12 | unsigned int kind; 13 | } ParseNode_User; 14 | 15 | #define D_ParseNode_User ParseNode_User 16 | 17 | #define D_ParseNode_Globals struct Grammar 18 | 19 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g31.test.g.1.check: -------------------------------------------------------------------------------- 1 | final expression 2 | sym integer 3 | gen integer 4 | final expression 5 | sym integer 6 | sym integer 7 | sym + 8 | gen integer 9 | gen integer 10 | final expression 11 | sym integer 12 | sym integer 13 | sym + 14 | sym = 15 | gen integer 16 | gen integer 17 | gen = 18 | 39 states 17 scans 13 shifts 26 reductions 0 compares 0 ambiguities 19 | (( 1 ; )(( 2 + 3 ) ; )(( b = ( 3 + 4 )) ; )) 20 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/sample.test.g.26.check: -------------------------------------------------------------------------------- 1 | ref Sym 'x' line 1: not found 2 | ref Sym 'y' line 1: not found 3 | ref Sym 'y' line 1: not found 4 | ref Sym 'z' line 1: not found 5 | ref Sym 'z' line 1: not found 6 | ref Sym 'zz' line 1: not found 7 | ref Sym 'zzz' line 1: not found 8 | 51 states 32 scans 20 shifts 26 reductions 0 compares 0 ambiguities 9 | (( if ( x ) y else ( if ( y ) z else ( if ( z ) zz else zzz ))) ; ) 10 | -------------------------------------------------------------------------------- /RxODE/src/dparser/mkdparse.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2002-2004 John Plevyak, All Rights Reserved 3 | */ 4 | #ifndef _mkdparse_H_ 5 | #define _mkdparse_H_ 6 | 7 | #include 8 | #if defined(__cplusplus) 9 | extern "C" { 10 | #endif 11 | 12 | struct Grammar; 13 | 14 | void mkdparse(struct Grammar *g, char *grammar_pathname); 15 | void mkdparse_from_string(struct Grammar *g, char *str); 16 | 17 | #if defined(__cplusplus) 18 | } 19 | #endif 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g29.test.g.1.check: -------------------------------------------------------------------------------- 1 | duplicate identifier line 5 2 | duplicate identifier line 17 3 | 1 4 | 2 5 | 2 6 | 3 7 | 3 8 | 4 9 | 4 10 | 5 11 | 5 12 | 3 13 | 6 14 | 7 15 | 7 16 | 1 17 | 143 states 70 scans 48 shifts 87 reductions 0 compares 0 ambiguities 18 | ((( a : 1 ) ; )( { ((( a : 2 ) ; )( a ; )(( a : 3 ) ; )( { (( a ; )(( a : 4 ) ; )( a ; )(( a = 5 ) ; )( a ; )) } )( a ; )( { (( a = 6 ) ; ) } )(( a : 7 ) ; )( a ; )) } )( a ; )) 19 | -------------------------------------------------------------------------------- /RxODE/src/dparser/python/tests/test4.py: -------------------------------------------------------------------------------- 1 | import dparser 2 | 3 | def d_S(t): 4 | "S: a | b" 5 | return 'S' 6 | 7 | def d_a(t): 8 | "a : x1 x1 'y'" 9 | 10 | def d_b(t): 11 | "b : x2 x2 'y'" 12 | 13 | def d_x1(t, spec): 14 | "x1 : 'x'" 15 | 16 | def d_x2(t, spec): 17 | "x2 : 'x'" 18 | if spec: 19 | return dparser.Reject 20 | 21 | def syntax_error(t): 22 | print 'fail' 23 | 24 | parser = dparser.Parser() 25 | parser.parse('xxy', syntax_error_fn = syntax_error).getStructure() 26 | -------------------------------------------------------------------------------- /RxODE/src/dparser/python/README: -------------------------------------------------------------------------------- 1 | This module was created by Brian Sabbey (sabbey at u.washington.edu). 2 | 3 | See index.html for details. 4 | 5 | Swig: 6 | make swig 7 | 8 | made with SWIG Version 1.3 9 | 10 | Thanks to: 11 | 12 | Brennan Evans for more general unix support. 13 | 14 | Milosz Krajewski for non-unix support (mostly superseded by binary table support in d parser) and directory independence. 15 | 16 | Yves Forkl for bugs, usability suggestions, and emacs lisp code to jump to syntax error location. 17 | 18 | -------------------------------------------------------------------------------- /RxODE/NAMESPACE: -------------------------------------------------------------------------------- 1 | importFrom("tools", "md5sum") # to ensure equality 2 | import("utils") 3 | 4 | # export only these 3 RxODE functions and print methods 5 | export("RxODE", "rx.initCmpMgr", "eventTable") 6 | 7 | S3method("print", "RxODE") 8 | S3method("print", "EventTable") 9 | S3method("print", "RxCompilationManager") 10 | 11 | # the following is very experimental, probably will be 12 | # moved to a helper pkg 13 | export("genShinyApp.template", 14 | "write.template.server", 15 | "write.template.ui") 16 | 17 | #useDynLib("RxODE") 18 | -------------------------------------------------------------------------------- /RxODE/src/dparser/python/tests/test3.py: -------------------------------------------------------------------------------- 1 | from dparser import Parser 2 | 3 | def d_add1(t): 4 | '''add : add '+' mul''' 5 | return t[0] + t[2] 6 | 7 | def d_add2(t, nodes): 8 | '''add : mul''' 9 | return nodes[0].user.t 10 | 11 | def d_mul1(t): 12 | '''mul : mul '*' exp''' 13 | return t[0]*t[2] 14 | 15 | def d_mul2(t): 16 | '''mul : exp''' 17 | return t[0] 18 | 19 | def d_exp1(t): 20 | '''exp : "[0-9]+"''' 21 | return int(t[0]) 22 | 23 | def d_exp2(t): 24 | '''exp : '(' add ')' ''' 25 | return t[1] 26 | 27 | if Parser().parse('''3*(3+4)''').getStructure() != 21: 28 | print 'fail' 29 | -------------------------------------------------------------------------------- /RxODE/src/dparser/lex.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2002-2004 John Plevyak, All Rights Reserved 3 | */ 4 | 5 | #ifndef _lex_H_ 6 | #define _lex_H_ 7 | 8 | /* #define LIVE_DIFF_IN_TRANSITIONS */ 9 | 10 | struct Grammar; 11 | 12 | typedef struct ScanStateTransition { 13 | uint index; 14 | VecAction live_diff; 15 | VecAction accepts_diff; 16 | } ScanStateTransition; 17 | 18 | typedef struct ScanState { 19 | uint index; 20 | struct ScanState *chars[256]; 21 | VecAction accepts; 22 | VecAction live; 23 | ScanStateTransition *transition[256]; 24 | } ScanState; 25 | 26 | void build_scanners(struct Grammar *g); 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /RxODE/src/dparser/python/dparser.i: -------------------------------------------------------------------------------- 1 | %module dparser_swigc 2 | %{ 3 | #include "pydparser.h" 4 | %} 5 | 6 | %include "pydparser.h" 7 | 8 | typedef struct d_loc_t { 9 | void *s: /* converting to a string would be too expensive */ 10 | char *pathname, *ws; 11 | int col, line; 12 | } d_loc_t; 13 | 14 | typedef struct D_ParseNode { 15 | int symbol; 16 | d_loc_t start_loc; 17 | D_ParseNode_Globals *globals; 18 | user_pyobjects user; 19 | } D_ParseNode; 20 | 21 | D_ParseNode *d_get_child(D_ParseNode *pn, int child); 22 | D_ParseNode *d_find_in_tree(D_ParseNode *pn, int symbol); 23 | int d_get_number_of_children(D_ParseNode *pn); 24 | 25 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g45.test.g: -------------------------------------------------------------------------------- 1 | { 2 | #include "stdio.h" 3 | #include "dparse.h" 4 | D_Scope *saved = 0; 5 | } 6 | 7 | S: def use; 8 | 9 | def: 'a' { 10 | D_Scope *s = ${scope}; 11 | ${scope} = enter_D_Scope(${scope}, ${scope}); 12 | saved = ${scope}; 13 | NEW_D_SYM(${scope}, "a", 0); 14 | ${scope} = enter_D_Scope(${scope}, s); 15 | }; 16 | 17 | use: 'b' { 18 | if (find_D_Sym(${scope}, "a", 0)) 19 | printf("failed1\n"); 20 | else 21 | printf("succeed1\n"); 22 | ${scope} = scope_D_Scope(${scope}, saved); 23 | if (find_D_Sym(${scope}, "a", 0)) 24 | printf("succeed2\n"); 25 | else 26 | printf("failed2\n"); 27 | }; 28 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g47.test.g.1.check: -------------------------------------------------------------------------------- 1 | PARA(A para.) 2 | BARE 3 | BLOCK(%A para.) 4 | PARA(List item 1.) 5 | PARA( Item 1, para 2.) 6 | ITEM(---List item 1. Item 1, para 2.) 7 | PARA(List item 2.) 8 | ITEM(%---List item 2.) 9 | PARA(List item 3.) 10 | ITEM(%---List item 3.) 11 | LIST(---List item 1. Item 1, para 2.%---List item 2.%---List item 3.) 12 | BLOCK(---List item 1. Item 1, para 2.%---List item 2.%---List item 3.) 13 | PARA(Final para.) 14 | BARE 15 | BLOCK(%Final para.) 16 | 82 states 30 scans 17 shifts 80 reductions 3 compares 0 ambiguities 17 | (( % A para. )(( --- ( List item 1. Item 1, para 2. ))( %--- List item 2. )( %--- List item 3. ))(( % Final para. ) 18 | )) 19 | -------------------------------------------------------------------------------- /RxODE/src/dparser/python/tests/test.py: -------------------------------------------------------------------------------- 1 | from dparser import Parser 2 | 3 | def d_S(t): 4 | '''S : d '+' d''' 5 | return t[0] + t[2] 6 | 7 | def d_number(t): 8 | '''d : "[0-9]+" ''' 9 | return int(t[0]) 10 | 11 | def skip_space(loc): 12 | while loc.s < len(loc.buf) and loc.buf[loc.s:loc.s+len('hello')] == 'hello': 13 | loc.s = loc.s + len('hello') 14 | 15 | parser = Parser(make_grammar_file=1) 16 | 17 | buf = 'hi10hello+3hellohi' 18 | 19 | if parser.parse(buf, buf_offset=2, partial_parses=1, initial_skip_space_fn = skip_space).getStructure() != 13: 20 | print 'fail' 21 | 22 | buf = '87+5' 23 | if parser.parse(buf, initial_skip_space_fn = skip_space).getStructure() != 92: 24 | print 'fail' 25 | -------------------------------------------------------------------------------- /RxODE/tests/test-basic.R: -------------------------------------------------------------------------------- 1 | # Test basic RxODE() invocation (including errors) 2 | 3 | library("RxODE") 4 | library("tools") # use assertError() 5 | 6 | test.dir <- tempfile("Rx_base-") 7 | dir.create(test.dir) 8 | 9 | ode <- 'd/dt(y) = r * y * (1.0 - y/K);' 10 | 11 | # ODE inside a string 12 | m1 <- RxODE(model = ode, modName = "m1", do.compile=FALSE) 13 | 14 | # ODE in a text file 15 | fn <- file.path(test.dir, "exam3.1.txt") 16 | writeLines(ode, fn) 17 | m2 <- RxODE(filename = fn, modName = "f1", do.compile=FALSE) 18 | 19 | # Error: arguments model= and filename= are mutually exclusive. 20 | tools::assertError( 21 | RxODE(model=ode, filename=fn, do.compile=FALSE) 22 | ) 23 | 24 | unlink(test.dir, recursive = TRUE) 25 | -------------------------------------------------------------------------------- /RxODE/src/dparser/README: -------------------------------------------------------------------------------- 1 | This is DParser, a scannerless GLR parser. It uses to Tomita algorithm, 2 | and incorporates BNF production syntax, regular expression terminals, 3 | and a state-specific symbol table. 4 | 5 | It can be compiled to work with or without the Boehm Garbage Collector. 6 | To compile with GC, uncomment the line D_USE_GC=1 in the Makefile. 7 | 8 | The result is natural grammars and powerful parsing. 9 | 10 | To build: 'gmake' (only available with source code package) 11 | To test: 'gmake test' (only available with source code package) 12 | To install: 'gmake install' (binary or source code packages) 13 | 14 | For python support, '(cd python; gmake install)' 15 | 16 | Refer to the manual for more information. 17 | -------------------------------------------------------------------------------- /RxODE/src/dparser/python/tests/test5.py: -------------------------------------------------------------------------------- 1 | import dparser 2 | 3 | def d_h(t): 4 | 'h : h1 | h2' # uh oh, h1 and h2 are both matched by the letter a 5 | return t[0] 6 | 7 | def d_h1(t, spec_only): # h1 will be called for speculative parses only 8 | "h1 : 'a'" 9 | return 1 # This parse will be accepted since dparser.Reject is not returned. Its return value for the final parse will also be 1. 10 | 11 | def d_h2(t, spec): 12 | "h2 : 'a'" 13 | if spec: 14 | return dparser.Reject # don't let h2 match. If this were not here, a dparser.AmbiguityException exception would result 15 | return 2 16 | 17 | parser = dparser.Parser() 18 | if parser.parse('a').getStructure() != 1: 19 | print 'error' 20 | -------------------------------------------------------------------------------- /RxODE/src/dparser/verilog/ambig.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * ambig.c 4 | * 5 | * $Revision: 1.1 $ 6 | */ 7 | 8 | #include "d.h" 9 | #undef DPN_TO_PN 10 | #define DPN_TO_PN(_dpn) \ 11 | ((PNode *)(((char*)(_dpn))-(int)(&((PNode*)0)->parse_node))) 12 | 13 | extern void print_paren(PNode *); 14 | 15 | struct D_ParseNode * 16 | my_ambiguity_fn(struct D_Parser *pp, int n, struct D_ParseNode **v ) 17 | { 18 | int i; 19 | char *s; 20 | printf( "my_ambiguity_fn: %d possibilities:\n", n ); 21 | 22 | s = v[0]->start_loc.s; 23 | while (s != v[0]->end) 24 | putchar( s[0] ), s++; 25 | 26 | for (i=0; is[0] == 'a') { 8 | loc->s++; 9 | *symbol = A; 10 | return 1; 11 | } else if (loc->s[0] == 'b') { 12 | loc->s++; 13 | *symbol = BB; 14 | return 1; 15 | } else if (loc->s[0] == 'c') { 16 | loc->s++; 17 | *symbol = CCC; 18 | return 1; 19 | } else if (loc->s[0] == 'd') { 20 | loc->s++; 21 | *symbol = DDDD; 22 | return 1; 23 | } else 24 | return 0; 25 | } 26 | 27 | } 28 | ${scanner myscanner} 29 | ${token A BB CCC DDDD} 30 | 31 | S: A (BB CCC)+ SS; 32 | SS: DDDD; 33 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g24.test.g: -------------------------------------------------------------------------------- 1 | S: number*; 2 | number ::= integer | longinteger | floatnumber | imagnumber; 3 | integer ::= decimalinteger | octinteger | hexinteger; 4 | decimalinteger ::= nonzerodigit digit* | '0'; 5 | octinteger ::= '0' octdigit+; 6 | hexinteger ::= '0' ('x' | 'X') hexdigit+; 7 | floatnumber ::= pointfloat | exponentfloat; 8 | pointfloat ::= intpart? fraction | intpart '.'; 9 | exponentfloat ::= (intpart | pointfloat) exponent; 10 | intpart ::= digit+; 11 | fraction ::= "." digit+; 12 | exponent ::= ("e" | "E") ("+" | "-")? digit+; 13 | imagnumber ::= (floatnumber | intpart) ("j" | "J"); 14 | longinteger ::= integer ("l" | "L"); 15 | nonzerodigit ::= "[1-9]"; 16 | digit ::= "[0-9]"; 17 | octdigit ::= "[0-7]"; 18 | hexdigit ::= digit | "[a-fA-F]"; 19 | 20 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g31.test.g: -------------------------------------------------------------------------------- 1 | { 2 | #include 3 | } 4 | 5 | ${pass sym for_all postorder} 6 | ${pass gen for_all postorder} 7 | 8 | translation_unit: statement*; 9 | 10 | statement 11 | : expression ';' 12 | { 13 | printf("final expression\n"); 14 | d_pass(${parser}, &$n, ${pass sym}); 15 | d_pass(${parser}, &$n, ${pass gen}); 16 | } 17 | ; 18 | 19 | expression 20 | : identifier '=' expression $right 1 21 | sym: { printf("sym =\n"); } 22 | gen: { printf("gen =\n"); } 23 | | integer 24 | gen: { printf("gen integer\n"); } 25 | sym: { printf("sym integer\n"); } 26 | | expression '+' expression $right 2 27 | sym: { printf("sym +\n"); } 28 | ; 29 | 30 | integer: "-?([0-9]|0(x|X))[0-9]*(u|U|b|B|w|W|L|l)*" $term -1; 31 | identifier: "[a-zA-Z_][a-zA-Z_0-9]*"; 32 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g47.test.g: -------------------------------------------------------------------------------- 1 | { 2 | #include "stdio.h" 3 | #include "string.h" 4 | #include "stdlib.h" 5 | char *xdup(char *s, char *e) { 6 | char *ss = malloc( e - s + 2 ); 7 | memcpy(ss, s, e-s); 8 | ss[e-s] = 0; 9 | return ss; 10 | } 11 | } 12 | top: ( block explicit_space? )+; 13 | explicit_space : "[ \n]+"; 14 | block : para { printf("BLOCK(%s)\n", xdup($n.start_loc.s, $n.end)); } 15 | | list { printf("BLOCK(%s)\n", xdup($n.start_loc.s, $n.end)); }; 16 | list : list_item+ { printf("LIST(%s)\n", xdup($n.start_loc.s, $n.end)); }; 17 | list_item : "%?---" para_within_list+ { printf("ITEM(%s)\n", xdup($n.start_loc.s, $n.end)); }; 18 | para_within_list : "[a-zA-Z0-9 ,]+\." { printf("PARA(%s)\n", xdup($n.start_loc.s, $n.end)); }; 19 | para : '%' para_within_list { printf("BARE\n"); }; 20 | whitespace: "[\t\n]"; 21 | -------------------------------------------------------------------------------- /RxODE/src/dparser/verilog/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile 3 | # 4 | # $Revision: 1.1 $ 5 | # 6 | 7 | DPARSERDIR= .. 8 | GRAMMAR= verilog.g 9 | DPARSEFLAGS= -l -v 10 | 11 | TARGET= v 12 | CSRCS= main.c vparse.c ambig.c 13 | OBJS= $(CSRCS:.c=.o) $(GRAMMAR).d_parser.o 14 | INCDIRSS= -I$(DPARSERDIR) 15 | CFLAGS= -g $(INCDIRSS) 16 | 17 | ######### 18 | 19 | target: $(TARGET) 20 | 21 | ########## 22 | 23 | $(TARGET): $(OBJS) 24 | $(CC) $(CFLAGS) -o $@ $(OBJS) \ 25 | -L$(DPARSERDIR) -ldparse 26 | 27 | $(GRAMMAR).d_parser.c: $(GRAMMAR) 28 | $(DPARSERDIR)/make_dparser $(DPARSEFLAGS) $(GRAMMAR) 29 | 30 | lint: 31 | lint $(CFLAGS) $(CSRCS) 32 | 33 | test: $(TARGET) 34 | ./verilog_tests 35 | grep succeeded log.txt | wc -l 36 | grep failed log.txt | wc -l 37 | 38 | clean: 39 | rm -f $(GRAMMAR).d_parser.c $(TARGET) $(OBJS) log.txt 40 | -------------------------------------------------------------------------------- /RxODE/src/dparser/4calc.g: -------------------------------------------------------------------------------- 1 | { 2 | #include 3 | #include 4 | 5 | typedef struct My_ParseNode { 6 | int value; 7 | } My_ParseNode; 8 | #define D_ParseNode_User My_ParseNode 9 | } 10 | 11 | translation_unit : 12 | statement* 13 | ; 14 | 15 | statement : 16 | expr ';' { printf("%d\n", $0.value); } 17 | ; 18 | 19 | expr : 20 | integer { $$.value = atoi($n0.start_loc.s); } 21 | | expr '+' expr $right 10 { $$.value = $0.value + $2.value; } 22 | | expr '-' expr $right 10 { $$.value = $0.value - $2.value; } 23 | | expr '*' expr $right 20 { $$.value = $0.value * $2.value; } 24 | | expr '/' expr $right 20 { $$.value = $0.value / $2.value; } 25 | | '(' expr ')' { $$.value = $1.value; } 26 | ; 27 | 28 | integer : 29 | "-?[0-9]+" 30 | ; 31 | -------------------------------------------------------------------------------- /RxODE/src/dparser/verilog/README: -------------------------------------------------------------------------------- 1 | 2 | This Verilog grammar was contributed by Thomas Skibo (thanx!). 3 | 4 | To make, type 'make'. 5 | 6 | To test, get the test suite from ftp://icarus.com/pub/eda/verilog/tests 7 | 8 | and untar into this directory, then type 'make test'. 9 | 10 | The result should be: 11 | 12 | ./verilog_tests 13 | grep succeeded log.txt | wc -l 14 | 383 15 | grep failed log.txt | wc -l 16 | 8 17 | 18 | The failures represent unsupported features: 19 | 20 | testsuite/ivltests/always3.1.1K.v failed 21 | testsuite/ivltests/function3.11E.v failed 22 | testsuite/ivltests/signed1.v failed 23 | testsuite/ivltests/signed2.v failed 24 | testsuite/ivltests/signed3.v failed 25 | testsuite/ivltests/signed4.v failed 26 | testsuite/ivltests/wildsense.v failed 27 | testsuite/ivltests/specify_01.v failed 28 | 29 | see log.txt for details. 30 | -------------------------------------------------------------------------------- /RxODE/src/Makefile: -------------------------------------------------------------------------------- 1 | CC = `"$(R_HOME)/bin/R" CMD config CC` 2 | FC = `"$(R_HOME)/bin/R" CMD config FC` 3 | CFLAGS = `"$(R_HOME)/bin/R" CMD config CFLAGS` 4 | FFLAGS = `"$(R_HOME)/bin/R" CMD config FFLAGS` 5 | 6 | # Run make in subdirs 7 | all: libodeaux libdparse libtran 8 | 9 | libodeaux: 10 | echo "make libodeaux.a in ode/ ..." 11 | (cd ode; $(MAKE) CC="$(CC)" FC="$(FC)" CFLAGS="$(CFLAGS) -fPIC" FFLAGS="$(FFLAGS) -fPIC" AR="$(AR)" RANLIB="$(RANLIB)" libodeaux.a) 12 | 13 | libdparse: 14 | echo "make libdparse.a in dparser/ ..." 15 | (cd dparser; $(MAKE) -f Makefile.new CC="$(CC)" CFLAGS="$(CFLAGS)" AR="$(AR)" RANLIB="$(RANLIB)" libdparse.a) 16 | 17 | libtran: 18 | echo "make tran ..." 19 | ($(CC) tran*.c -Idparser -Ldparser -ldparse -o tran.exe) 20 | 21 | clean: 22 | echo "cleaning ..." 23 | (cd dparser;rm -f *.o *.a) 24 | (cd ode;rm -f *.o *.a) 25 | rm -f *.exe 26 | -------------------------------------------------------------------------------- /RxODE/src/dparser/mkdparse.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2002-2004 John Plevyak, All Rights Reserved 3 | */ 4 | 5 | #include "gramgram.h" 6 | #include "d.h" 7 | #include "mkdparse.h" 8 | 9 | static void 10 | mkdparse_internal(Grammar *g, char *grammar_pathname, char *str) { 11 | if (!grammar_pathname) 12 | grammar_pathname = "-"; 13 | if (parse_grammar(g, grammar_pathname, str) < 0) 14 | d_fail("unable to parse grammar '%s'", grammar_pathname); 15 | if (g->productions.n < 2) 16 | d_fail("no productions in grammar '%s'", grammar_pathname); 17 | if (build_grammar(g) < 0) 18 | d_fail("unable to load grammar '%s'", grammar_pathname); 19 | } 20 | 21 | void 22 | mkdparse(Grammar *g, char *grammar_pathname) { 23 | mkdparse_internal(g, grammar_pathname, 0); 24 | } 25 | 26 | void 27 | mkdparse_from_string(Grammar *g, char *str) { 28 | mkdparse_internal(g, 0, str); 29 | } 30 | 31 | -------------------------------------------------------------------------------- /RxODE/src/dparser/python/tests/test6.py: -------------------------------------------------------------------------------- 1 | # replaces the '%' symbol with '+', leaving the return values of actions usable for other things, such as type information, 2 | # and leaving whitespace intact. 3 | 4 | from dparser import Parser 5 | 6 | # turn a tree of strings into a single string (slowly): 7 | def stringify(s): 8 | if not isinstance(s, str): 9 | return ''.join(map(stringify, s)) 10 | return s 11 | 12 | def d_add1(t, s): 13 | "add : add '%' exp" 14 | s[1] = '+ ' # replace the % with + 15 | 16 | def d_add2(t, s): 17 | "add : exp" 18 | 19 | def d_exp(t): 20 | 'exp : "[0-9]+" ' 21 | 22 | # if the start action specifies the 's' argument, then parser 23 | # will contain a member, s, 24 | 25 | parser = Parser() 26 | parsedmessage = parser.parse('1 % 2 % 3') 27 | if stringify(parsedmessage.getStringLeft()) != '1 + 2 + 3': 28 | print 'error' 29 | -------------------------------------------------------------------------------- /RxODE/src/Makefile.win: -------------------------------------------------------------------------------- 1 | CC = `"$(R_HOME)/bin/R" CMD config CC` 2 | FC = `"$(R_HOME)/bin/R" CMD config FC` 3 | CFLAGS = `"$(R_HOME)/bin/R" CMD config CFLAGS` 4 | FFLAGS = `"$(R_HOME)/bin/R" CMD config FFLAGS` 5 | include $(R_HOME)/etc/$(R_ARCH)/Makeconf 6 | 7 | # Run make in subdirs 8 | all: libodeaux libdparse libtran 9 | 10 | libodeaux: 11 | echo "make libodeaux.a in ode/ ..." 12 | (cd ode; $(MAKE) CC="$(CC)" FC="$(FC)" CFLAGS="$(CFLAGS)" FFLAGS="$(FFLAGS)" AR="$(AR)" RANLIB="$(RANLIB)" libodeaux.a) 13 | 14 | libdparse: 15 | echo "make libodeaux.a ..." 16 | (cd dparser; $(MAKE) -f Makefile.new CC="$(CC)" CFLAGS="$(CFLAGS)" AR="$(AR)" RANLIB="$(RANLIB)" libdparse.a) 17 | 18 | libtran: 19 | echo "make tran ..." 20 | ($(CC) tran*.c -Idparser -Ldparser -ldparse -o tran.exe) 21 | 22 | clean: 23 | echo "cleaning ..." 24 | (cd dparser;rm -f *.o *.a) 25 | (cd ode;rm -f *.o *.a) 26 | rm -f *.exe 27 | -------------------------------------------------------------------------------- /RxODE/src/dparser/read_binary.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2002-2004 John Plevyak, All Rights Reserved 3 | */ 4 | #ifndef _read_binary_H_ 5 | #define _read_binary_H_ 6 | 7 | typedef struct BinaryTablesHead { 8 | int n_relocs; 9 | int n_strings; 10 | int d_parser_tables_loc; 11 | int tables_size; 12 | int strings_size; 13 | } BinaryTablesHead; 14 | 15 | typedef struct BinaryTables { 16 | D_ParserTables *parser_tables_gram; 17 | char *tables; 18 | } BinaryTables; 19 | 20 | 21 | BinaryTables * read_binary_tables(char *file_name, D_ReductionCode spec_code, D_ReductionCode final_code); 22 | BinaryTables * read_binary_tables_from_file(FILE *fp, D_ReductionCode spec_code, D_ReductionCode final_code); 23 | BinaryTables * read_binary_tables_from_string(unsigned char *buf, D_ReductionCode spec_code, D_ReductionCode final_code); 24 | void free_BinaryTables(BinaryTables * binary_tables); 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /RxODE/src/dparser/arg.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 1994-2004 John Plevyak, All Rights Reserved 3 | */ 4 | #include 5 | #include 6 | #include 7 | 8 | #ifndef __alpha 9 | #define atoll atol 10 | #endif 11 | 12 | /* Argument Handling 13 | */ 14 | struct ArgumentState; 15 | 16 | typedef void ArgumentFunction(struct ArgumentState *arg_state, char *arg); 17 | 18 | typedef struct { 19 | char *name; 20 | char key; 21 | char *description; 22 | char *type; 23 | void *location; 24 | char *env; 25 | ArgumentFunction *pfn; 26 | } ArgumentDescription; 27 | 28 | typedef struct ArgumentState { 29 | char **file_argument; 30 | int nfile_arguments; 31 | char *program_name; 32 | ArgumentDescription *desc; 33 | } ArgumentState; 34 | 35 | void usage(ArgumentState *arg_state, char *arg_unused); 36 | void process_args(ArgumentState *arg_state, char **argv); 37 | void free_args(ArgumentState *arg_state); 38 | -------------------------------------------------------------------------------- /RxODE/src/dparser/python/tests/test2.py: -------------------------------------------------------------------------------- 1 | from dparser import Parser 2 | 3 | def d_add(t): 4 | '''add : add '+' mul 5 | | mul''' 6 | if(len(t) == 1): 7 | return t[0] 8 | return t[0] + t[2] 9 | 10 | def d_mul(t): 11 | '''mul : mul '*' exp 12 | | exp''' 13 | if(len(t) == 1): 14 | return t[0] 15 | return t[0]*t[2] 16 | 17 | def d_exp(t): 18 | '''exp : number1 19 | | number2 20 | | '(' add ')' ''' 21 | if(len(t) == 1): 22 | return int(t[0]) 23 | return t[1] 24 | 25 | def d_number1(t): 26 | '''number1 : number''' 27 | return t[0] 28 | 29 | def d_number2(t): 30 | '''number2 : number''' 31 | return t[0] 32 | 33 | def d_number(t): 34 | '''number : "[0-9]+"''' 35 | return t[0] 36 | 37 | def ambiguity_func(v): 38 | return v[0] 39 | 40 | def d_whitespace(t, spec): 41 | "whitespace : ' '*" 42 | 43 | if Parser().parse('1 +2* (3+ 4+5)', ambiguity_fn = ambiguity_func, print_debug_info=0).getStructure() != 25: 44 | print 'fail' 45 | -------------------------------------------------------------------------------- /RxODE/src/install.libs.R: -------------------------------------------------------------------------------- 1 | # Copy libs, headers, and binaries to to 2 | # R_PACKAGE_DIR/{libs,include,bin} as per architecture 3 | 4 | bin <- file.path(R_PACKAGE_DIR, paste0("bin", R_ARCH)) 5 | libs <- file.path(R_PACKAGE_DIR, paste0("libs", R_ARCH)) 6 | incl <- file.path(R_PACKAGE_DIR, "include") 7 | 8 | if(!file.exists(bin)) 9 | dir.create(bin, recursive = TRUE, showWarnings = FALSE) 10 | 11 | if(!file.exists(libs)) 12 | dir.create(libs, recursive = TRUE, showWarnings = FALSE) 13 | 14 | if(!file.exists(incl)) 15 | dir.create(incl, recursive = TRUE, showWarnings = FALSE) 16 | 17 | # binary files 18 | files <- file.path(".", "tran.exe") 19 | message("Installing ", files, " to ", bin) 20 | file.copy(files, bin, overwrite = TRUE) 21 | 22 | # libs 23 | files <- file.path("ode", "libodeaux.a") 24 | message("Installing ", files, " to ", libs) 25 | file.copy(files, libs, overwrite = TRUE) 26 | 27 | # header files 28 | files <- file.path("ode", "dop853.h") 29 | message("Installing ", files, " to ", incl) 30 | file.copy(files, incl, overwrite = TRUE) 31 | 32 | -------------------------------------------------------------------------------- /RxODE/tests/test3.2.R: -------------------------------------------------------------------------------- 1 | # Example 3.2 from 2 | # "Solving Differential Equations in R" by Soetaert et al (2012) 3 | 4 | library("RxODE") 5 | 6 | ode <- 7 | RxODE( 8 | model = ' 9 | d/dt(X) = a*X + Y*Z; 10 | d/dt(Y) = b*(Y - Z); 11 | d/dt(Z) = -X*Y + c*Y - Z;', 12 | modName = "test_3-2", 13 | wd = tempdir() # don't pollute "./tests" 14 | ) 15 | 16 | et <- eventTable() # default time units 17 | et$add.sampling(seq(from=0, to=100, by=0.01)) 18 | 19 | out <- 20 | ode$solve( 21 | params = c(a=-8/3, b=-10, c=28), 22 | events = et, 23 | inits = c(X=1, Y=1, Z=1) 24 | ) 25 | 26 | print(head(out, n = 15), digits = 6) 27 | 28 | 29 | # old <- par(mfrow=c(2,2)) 30 | # 31 | # plot(out[,"time"], out[,"X"], xlab="time", ylab="X", type="l") 32 | # plot(out[,"time"], out[,"Y"], xlab="time", ylab="Y", type="l") 33 | # plot(out[,"time"], out[,"Z"], xlab="time", ylab="Z", type="l") 34 | # plot(out[,"X"], out[,"Y"], xlab="X", ylab="Y", type="l") 35 | # 36 | # par(old) 37 | 38 | 39 | -------------------------------------------------------------------------------- /RxODE/inst/Porting: -------------------------------------------------------------------------------- 1 | RxODE has been successfully installed on the following environments: 2 | 3 | Linux: 4 | * Ubuntu 14.04 LTS, gcc 4.8.2, gfortran 4.8.2 5 | * Red Hat Enterprise Linux Server release 6.5, Intel icc and ifort 6 | version 14.0.1 compilers (compatible with gcc 4.4.7). 7 | 8 | Max OS/X: 9 | * MaC OS/X 10.6 (Snow Leopard), R 3.0.2, gcc 4.2.1, gfortran 4.2.3 10 | 11 | Windows i386: 12 | * Windows 7, R 3.0.2, Rtools30 13 | * Windows 7, R 3.1.1, Rtools31 14 | 15 | Troubleshooting: 16 | 17 | * Under Windows, make sure Rtools are properly installed, in particular 18 | the PATH variable needs to be set properly, e.g., it may need to 19 | include the "libexec\gcc\i686-w64-mingw32\" subdirectory, 20 | otherwise you may see the error 21 | "gcc.exe: error: CreateProcess: No such file or directory" 22 | when running RxODE(). 23 | 24 | * Under Windows, make sure the RxODE is installed in a library whose 25 | path name contains no spaces -- having spaces in the path name will 26 | most likely break calls to "R CMD SHLIB ..." from within the R 27 | console/GUI. 28 | 29 | -------------------------------------------------------------------------------- /RxODE/src/dparser/python/make_tables.c: -------------------------------------------------------------------------------- 1 | #include "../gramgram.h" 2 | #include "../d.h" 3 | #include "../mkdparse.h" 4 | 5 | int 6 | make_tables(char *grammar_string, char *grammar_pathname) { 7 | Grammar *g; 8 | g = new_D_Grammar(grammar_pathname); 9 | g->set_op_priority_from_rule = 0; 10 | g->right_recursive_BNF = 0; 11 | g->states_for_whitespace = 1; 12 | g->states_for_all_nterms = 1; 13 | g->tokenizer = 0; 14 | g->longest_match = 0; 15 | strcpy(g->grammar_ident, "gram"); 16 | g->scanner_blocks = 4; 17 | g->scanner_block_size = 0; 18 | g->write_line_directives = 1; 19 | g->write_header = -1; 20 | g->token_type = 0; 21 | strcpy(g->write_extension, "dat"); 22 | static char output_file [1024] = ""; 23 | strncpy(output_file, grammar_pathname, sizeof(output_file)-1); 24 | strncat(output_file, ".d_parser.", sizeof(output_file)-strlen(output_file)-1); 25 | strncat(output_file, g->write_extension, sizeof(output_file)-strlen(output_file)-1); 26 | g->write_pathname = output_file; 27 | 28 | mkdparse_from_string(g, grammar_string); 29 | 30 | if (write_binary_tables(g) < 0) 31 | d_fail("unable to write tables"); 32 | 33 | free_D_Grammar(g); 34 | return 0; 35 | } 36 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g33.test.g.1.check: -------------------------------------------------------------------------------- 1 | final expression 2 | sym integer 3 | sym expression: integer 4 | default sym(statement : "1;") 5 | default gen(integer : "1") 6 | gen expression: integer 7 | default gen(statement : "1;") 8 | final expression 9 | sym integer 10 | sym expression: integer 11 | sym integer 12 | sym expression: integer 13 | sym + 14 | default sym(statement : "2 + 3;") 15 | default gen(integer : "2") 16 | gen expression: integer 17 | default gen(integer : "3") 18 | gen expression: integer 19 | default gen(expression : "2 + 3") 20 | default gen(statement : "2 + 3;") 21 | final expression 22 | default sym(identifier : "b") 23 | sym integer 24 | sym expression: integer 25 | sym integer 26 | sym expression: integer 27 | sym + 28 | sym expression: = 29 | default sym(statement : "b = 3 + 4;") 30 | default gen(identifier : "b") 31 | default gen(integer : "3") 32 | gen expression: integer 33 | default gen(integer : "4") 34 | gen expression: integer 35 | default gen(expression : "3 + 4") 36 | default gen(expression : "b = 3 + 4") 37 | default gen(statement : "b = 3 + 4;") 38 | 39 states 17 scans 13 shifts 26 reductions 0 compares 0 ambiguities 39 | (( 1 ; )(( 2 + 3 ) ; )(( b = ( 3 + 4 )) ; )) 40 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g50.test.g.1.check: -------------------------------------------------------------------------------- 1 | :144: syntax error after ';' 2 | :145: syntax error after '} 3 | ' 4 | :146: syntax error after '} 5 | ' 6 | :147: syntax error after 'bool dragged; 7 | ' 8 | :148: syntax error after '{ 9 | if( input.button == Key.Escape ) ' 10 | :149: syntax error after 'if' 11 | :150: syntax error after ';' 12 | :153: syntax error after '}' 13 | :158: syntax error after '}' 14 | :159: syntax error after '}} 15 | ' 16 | :160: syntax error after ')' 17 | :161: syntax error after 'LeftButton || button == Key.RightButton) ) { 18 | if(!dragged) ' 19 | :162: syntax error after '}' 20 | :163: syntax error after '}' 21 | :164: syntax error after '} 22 | } 23 | ' 24 | :165: syntax error after '}' 25 | :166: syntax error after '}} 26 | ' 27 | :167: syntax error after '}} 28 | void move() { with(input) { 29 | if( rZ ) ' 30 | :168: syntax error after '}} 31 | void move() { with(input) { 32 | if( rZ ) { 33 | if( modifiers[Key.LeftShift] ' 34 | :169: syntax error after ')' 35 | :171: syntax error after '}' 36 | :185: syntax error after 't' 37 | :187: syntax error after ';' 38 | :188: syntax error after ';' 39 | :189: syntax error after ';' 40 | :190: syntax error after ';' 41 | fatal error, '' line 190 42 | -------------------------------------------------------------------------------- /RxODE/tests/test3.1.R: -------------------------------------------------------------------------------- 1 | # Example 3.1 from the book 2 | # "Solving Differential Equations in R" by Soetaert et al (2012) 3 | # Use both the default stiff solver and the non-stiff solver 4 | 5 | library("RxODE") 6 | 7 | old <- options(digits = 6) 8 | 9 | ode <- 10 | RxODE( 11 | model = 'd/dt(y) = r * y * (1.0 - y/K);', 12 | modName = "test_3-1", 13 | wd = tempdir() # don't pollute "./tests" 14 | ) 15 | 16 | # create event table with times at which we observe the system 17 | et <- eventTable(time.units= NA) 18 | et$add.sampling(seq(from = 0, to = 20, by = 0.2)) 19 | 20 | # same model, different initial values (2 and 12) 21 | out1 <- ode$solve(params=c(r=1, K=10), events=et, inits=c(y=2)) 22 | out2 <- ode$solve(params=c(r=1, K=10), events=et, inits=c(y=12)) 23 | 24 | #matplot(x = out1[,1], y = cbind(out1[,2], out2[,2]), type = "l", 25 | # main = "logistic growth", xlab="time", ylab="") 26 | 27 | # Now use a non-stiff solver 28 | 29 | out1.ns <- 30 | ode$solve(params=c(r=1, K=10), events=et, inits=c(y=2), stiff=FALSE) 31 | out2.ns <- 32 | ode$solve(params=c(r=1, K=10), events=et, inits=c(y=12), stiff=FALSE) 33 | 34 | head(cbind(out1, out2, out1.ns, out2.ns), n = 15) 35 | 36 | options(old) 37 | -------------------------------------------------------------------------------- /RxODE/src/dparser/python/setup.py: -------------------------------------------------------------------------------- 1 | from distutils.core import setup, Extension 2 | from distutils.command.install_data import install_data 3 | import os, sys 4 | 5 | #Pete Shinner's distutils data file fix... from distutils-sig 6 | #data installer with improved intelligence over distutils 7 | #data files are copied into the project directory instead 8 | #of willy-nilly 9 | class smart_install_data(install_data): 10 | def run(self): 11 | #need to change self.install_dir to the library dir 12 | install_cmd = self.get_finalized_command('install') 13 | self.install_dir = getattr(install_cmd, 'install_lib') 14 | return install_data.run(self) 15 | 16 | module_swigc = Extension('_dparser_swigc', 17 | sources = ['dparser_wrap.c', 'pydparser.c', 'make_tables.c'], 18 | define_macros = [('SWIG_GLOBAL', None)], 19 | libraries = ['mkdparse', 'dparse'], 20 | library_dirs = ['../'], 21 | extra_compile_args = ['-Wall', '-ggdb3']) 22 | 23 | setup(name="dparser", 24 | cmdclass = {"install_data": smart_install_data}, 25 | version = "1.30", 26 | description = 'DParser for Python', 27 | py_modules = ["dparser", "dparser_swigc"], 28 | ext_modules = [module_swigc], 29 | ) 30 | -------------------------------------------------------------------------------- /RxODE/src/dparser/parser_tests: -------------------------------------------------------------------------------- 1 | #!/bin/tcsh 2 | 3 | #unset D_USE_FREELISTS for best valgrind results 4 | #setenv VALGRIND 'valgrind -q ' 5 | setenv VALGRIND ' ' 6 | 7 | cp D_BUILD_VERSION Makefile *.c *.h grammar.g tests 8 | cd tests 9 | $MAKE -s make_dparser 10 | $MAKE gram 11 | $MAKE -s make_dparser 12 | set failed = 0 13 | foreach g (*.test.g) 14 | rm -f sample_parser 15 | if (-e $g.flags) then 16 | set flags = `cat $g.flags` 17 | else 18 | set flags = 19 | endif 20 | $VALGRIND ./make_dparser $flags $g 21 | $MAKE -s sample_parser SAMPLE_GRAMMAR=$g:t 22 | foreach t ( $g.[0-9] $g.[0-9][0-9] ) 23 | if (-e $t.flags) then 24 | set flags = `cat $t.flags` 25 | else 26 | set flags = 27 | endif 28 | $VALGRIND ./sample_parser $flags -v $t >&! $t.out 29 | diff $t.out $t.check 30 | if ($?) then 31 | echo $t "******** FAILED ********" 32 | set failed = `expr $failed + 1` 33 | else 34 | echo $t "PASSED" 35 | endif 36 | end 37 | end 38 | echo "---------------------------------------" 39 | if (! $failed) then 40 | echo "ALL tests PASSED" 41 | else 42 | echo "********" $failed "test(s) FAILED *********" 43 | endif 44 | rm -f sample_parser D_BUILD_VERSION Makefile *.c *.h *.o make_dparser libdparse.a grammar.g 45 | cd .. 46 | -------------------------------------------------------------------------------- /RxODE/src/dparser/python/tests/test7.py: -------------------------------------------------------------------------------- 1 | # the 'nodes' argument to actions is useful for obtaining line number information and such 2 | 3 | from dparser import Parser 4 | 5 | def d_start(t, nodes, this): # in this example, nodes[0] is the D_ParseNode for 'noun' 6 | 'start : noun verb' 7 | 8 | # the 'buf' member contains the entire string that is being parsed 9 | buf = nodes[0].buf 10 | noun = nodes[0] 11 | 12 | # the 'end', 'end_skip', and 'start_loc.s' members of nodes[0] are indices into relevant parts of buf: 13 | buf[noun.start_loc.s:noun.end] # 'cat' 14 | buf[noun.start_loc.s:] # 'cat flies' 15 | buf[noun.end:] # ' flies' 16 | buf[noun.end_skip:] # 'flies' 17 | 18 | # line numbers and columns: 19 | noun.start_loc.line 20 | noun.start_loc.col 21 | 22 | # the 'this' argument is the D_ParseNode for this action: 23 | buf[this.start_loc.s:this.end] # 'cat flies' 24 | 25 | # children of a node can also be obtained with the 'c' member: 26 | # this.c[0] is the same as nodes[0] 27 | 28 | def d_noun(t, this): 29 | "noun : 'cat'" 30 | return t[0] 31 | 32 | def d_verb(t, this): 33 | "verb : 'flies'" 34 | return t[0] 35 | 36 | Parser().parse('cat flies').getStructure() 37 | -------------------------------------------------------------------------------- /RxODE/src/dparser/python/contrib/dparserpy-syntax_error.py: -------------------------------------------------------------------------------- 1 | ### PYTHON FRAGMENT 2 | 3 | # suggestions for code improvement are highly welcome ;-) 4 | 5 | def syntax_error(loc): 6 | contextwidth_left = 30 7 | contextwidth_right = 30 8 | ellipsis = '[...]' 9 | locbuf_flattened = loc.buf.replace("\n","\254") # \254 is 'not sign' 10 | 11 | spanstart = loc.s - contextwidth_left 12 | mn = max(spanstart, 0) 13 | if spanstart > 0: 14 | before = ellipsis + locbuf_flattened[mn + len(ellipsis):loc.s] 15 | else: 16 | before = locbuf_flattened[mn:loc.s] 17 | space = ' '*(contextwidth_left - len(before)) 18 | before = space + before 19 | 20 | spanend = loc.s + contextwidth_right 21 | mx = min(spanend, len(locbuf_flattened)) 22 | after = locbuf_flattened[loc.s:mx] 23 | if len(after) > (contextwidth_right - len(ellipsis)): 24 | after = locbuf_flattened[loc.s:(mx - len(ellipsis))] + ellipsis 25 | 26 | print "-"*79 27 | print "File %s:\n" % inputfilename 28 | print before +\ 29 | " ____________\n" +\ 30 | " "*contextwidth_left +\ 31 | "/syntax error at line " + str(loc.line) +\ 32 | " (buffer pos. " + str(loc.s) + ")" 33 | print " "*contextwidth_left + after 34 | print "-"*79 35 | -------------------------------------------------------------------------------- /RxODE/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: RxODE 2 | Version: 0.5-6 3 | Date: 2016-11-01 4 | Title: Facilities for Simulating from ODE-Based Models 5 | Authors@R: c( 6 | person("Melissa", "Hallow", 7 | role = "aut", email = "hallowkm@uga.edu"), 8 | person("Matthew L.","Fidler", 9 | role = "aut", email = "matthew.fidler@gmail.com"), 10 | person("Wenping", "Wang", 11 | role = c("aut", "cre"), email = "wwang8198@gmail.com") 12 | ) 13 | Author: Melissa Hallow [aut], Matthew L. Fidler [aut], Wenping Wang [aut, cre] 14 | Maintainer: Wenping Wang 15 | Depends: R (>= 3.0.0) 16 | Suggests: knitr, rmarkdown, shiny 17 | Imports: utils 18 | Description: Facilities for running simulations from ordinary 19 | differential equation (ODE) models, such as pharmacometrics and other 20 | compartmental models. A compilation manager translates the ODE model 21 | into C, compiles it, and dynamically loads the object code into R for 22 | improved computational efficiency. An event table object facilitates 23 | the specification of complex dosing regimens (optional) and sampling 24 | schedules. 25 | NeedsCompilation: yes 26 | VignetteBuilder: knitr 27 | SystemRequirements: GNU make 28 | License: GPL (>= 2) 29 | URL: https://www.r-project.org, https://github.com/hallowkm/RxODE 30 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g40.test.g: -------------------------------------------------------------------------------- 1 | { 2 | 3 | struct D_Sym; 4 | struct D_Scope; 5 | 6 | typedef struct My_ParseNode { 7 | struct D_Sym *sym; 8 | struct D_Scope *saved_scope; 9 | } My_ParseNode; 10 | #define D_ParseNode_User My_ParseNode 11 | 12 | #define NEW_SYM(_s, _scope, _start, _end) do { \ 13 | _scope = enter_D_Scope(_scope, _scope); /* clone scope */ \ 14 | _s = NEW_D_SYM(_scope, _start, _end); \ 15 | } while (0) 16 | 17 | } 18 | 19 | statement: expression ';' ; 20 | 21 | expression 22 | : identifier 23 | | def_identifier expression $right 5100 /* define variable */ 24 | | def_function expression $right 5100 /* define function */ 25 | [ ${scope} = enter_D_Scope(${scope}, $0.saved_scope); ] 26 | | pre_operator expression 27 | | expression binary_operator expression 28 | ; 29 | 30 | def_identifier: identifier ':' 31 | [ NEW_SYM($$.sym, ${scope}, $n0.start_loc.s, $n0.end); ] 32 | ; 33 | 34 | def_function: identifier identifier+ ':' 35 | [ 36 | NEW_SYM($$.sym, ${scope}, $n0.start_loc.s, $n0.end); 37 | $$.saved_scope = ${scope}; 38 | ${scope} = new_D_Scope(${scope}); 39 | ] 40 | ; 41 | 42 | binary_operator 43 | : '+' $binary_op_left 9500 44 | | $binary_op_left 7000 45 | ; 46 | 47 | pre_operator 48 | : '+' $unary_op_right 9800 49 | ; 50 | 51 | identifier: "[a-zA-Z_][a-zA-Z0-9_]*" $term -1; 52 | -------------------------------------------------------------------------------- /RxODE/tests/Examples/eventTable.Rout.save: -------------------------------------------------------------------------------- 1 | 2 | evntTb> # create dosing and observation (sampling) events 3 | evntTb> # QD 50mg dosing, 5 days followed by 25mg 5 days 4 | evntTb> 5 | evntTb> qd <- eventTable(amount.units = "mg", time.units = "days") 6 | 7 | evntTb> qd$add.dosing(dose=50, nbr.doses=5, dosing.interval = 1, do.sampling=FALSE) 8 | 9 | evntTb> # sample the system's drug amounts hourly the first day, then every 12 hours 10 | evntTb> # for the next 4 days 11 | evntTb> qd$add.sampling(seq(from = 0, to = 1, by = 1/24)) 12 | 13 | evntTb> qd$add.sampling(seq(from = 1, to = 5, by = 12/24)) 14 | 15 | evntTb> #print(qd$get.dosing()) # table of dosing records 16 | evntTb> print(qd$get.nobs()) # number of observation (not dosing) records 17 | [1] 34 18 | 19 | evntTb> # BID dosing, 5 days 20 | evntTb> 21 | evntTb> bid <- eventTable("mg", "days") # only dosing 22 | 23 | evntTb> bid$add.dosing(dose=10000, nbr.doses=2*5, 24 | evntTb+ dosing.interval = 12, do.sampling=FALSE) 25 | 26 | evntTb> # Use the copy() method to create a copy (clone) of an existing 27 | evntTb> # event table (simple assignments just create a new reference to 28 | evntTb> # the same event table object (closure)). 29 | evntTb> 30 | evntTb> bid.ext <- bid$copy() # three-day extension for a 2nd cohort 31 | 32 | evntTb> bid.ext$add.dosing(dose = 5000, nbr.doses = 2*3, 33 | evntTb+ start.time = 120, dosing.interval = 12, do.sampling = FALSE) 34 | -------------------------------------------------------------------------------- /RxODE/src/dparser/COPYRIGHT: -------------------------------------------------------------------------------- 1 | Copyright (c) 1994-2013 John Bradley Plevyak, All Rights Reserved 2 | 3 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 4 | 5 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 6 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 7 | 3. The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission. 8 | 9 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 10 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g28.test.g: -------------------------------------------------------------------------------- 1 | { 2 | #include 3 | 4 | typedef struct My_Sym { 5 | int value; 6 | } My_Sym; 7 | #define D_UserSym My_Sym 8 | typedef struct My_ParseNode { 9 | int value; 10 | struct D_Scope *scope; 11 | } My_ParseNode; 12 | #define D_ParseNode_User My_ParseNode 13 | } 14 | 15 | translation_unit: statement*; 16 | 17 | statement 18 | : expression ';' 19 | { printf("%d\n", $0.value); } 20 | | '{' statement* '}' 21 | [ ${scope} = enter_D_Scope(${scope}, $n0.scope); ] 22 | { ${scope} = commit_D_Scope(${scope}); } 23 | ; 24 | 25 | expression 26 | : identifier ':' expression 27 | [ 28 | D_Sym *s; 29 | ${scope} = new_D_Scope(${scope}); 30 | s = NEW_D_SYM(${scope}, $n0.start_loc.s, $n0.end); 31 | s->user.value = $2.value; 32 | $$.value = s->user.value; 33 | ] 34 | | identifier '=' expression 35 | [ D_Sym *s = find_D_Sym(${scope}, $n0.start_loc.s, $n0.end); 36 | s = UPDATE_D_SYM(s, &${scope}); 37 | s->user.value = $2.value; 38 | $$.value = s->user.value; 39 | ] 40 | | integer 41 | [ $$.value = atoi($n0.start_loc.s); ] 42 | | identifier 43 | [ D_Sym *s = find_D_Sym(${scope}, $n0.start_loc.s, $n0.end); 44 | if (s) 45 | $$.value = s->user.value; 46 | ] 47 | | expression '+' expression 48 | [ $$.value = $0.value + $1.value; ] 49 | ; 50 | 51 | integer: "-?([0-9]|0(x|X))[0-9]*(u|U|b|B|w|W|L|l)*" $term -1; 52 | identifier: "[a-zA-Z_][a-zA-Z_0-9]*"; 53 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g33.test.g: -------------------------------------------------------------------------------- 1 | { 2 | #include 3 | #include 4 | #include 5 | #include "dparse_tables.h" 6 | extern D_Symbol d_symbols_gram[]; 7 | char *xdup(char *s, char *e) { 8 | char *ss = malloc( e - s + 2 ); 9 | memcpy(ss, s, e-s); 10 | ss[e-s] = 0; 11 | return ss; 12 | } 13 | } 14 | 15 | ${pass sym for_all postorder} 16 | ${pass gen for_all postorder} 17 | 18 | translation_unit: statement*; 19 | 20 | _: 21 | sym: { 22 | printf("default sym(%s : \"%s\")\n", 23 | d_symbols_gram[$n.symbol].name, 24 | xdup($n.start_loc.s, $n.end) 25 | ); 26 | } 27 | gen: { 28 | printf("default gen(%s : \"%s\")\n", 29 | d_symbols_gram[$n.symbol].name, 30 | xdup($n.start_loc.s, $n.end) 31 | ); 32 | } 33 | ; 34 | 35 | statement 36 | : expression ';' 37 | { 38 | printf("final expression\n"); 39 | d_pass(${parser}, &$n, ${pass sym}); 40 | d_pass(${parser}, &$n, ${pass gen}); 41 | } 42 | ; 43 | 44 | expression 45 | : identifier '=' expression $right 1 46 | sym: { printf("sym expression: =\n"); } 47 | | integer 48 | gen: { printf("gen expression: integer\n"); } 49 | sym: { printf("sym expression: integer\n"); } 50 | | expression '+' expression $right 2 51 | sym: { printf("sym +\n"); } 52 | ; 53 | 54 | integer: "-?([0-9]|0(x|X))[0-9]*(u|U|b|B|w|W|L|l)*" $term -1 55 | sym: { printf("sym integer\n"); } 56 | ; 57 | identifier: "[a-zA-Z_][a-zA-Z_0-9]*"; 58 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g32.test.g: -------------------------------------------------------------------------------- 1 | { 2 | #include 3 | #include 4 | #include 5 | char *xdup(char *s, char *e) { 6 | char *ss = malloc( e - s + 2 ); 7 | memcpy(ss, s, e-s); 8 | ss[e-s] = 0; 9 | return ss; 10 | } 11 | } 12 | 13 | translation_unit: statement*; 14 | 15 | statement 16 | : expression ';' 17 | { printf("(%s)expression ;(%s)", 18 | xdup(d_ws_before(${parser}, &$n), $n.start_loc.s), 19 | xdup($n.end, d_ws_after(${parser}, &$n))); 20 | } 21 | ; 22 | 23 | expression 24 | : identifier '=' expression $right 1 25 | { printf("(%s)= in expression(%s)", 26 | xdup(d_ws_before(${parser}, &$n1), $n1.start_loc.s), 27 | xdup($n1.end, d_ws_after(${parser}, &$n1))); 28 | } 29 | | integer 30 | { printf("(%s)expression: integer(%s)", 31 | xdup(d_ws_before(${parser}, &$n0), $n0.start_loc.s), 32 | xdup($n0.end, d_ws_after(${parser}, &$n0))); 33 | } 34 | | expression '+' expression $right 2 35 | { printf("(%s)+ in expression(%s)", 36 | xdup(d_ws_before(${parser}, &$n1), $n1.start_loc.s), 37 | xdup($n1.end, d_ws_after(${parser}, &$n1))); 38 | } 39 | ; 40 | 41 | integer: "-?([0-9]|0(x|X))[0-9]*(u|U|b|B|w|W|L|l)*" $term -1; 42 | identifier: "[a-zA-Z_][a-zA-Z_0-9]*" 43 | { printf("(%s)identifier(%s)", 44 | xdup(d_ws_before(${parser}, &$n0), $n0.start_loc.s), 45 | xdup($n0.end, d_ws_after(${parser}, &$n0))); 46 | } 47 | ; 48 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/g29.test.g: -------------------------------------------------------------------------------- 1 | { 2 | #include 3 | 4 | typedef struct My_Sym { 5 | int value; 6 | } My_Sym; 7 | #define D_UserSym My_Sym 8 | typedef struct My_ParseNode { 9 | int value; 10 | struct D_Scope *scope; 11 | } My_ParseNode; 12 | #define D_ParseNode_User My_ParseNode 13 | } 14 | 15 | translation_unit: statement*; 16 | 17 | statement 18 | : expression ';' 19 | { printf("%d\n", $0.value); } 20 | | '{' new_scope statement* '}' 21 | [ ${scope} = enter_D_Scope(${scope}, $n0.scope); ] 22 | ; 23 | 24 | new_scope: [ ${scope} = new_D_Scope(${scope}); ]; 25 | 26 | expression 27 | : identifier ':' expression 28 | [ 29 | D_Sym *s; 30 | if (find_D_Sym_in_Scope(${scope}, ${scope}, $n0.start_loc.s, $n0.end)) 31 | printf("duplicate identifier line %d\n", $n0.start_loc.line); 32 | s = NEW_D_SYM(${scope}, $n0.start_loc.s, $n0.end); 33 | s->user.value = $2.value; 34 | $$.value = s->user.value; 35 | ] 36 | | identifier '=' expression 37 | [ D_Sym *s = find_D_Sym(${scope}, $n0.start_loc.s, $n0.end); 38 | s = UPDATE_D_SYM(s, &${scope}); 39 | s->user.value = $2.value; 40 | $$.value = s->user.value; 41 | ] 42 | | integer 43 | [ $$.value = atoi($n0.start_loc.s); ] 44 | | identifier 45 | [ D_Sym *s = find_D_Sym(${scope}, $n0.start_loc.s, $n0.end); 46 | if (s) 47 | $$.value = s->user.value; 48 | ] 49 | | expression '+' expression 50 | [ $$.value = $0.value + $1.value; ] 51 | ; 52 | 53 | integer: "-?([0-9]|0(x|X))[0-9]*(u|U|b|B|w|W|L|l)*" $term -1; 54 | identifier: "[a-zA-Z_][a-zA-Z_0-9]*"; 55 | -------------------------------------------------------------------------------- /RxODE/inst/tran.g: -------------------------------------------------------------------------------- 1 | //loop 2 | 3 | statement_list : (statement)+ ; 4 | 5 | statement 6 | : assignment ';' 7 | | derivative ';' 8 | | compound_statement 9 | | selection_statement 10 | | ';' ; 11 | 12 | 13 | compound_statement : '{' statement_list? '}' ; 14 | 15 | selection_statement 16 | : 'if' '(' logical_or_expression ')' statement ('else' statement)?; 17 | 18 | derivative : 'd/dt' '(' identifier ')' '=' additive_expression; 19 | assignment : identifier '=' additive_expression; 20 | 21 | 22 | 23 | logical_or_expression : logical_and_expression 24 | ('||' logical_and_expression)* ; 25 | 26 | logical_and_expression : equality_expression 27 | ('&&' equality_expression)* ; 28 | 29 | equality_expression : relational_expression 30 | (('!=' | '==') relational_expression)* ; 31 | 32 | relational_expression : additive_expression 33 | (('<' | '>' | '<=' | '>=') additive_expression)* ; 34 | 35 | additive_expression : multiplicative_expression 36 | (('+' | '-') multiplicative_expression)* ; 37 | 38 | multiplicative_expression : unary_expression 39 | (('*' | '/') unary_expression)* ; 40 | 41 | unary_expression : ('+' | '-')? (primary_expression | power_expression); 42 | 43 | power_expression : primary_expression '^' primary_expression ; 44 | 45 | primary_expression 46 | : identifier 47 | | constant 48 | | function 49 | | '(' additive_expression ')' 50 | ; 51 | 52 | function : identifier '(' additive_expression (',' additive_expression)* ')' ; 53 | 54 | constant : decimalint | float1 | float2; 55 | 56 | 57 | decimalint: "0|([1-9][0-9]*)" $term -1; 58 | float1: "([0-9]+.[0-9]*|[0-9]*.[0-9]+)([eE][\-\+]?[0-9]+)?" $term -2; 59 | float2: "[0-9]+[eE][\-\+]?[0-9]+" $term -3; 60 | identifier: "[a-zA-Z_][a-zA-Z0-9_]*" $term -4; 61 | whitespace: ( "[ \t\r\n]+" | singleLineComment )*; 62 | singleLineComment: '#' "[^\n]*" '\n'; 63 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/bnf.g: -------------------------------------------------------------------------------- 1 | rulelist : ( rule | _0_rulelist ) + ; 2 | whitespace : ; 3 | comment : ';' ( WSP | VCHAR ) * CRLF ; 4 | hex_val : 'x' HEXDIG + ( _0_hex_val | _1_hex_val ) ? ; 5 | _0_hex_val : ( '.' HEXDIG + ) + ; 6 | _1_hex_val : '-' HEXDIG + ; 7 | alternation : concatenation ( c_wsp * '/' c_wsp * concatenation ) * ; 8 | concatenation : repetition ( c_wsp + repetition ) * ; 9 | c_nl : comment | CRLF ; 10 | CHAR : "[\x01-\x7f]" ; 11 | WSP : SP | HTAB ; 12 | repeat : _0_repeat | _1_repeat ; 13 | _0_repeat : DIGIT + ; 14 | _1_repeat : DIGIT * '*' DIGIT * ; 15 | char_val : DQUOTE ( "[ -!]" | "[#-~]" ) * DQUOTE ; 16 | prose_val : '<' ( "[ -=]" | "[?-~]" ) * '>' ; 17 | LF : "\x0a" ; 18 | group : '(' c_wsp * alternation c_wsp * ')' ; 19 | bin_val : 'b' BIT + ( _0_bin_val | _1_bin_val ) ? ; 20 | _0_bin_val : ( '.' BIT + ) + ; 21 | _1_bin_val : '-' BIT + ; 22 | HTAB : "\x09" ; 23 | dec_val : 'd' DIGIT + ( _0_dec_val | _1_dec_val ) ? ; 24 | _0_dec_val : ( '.' DIGIT + ) + ; 25 | _1_dec_val : '-' DIGIT + ; 26 | _0_rulelist : c_wsp * c_nl ; 27 | rulename : ALPHA ( ALPHA | DIGIT | '-' ) * ; 28 | BIT : '0' | '1' ; 29 | elements : alternation c_wsp * ; 30 | option : '[' c_wsp * alternation c_wsp * ']' ; 31 | LWSP : ( WSP | _0_LWSP ) * ; 32 | _0_LWSP : CRLF WSP ; 33 | OCTET : "[\x01-\xfe]" ; 34 | CRLF : CR LF ; 35 | HEXDIG : DIGIT | 'A' | 'B' | 'C' | 'D' | 'E' | 'F' ; 36 | CR : "\x0d" ; 37 | defined_as : c_wsp * ( '=' | '=/' ) c_wsp * ; 38 | repetition : repeat ? element ; 39 | DIGIT : "[0-9]" ; 40 | SP : " " ; 41 | num_val : '%' ( bin_val | dec_val | hex_val ) ; 42 | rule : rulename defined_as elements c_nl ; 43 | element : rulename | group | option | char_val | num_val | prose_val ; 44 | c_wsp : WSP | _0_c_wsp ; 45 | _0_c_wsp : c_nl WSP ; 46 | VCHAR : "[!-~]" ; 47 | ALPHA : "[A-Z]" | "[a-z]" ; 48 | DQUOTE : "\"" ; 49 | 50 | -------------------------------------------------------------------------------- /RxODE/demo/demo1.R: -------------------------------------------------------------------------------- 1 | ode <- " 2 | C2 = centr/V2; 3 | C3 = peri/V3; 4 | d/dt(depot) =-KA*depot; 5 | d/dt(centr) = KA*depot - CL*C2 - Q*C2 + Q*C3; 6 | d/dt(peri) = Q*C2 - Q*C3; 7 | d/dt(eff) = Kin - Kout*(1-C2/(EC50+C2))*eff; 8 | " 9 | 10 | m1 <- RxODE(model = ode, modName = "m1") 11 | 12 | # create dosing and observation (sampling) events 13 | # QD (once daily) dosing, 5 days 14 | 15 | qd <- eventTable(amount.units="umg", time.units = "hours") 16 | qd$add.dosing(dose=10000, nbr.doses=5, dosing.interval = 24) 17 | 18 | # hourly sampling during 1st day, every 4 hours afterwards 19 | qd$add.sampling(0:24) # hourly 20 | qd$add.sampling(seq(from=28, to=96, by=4) ) # every 4 hours 21 | 22 | # BID dosing, 5 days 23 | 24 | bid <- eventTable(amount.units="ug", time.units="days") # only dosing 25 | bid$add.dosing(dose = 10000, 26 | nbr.doses = 2*5, 27 | dosing.interval = 12) 28 | 29 | bid$add.sampling(0:24) 30 | bid$add.sampling(96+0:24) 31 | 32 | # init values 33 | theta <- 34 | c(KA=2.94E-01, CL=1.86E+01, V2=4.02E+01, Q=1.05E+01, V3=2.97E+02, 35 | Kin=1, Kout=1, EC50=200) 36 | 37 | qd.cp <- m1$solve(theta, qd, inits = c(0,0,0,1)) 38 | bid.cp <- m1$solve(theta, bid, inits = c(0,0,0,1)) 39 | 40 | cp.plot <- 41 | function(cp, xlab = "Time (days)", ...) 42 | { 43 | xtime <- cp[,"time"] 44 | matplot(xtime, cp[,c("depot", "centr", "peri")], type = "l", ..., 45 | xlab = xlab, ylab = "Drug amount (ug)") 46 | 47 | legend("topright", 48 | legend = c("Depot", "Central", "Peripheral"), 49 | title = "Compartment", 50 | col=1:3, lty = 1:3, bty = "n") 51 | 52 | plot(xtime, cp[,"eff"], type = "l", ..., 53 | xlab = xlab, ylab = "Effect compartment") 54 | } 55 | 56 | cp.plot(qd.cp, main = "QD dosing, 5 days") 57 | 58 | cp.plot(bid.cp, main = "BID dosing, 5 days") 59 | -------------------------------------------------------------------------------- /RxODE/src/dparser/python/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | DParser for Python 4 | 5 | 6 |

DParser for Python

7 | 8 | DParser is a simple but powerful tool for parsing, written by J. Plevyak. DParser for Python gives Python 9 | programmers a seamless interface to DParser. 10 |

11 | 12 | The features that set this Python parser apart from other Python parsers are: 13 |

    14 |
  • it can deal with any grammar (GLR) 15 |
  • it is fast (based in C) 16 |
  • it does not require a compiler to operate. 17 |
18 | DParser for Python also has many easy-to-use features found in other Python parsers: 19 |
    20 |
  • it does not require explicit definitions of tokens 21 |
  • it does not require a separate, non-Python grammar file 22 |
  • it uses function documentation strings to specify grammar rules 23 |
  • it does not output parser code that the user must compile or run. 24 |
25 | 26 | A simple example-- a grammar to add numbers: 27 |
28 | from dparser import Parser
29 | 
30 | def d_add(t):              # actions must start with 'd_'
31 |     "exp : exp '+' exp"    # literals are put directly into grammar rules
32 |     return t[0] + t[2]
33 |     
34 | def d_number(t):
35 |     'exp : "[0-9]+" '  # regular expressions are enclosed in double quotes
36 |     return int(t[0])
37 |     
38 | print Parser().parse("2+3+4")
39 | 
40 | ==> 9
41 | 
42 |

43 | Also see the slightly longer requisite calculator example. 44 |

45 | 46 |

Documentation

47 | DParser for Python Documentation 48 |

49 | DParser for Python requires at least Python 2.2 50 |

51 |

Contact

52 | 53 | Brian Sabbey (sabbey_at_u_dot_washington_dot_edu.) 54 | 55 |

56 | 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /RxODE/inst/doc/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | R: Vignettes and other documentation 4 | 5 | 6 | 7 |

Vignettes and other documentation 8 | 9 |

10 |
11 |
12 | [Top] 13 |
14 |

Vignettes from package 'RxODE'

15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 |
RxODE::RxODE-introIntroduction to RxODEHTMLsourceR code
RxODE::RxODE-syntaxRxODE Modeling SyntaxHTMLsourceR code
33 | 34 | -------------------------------------------------------------------------------- /RxODE/src/dparser/dparse_tree.h: -------------------------------------------------------------------------------- 1 | /* 2 | $URL: http://manta.univ.gda.pl/svn/wb/parsing/dparser/D/dparse_tree.h $ 3 | $Revision: 1.1 $ 4 | 5 | This interface provides a `print_parsetree' function that can 6 | be used to print a parse tree built by Dparser. The implementation 7 | of `print_parsetree' calls, on every node of the parse tree, 8 | a function `fn` that should print the node. Two such functions are 9 | provided: `print_node_default' which uses indentation to show the parse 10 | tree and `print_node_parenthesised' which uses parens. 11 | 12 | Three additional files provide an example: 13 | -- `driver_parsetree.c' contains a program illustrating the use of `print_parsetree', 14 | -- `4calc.g' contains a grammar for a simple calculator, 15 | -- `4calc.in' an expression to parse. 16 | The following commands can be used to compile and try out the example: 17 | make_dparser 4calc.g 18 | cc -o 4calc driver_parsetree.c 4calc.g.d_parser.c -I/usr/local/include -L/usr/local/lib -ldparse 19 | ./4calc 4calc.in 20 | */ 21 | 22 | #ifndef _parsetree_H_ 23 | #define _parsetree_H_ 24 | 25 | #include "dparse.h" 26 | 27 | 28 | /* `print_node_fn_t' type defines a class of callback functions that 29 | the `print_parsetree' function uses to print a node */ 30 | 31 | typedef void (print_node_fn_t)(int depth, char *token_name, char *token_value, void *client_data); 32 | 33 | /* if `fn' is NULL, then the function `print_node_default' is used */ 34 | 35 | void 36 | print_parsetree(D_ParserTables pt, D_ParseNode *pn, print_node_fn_t fn, void *client_data); 37 | 38 | 39 | /* `print_node_default' truncates `token_value' to 44 characters 40 | and replaces newlines with spaces */ 41 | 42 | void 43 | print_node_default(int depth, char *token_name, char *token_value, void *client_data); 44 | 45 | void 46 | print_node_parenthesised(int depth, char *token_name, char *token_value, void *client_data); 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /RxODE/inst/TODO.txt: -------------------------------------------------------------------------------- 1 | * Develop more comprehensive testing scripts (high priority) 2 | 3 | * Allow tran.c to be called from R (ie., replace main by tran()) 4 | 5 | * Under Windows, system() uses COMSPEC, which causes problems with 6 | pathnames that have spaces. 7 | 8 | * Modify call_dvode.c and tran.c to use function pointers to avoid 9 | the current hack of editing/replacing function names with model- 10 | specific names (see rx.initCmpMgr in RxODE.R) 11 | 12 | * Move InfusionRate[] from global to local (per model). Remove 13 | limitation to 99 entries. 14 | 15 | * We no longer need the variable.txt file, as that info is part of 16 | the compilation manager. 17 | 18 | * Replace .C for .Call 19 | 20 | * eventTable(), should we expand the encoded/packed "evid" column 21 | in the event table? (e.g., provide columns flags for infusion vs 22 | bolus, etc.) 23 | 24 | * How should we manage model files life cycle? Instead of simple 25 | directories we could create zip/tar archives per model (maybe). 26 | Or should we just leave the *.so and remove everything else? 27 | 28 | * Define methods for EventTable objects (plot, points/lines, summary, 29 | any other?) 30 | 31 | * Define methods for RxODE models (summary, fitted, predict, 32 | update, simulate, residuals, plot, points/lines, llikliood, 33 | anova, ...) But note that RxODE is closer to approx() than to 34 | lm(). 35 | 36 | * Connect to gls, nlme, lme3, ... 37 | 38 | * Do we need the following? can we query R CMD config for this info? 39 | .gflibs <- if (is.win) "-lRblas -lgfortran" else "-lgfortran" 40 | 41 | * RxODE() includes a hack that fishes arguments "S1", "S2, ... a-la-nonmem 42 | for scaling the corresponding compartment. Provide a more 43 | explicit mechanism, say, scale = c(centr = 7.5) similar in spirit to 44 | parms= and inits= arguments. 45 | 46 | * Add C code to register the C function, as in R-ext Section 5.4. 47 | 48 | * Add "**" as a synonim for the exponentiation "^" operator (low priority). 49 | -------------------------------------------------------------------------------- /RxODE/src/dparser/python/pydparser.h: -------------------------------------------------------------------------------- 1 | typedef struct user_pyobjects { 2 | PyObject *t; 3 | PyObject *s; 4 | int inced_global_state; 5 | } user_pyobjects; 6 | 7 | #ifndef SWIG 8 | #define D_ParseNode_User user_pyobjects 9 | #define D_ParseNode_Globals PyObject 10 | #include "../d.h" 11 | #endif 12 | 13 | void my_d_loc_t_s_set(d_loc_t *dlt, D_Parser *dp, int val); 14 | int my_d_loc_t_s_get(d_loc_t *dlt, D_Parser *dp); 15 | void my_D_ParseNode_end_set(D_ParseNode *dpn, D_Parser *dp, int val); 16 | void my_D_ParseNode_end_skip_set(D_ParseNode *dpn, D_Parser *dp, int val); 17 | int my_D_ParseNode_end_get(D_ParseNode *dpn, D_Parser *dp); 18 | int my_D_ParseNode_end_skip_get(D_ParseNode *dpn, D_Parser *dp); 19 | PyObject *my_D_ParseNode_symbol_get(D_ParseNode *dpn, D_Parser *dp); 20 | 21 | void remove_parse_tree_viewer(D_Parser* dp); 22 | void add_parse_tree_viewer(D_Parser* dp); 23 | void del_parser(D_Parser *dp); 24 | D_Parser *make_parser(long int idpt, 25 | PyObject *self, 26 | PyObject *reject, 27 | PyObject *make_token, 28 | PyObject *loc_type, 29 | PyObject *node_info_type, 30 | PyObject *actions, 31 | PyObject *initial_white_space_fn, 32 | PyObject *syntax_error_fn, 33 | PyObject *ambiguity_fn, 34 | int dont_fixup_internal_productions, 35 | int fixup_EBNF_productions, 36 | int dont_merge_epsilon_trees, 37 | int commit_actions_interval, 38 | int error_recovery, 39 | int print_debug_info, 40 | int partial_parses, 41 | int dont_compare_stacks, 42 | int dont_use_greediness_for_disambiguation, 43 | int dont_use_height_for_disambiguation, 44 | char *start_state, 45 | int takes_strings, 46 | int takes_globals); 47 | PyObject *run_parser(D_Parser *dp, PyObject* string, int buf_idx); 48 | int make_tables(char *grammar_string, char *grammar_pathname); 49 | long int load_parser_tables(char *tables_name); 50 | void unload_parser_tables(long int binary_table); 51 | 52 | -------------------------------------------------------------------------------- /RxODE/src/dparser/verilog/main.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * main.c 4 | * 5 | * Main for Verilog parser. 6 | * 7 | * $Revision: 1.2 $ 8 | */ 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | #include "vparse.h" 15 | #include "dparse.h" 16 | 17 | extern D_ParserTables parser_tables_gram; 18 | extern int d_verbose_level; 19 | extern struct D_ParseNode *my_ambiguity_fn(struct D_Parser *pp, int n, 20 | struct D_ParseNode **v ); 21 | 22 | static char *usage = "%s [-vpI] file ...\n"; 23 | 24 | int 25 | main(int argc, char *argv[]) { 26 | 27 | char *filebuf; 28 | int size; 29 | int ch, arg; 30 | char incdirsbuf[2048]; 31 | 32 | int dump_pp = 0; 33 | 34 | D_Parser *p = new_D_Parser(&parser_tables_gram, 35 | sizeof(D_ParseNode_User)); 36 | p->ambiguity_fn = my_ambiguity_fn; 37 | 38 | while ((ch = getopt(argc, argv, "vphI:")) != -1) 39 | switch (ch) { 40 | case 'v': d_verbose_level++; break; 41 | case 'p': dump_pp++; break; 42 | case 'I': 43 | if ( ! v_incdirs ) { 44 | v_incdirs = incdirsbuf; 45 | v_incdirs[0] = '\0'; 46 | } 47 | if ( strlen( v_incdirs ) + strlen( optarg ) + 2 > 48 | sizeof(incdirsbuf) ) 49 | exit(1); 50 | strcat( v_incdirs, optarg ); 51 | strcat( v_incdirs, ":" ); 52 | break; 53 | case '?': 54 | case 'h': 55 | default: 56 | fprintf( stderr, usage, argv[0] ); 57 | exit(1); 58 | } 59 | 60 | for (arg = optind; arg < argc; arg++) { 61 | 62 | if ( v_getfile( argv[ arg ], &filebuf, &size ) < 0 ) { 63 | fprintf( stderr, "Trouble getting '%s', skipping.\n", 64 | argv[ arg ] ); 65 | continue; 66 | } 67 | 68 | p->loc.pathname = argv[ arg ]; 69 | p->loc.line = 1; 70 | p->loc.col = 0; 71 | 72 | if ( dump_pp ) { 73 | int i; 74 | for (i=0; isyntax_errors ) 80 | fprintf( stderr, "%s succeeded\n", argv[ arg ] ); 81 | else 82 | fprintf( stderr, "%s failed\n", argv[ arg ] ); 83 | 84 | free( filebuf ); 85 | 86 | arg++; 87 | } 88 | 89 | return 0; 90 | } 91 | -------------------------------------------------------------------------------- /RxODE/src/dparser/dparse_tree.c: -------------------------------------------------------------------------------- 1 | /* 2 | $URL: http://manta.univ.gda.pl/svn/wb/parsing/dparser/D/dparse_tree.c $ 3 | $Revision: 1.2 $ 4 | */ 5 | 6 | #include 7 | #include 8 | 9 | #include "dparse_tree.h" 10 | 11 | char *dup_str(char *s, char *e); /* defined in util.h */ 12 | 13 | /* tunables */ 14 | 15 | #define MAX_LINE_LENGTH 44 /* must be at least 4 */ 16 | #define INDENT_SPACES 4 17 | 18 | static void 19 | xprint_parsetree(D_ParserTables pt, D_ParseNode *pn, int depth, print_node_fn_t fn, void *client_data); 20 | 21 | static void 22 | xprint_parsetree(D_ParserTables pt, D_ParseNode *pn, int depth, print_node_fn_t fn, void *client_data) { 23 | int nch = d_get_number_of_children(pn), i; 24 | char *name = (char*)pt.symbols[pn->symbol].name; 25 | // int len = pn->end_skip - pn->start_loc.s; 26 | // char *value = malloc(len+2); 27 | // memcpy(value, pn->start_loc.s, len); 28 | // value[len] = 0; 29 | char *value = dup_str(pn->start_loc.s, pn->end); 30 | fn(depth, name, value, client_data); 31 | free(value); 32 | 33 | depth++; 34 | if (nch != 0) { 35 | for (i = 0; i < nch; i++) { 36 | D_ParseNode *xpn = d_get_child(pn,i); 37 | xprint_parsetree(pt, xpn, depth, fn, client_data); 38 | } 39 | } 40 | } 41 | 42 | void 43 | print_parsetree(D_ParserTables pt, D_ParseNode *pn, print_node_fn_t fn, void *client_data) { 44 | xprint_parsetree(pt, pn, 0, (NULL==fn)?print_node_default:fn, client_data); 45 | } 46 | 47 | void 48 | print_node_parenthesised(int depth, char *name, char *value, void *client_data) { 49 | printf("( %s )", name); 50 | } 51 | 52 | static char * 53 | change_newline2space(char *s) { 54 | char *ss = s; 55 | while (*ss++) 56 | if (*ss == '\n') 57 | *ss = ' '; 58 | if (strlen(s)>MAX_LINE_LENGTH) { 59 | *(s+MAX_LINE_LENGTH-3) = '.'; 60 | *(s+MAX_LINE_LENGTH-2) = '.'; 61 | *(s+MAX_LINE_LENGTH-1) = '.'; 62 | *(s+MAX_LINE_LENGTH) = '\0'; 63 | } 64 | return s; 65 | } 66 | 67 | void 68 | print_node_default(int depth, char *name, char *value, void *client_data) { 69 | printf("%*s", depth*INDENT_SPACES, ""); 70 | printf("%s %s.\n", name, change_newline2space(value)); 71 | } 72 | -------------------------------------------------------------------------------- /RxODE/tests/Examples/RxODE.Rout.save: -------------------------------------------------------------------------------- 1 | 2 | RxODE> # Step 1 - Create a model specification 3 | RxODE> ode <- " 4 | RxODE+ # A 4-compartment model, 3 PK and a PD (effect) compartment 5 | RxODE+ # (notice state variable names 'depot', 'centr', 'peri', 'eff') 6 | RxODE+ 7 | RxODE+ C2 = centr/V2; 8 | RxODE+ C3 = peri/V3; 9 | RxODE+ d/dt(depot) =-KA*depot; 10 | RxODE+ d/dt(centr) = KA*depot - CL*C2 - Q*C2 + Q*C3; 11 | RxODE+ d/dt(peri) = Q*C2 - Q*C3; 12 | RxODE+ d/dt(eff) = Kin - Kout*(1-C2/(EC50+C2))*eff; 13 | RxODE+ " 14 | 15 | RxODE> m1 <- RxODE(model = ode, modName = "m1") 16 | 17 | RxODE> print(m1) 18 | RxODE model named "m1" (ready to run) 19 | 20 | RxODE> # Step 2 - Create the model input as an EventTable, 21 | RxODE> # including dosing and observation (sampling) events 22 | RxODE> 23 | RxODE> # QD (once daily) dosing for 5 days. 24 | RxODE> 25 | RxODE> qd <- eventTable(amount.units="ug", time.units = "hours") 26 | 27 | RxODE> qd$add.dosing(dose=10000, nbr.doses=5, dosing.interval = 24) 28 | 29 | RxODE> # Sample the system hourly during the first day, every 8 hours 30 | RxODE> # then after 31 | RxODE> 32 | RxODE> qd$add.sampling(0:24) 33 | 34 | RxODE> qd$add.sampling(seq(from = 24+8, to = 5*24, by = 8)) 35 | 36 | RxODE> # Step 3 - set starting parameter estimates and initial 37 | RxODE> # values of the state 38 | RxODE> 39 | RxODE> theta <- 40 | RxODE+ c(KA=.291, CL=18.6, 41 | RxODE+ V2=40.2, Q=10.5, V3=297.0, 42 | RxODE+ Kin=1.0, Kout=1.0, EC50=200.0) 43 | 44 | RxODE> # init state variable 45 | RxODE> inits <- c(0, 0, 0, 1) 46 | 47 | RxODE> # Step 4 - Fit the model to the data 48 | RxODE> 49 | RxODE> qd.cp <- m1$solve(theta, events = qd, inits) 50 | 51 | RxODE> head(qd.cp) 52 | time depot centr peri eff C2 C3 53 | [1,] 0 10000.000 0.000 0.0000 1.000000 0.00000 0.0000000 54 | [2,] 1 7475.157 1768.532 270.6751 1.083968 43.99334 0.9113641 55 | [3,] 2 5587.797 2191.248 787.3677 1.179529 54.50866 2.6510696 56 | [4,] 3 4176.966 2076.396 1314.0348 1.227523 51.65163 4.4243597 57 | [5,] 4 3122.347 1783.880 1765.1486 1.233503 44.37513 5.9432612 58 | [6,] 5 2334.004 1465.845 2120.2772 1.214084 36.46382 7.1389804 59 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/python.test.g.1: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2003 Brian Sabbey 2 | # Hacks Copyright (c) 2003 John Plevyak 3 | 4 | import pydparser, sys, types, dl, os 5 | 6 | class Parser: 7 | def __init__(self, modules=None): 8 | self.file_prefix = "dparser_auto" 9 | 10 | self.parser = None 11 | self.dl_parser = None 12 | self.actions = [] 13 | 14 | if not modules: 15 | try: 16 | raise RuntimeError 17 | except RuntimeError: 18 | e,b,t = sys.exc_info() 19 | 20 | dicts = [t.tb_frame.f_back.f_globals] 21 | else: 22 | if type(modules) == list: 23 | dicts = [module.__dict__ for module in modules] 24 | else: 25 | dicts = modules 26 | 27 | functions = [val for dict in dicts for name, val in dict.items() 28 | if (isinstance(val, types.FunctionType)) and name[0:2] == 'd_'] 29 | functions.sort(lambda x, y: cmp(x.func_code.co_filename, y.func_code.co_filename) 30 | or cmp(x.func_code.co_firstlineno, y.func_code.co_firstlineno)) 31 | 32 | self.filename = self.file_prefix + ".g" 33 | g_file = open(self.filename, "w") 34 | for f in functions: 35 | g_file.write(f.__doc__) 36 | g_file.write(";\n${action}\n"); 37 | self.actions.append(f) 38 | g_file.close() 39 | 40 | def action(self, i, speculative, args): 41 | if speculative: 42 | return 43 | if i >= 0 and i < len(self.actions): 44 | f = self.actions[i] 45 | ac = f.func_code.co_argcount 46 | if ac == 1: 47 | return f(args) 48 | raise "where's the action?" + str(i) 49 | return None 50 | 51 | def parse(self, input): 52 | parser = self.parser 53 | filename = self.filename 54 | if not parser: 55 | if os.system("make_dparser " + filename): 56 | raise "make_dparser error" 57 | if os.system("cc -I/usr/local/include -shared -fPIC -o " + filename + ".so " 58 | + filename + ".d_parser.c") : 59 | raise "cc -static XX.d_parser.o error" 60 | self.dl_parser = dl.open("./" + filename + ".so") 61 | self.parser = self.dl_parser.sym("parser_tables_gram"); 62 | return pydparser.run_parser(self.parser, self.action, input) 63 | -------------------------------------------------------------------------------- /RxODE/src/dparser/dsymtab.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2002-2004 John Plevyak, All Rights Reserved 3 | */ 4 | #ifndef _dsymtab_H_ 5 | #define _dsymtab_H_ 6 | 7 | #ifndef D_UserSym 8 | #define D_UserSym unsigned int 9 | #endif 10 | 11 | struct D_SymHash; 12 | struct D_Scope; 13 | 14 | typedef struct D_Sym { 15 | char *name; 16 | int len; 17 | unsigned int hash; 18 | struct D_Scope *scope; 19 | struct D_Sym *update_of; 20 | struct D_Sym *next; 21 | D_UserSym user; 22 | } D_Sym; 23 | 24 | #define D_SCOPE_INHERIT 0 25 | #define D_SCOPE_RECURSIVE 1 26 | #define D_SCOPE_PARALLEL 2 27 | #define D_SCOPE_SEQUENTIAL 3 28 | 29 | typedef struct D_Scope { 30 | unsigned int kind:2; 31 | unsigned int owned_by_user:1; /* don't automatically delete */ 32 | unsigned int depth; 33 | D_Sym *ll; 34 | struct D_SymHash *hash; 35 | D_Sym *updates; 36 | struct D_Scope *search; /* scope to start search */ 37 | struct D_Scope *dynamic; /* dynamic scope (e.g. methods) */ 38 | struct D_Scope *up; /* enclosing scope */ 39 | struct D_Scope *up_updates; /* prior scope in speculative parse */ 40 | struct D_Scope *down; /* enclosed scopes (for FREE) */ 41 | struct D_Scope *down_next; /* next enclosed scope */ 42 | } D_Scope; 43 | 44 | D_Scope *new_D_Scope(D_Scope *parent); 45 | D_Scope *enter_D_Scope(D_Scope *current, D_Scope *scope); 46 | D_Scope *commit_D_Scope(D_Scope *scope); 47 | D_Scope *equiv_D_Scope(D_Scope *scope); 48 | D_Scope *global_D_Scope(D_Scope *scope); 49 | D_Scope *scope_D_Scope(D_Scope *current, D_Scope *scope); 50 | void free_D_Scope(D_Scope *st, int force); 51 | D_Sym *new_D_Sym(D_Scope *st, char *name, char *end, int sizeof_D_Sym); 52 | #define NEW_D_SYM(_st, _name, _end) new_D_Sym(_st, _name, _end, sizeof(D_Sym)) 53 | void free_D_Sym(D_Sym *sym); 54 | D_Sym *find_D_Sym(D_Scope *st, char *name, char *end); 55 | D_Sym *find_global_D_Sym(D_Scope *st, char *name, char *end); 56 | /* use for first update in a production to update scope */ 57 | D_Sym *update_D_Sym(D_Sym *sym, D_Scope **st, int sizeof_D_Sym); 58 | #define UPDATE_D_SYM(_sym, _st) update_D_Sym(_sym, _st, sizeof(D_Sym)) 59 | /* use for first subsequent updates in a production */ 60 | D_Sym *update_additional_D_Sym(D_Scope *st, D_Sym *sym, int sizeof_D_Sym); 61 | #define UPDATE_ADDITIONAL_D_SYM(_st, _sym) update_additional_D_Sym(_st, _sym, sizeof(D_Sym)) 62 | D_Sym *current_D_Sym(D_Scope *st, D_Sym *sym); 63 | D_Sym *find_D_Sym_in_Scope(D_Scope *st, D_Scope *cur, char *name, char *end); 64 | D_Sym *next_D_Sym_in_Scope(D_Scope **st, D_Sym **sym); 65 | void print_scope(D_Scope *st); 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /RxODE/tests/test-parsing.R: -------------------------------------------------------------------------------- 1 | # test ODE parsing for syntax errors 2 | library("RxODE") 3 | library("tools") 4 | 5 | tmp <- tempdir() 6 | 7 | # list of model specs with errors (test description and code) 8 | errs <- list() 9 | 10 | errs[[1]] <- 11 | c(desc = 'incorrect d/dt operator', 12 | code = 'd/dt(y = 1);' 13 | ) 14 | 15 | errs[[2]] <- 16 | c(desc = 'comments must be outside statements', 17 | code = 'd/dt(y) = 1 # bad comment;' 18 | ) 19 | 20 | errs[[3]] <- 21 | c(desc = 'missing end of statement ";"', 22 | code = paste(sep = "\n", 23 | 'd/dt(depot) = -ka * depot', 24 | 'd/dt(centr) = ka * depot - kout * centr;') 25 | ) 26 | 27 | errs[[4]] <- 28 | c(desc = 'arithmetic syntax error', 29 | code = paste(sep = "\n", 30 | '# comment, just to show error in line 3', 31 | 'd/dt(y) = -ka;', 32 | 'C1 = /y;') 33 | ) 34 | 35 | errs[[5]] <- 36 | c(desc = 'unexistent operator **', 37 | code = paste(sep = "\n", 38 | 'd/dt(y) = -ka;', 39 | 'C1 = ka * y**2;') 40 | ) 41 | 42 | errs[[6]] <- 43 | c(desc = 'unexistent operator %', 44 | code = paste(sep = "\n", 45 | 'remainder = 4 % 3;', 46 | 'd/dt(y) = -ka;', 47 | 'C1 = ka * y;') 48 | ) 49 | 50 | errs[[7]] <- 51 | c(desc = 'incorrect "if" statement', 52 | code = paste(sep = "\n", 53 | 'if(comed==0){', 54 | ' F = 1.0;', 55 | 'else {', # missing "}"' 56 | ' F = 0.75;', 57 | '};', 58 | 'd/dt(y) = F * y;') 59 | ) 60 | 61 | errs[[8]] <- 62 | c(desc = 'illegal variable name (starting w. a digit)', 63 | code = paste(sep = "\n", 64 | 'F = 0.75;', 65 | '12foo_bar = 1.0/2.0;', 66 | 'd/dt(y) = F * y;') 67 | ) 68 | 69 | errs[[9]] <- 70 | c(desc = 'illegal variable name (illegal ".")', 71 | code = paste(sep = "\n", 72 | 'F = 0.75;', 73 | 'foo.bar = 1.0/2.0;', 74 | 'd/dt(y) = F * y;') 75 | ) 76 | 77 | errs[[10]] <- 78 | c(desc = 'illegal variable name in d/dt()', 79 | code = paste(sep = "\n", 80 | 'd/dt(y_1) = F * y;', # okay 81 | 'd/dt(y.1) = F * y;') # not okay 82 | ) 83 | 84 | N <- length(errs) 85 | for(i in 1:N){ 86 | 87 | desc <- errs[[i]]["desc"] 88 | code <- errs[[i]]["code"] 89 | 90 | cat(sprintf('Syntax test %d of %d (%s)\n', i, N, desc)) 91 | cat("==========================================================\n") 92 | cat("Input:\n", code, "\n", sep="") 93 | cat("\nRxODE message is:\n") 94 | 95 | assertError(RxODE(model = code, wd = tmp, modName=paste0("err",i))) 96 | 97 | cat("\n") 98 | } 99 | 100 | unlink(tmp, recursive = TRUE) 101 | -------------------------------------------------------------------------------- /RxODE/src/dparser/read_binary.c: -------------------------------------------------------------------------------- 1 | #include "d.h" 2 | 3 | static void 4 | read_chk(void* ptr, size_t size, size_t nmemb, FILE* fp, unsigned char **str) { 5 | if (fp) { 6 | if (fread(ptr, size, nmemb, fp) != nmemb) 7 | d_fail("error reading binary tables\n"); 8 | } else { 9 | memcpy(ptr, *str, size * nmemb); 10 | (*str) += size * nmemb; 11 | } 12 | } 13 | 14 | BinaryTables * 15 | read_binary_tables_internal(FILE *fp, unsigned char *str, 16 | D_ReductionCode spec_code, D_ReductionCode final_code) 17 | { 18 | BinaryTablesHead tables; 19 | int i; 20 | BinaryTables * binary_tables = MALLOC(sizeof(BinaryTables)); 21 | char *tables_buf, *strings_buf; 22 | 23 | read_chk(&tables, sizeof(BinaryTablesHead), 1, fp, &str); 24 | 25 | tables_buf = MALLOC(tables.tables_size + tables.strings_size); 26 | read_chk(tables_buf, sizeof(char), tables.tables_size, fp, &str); 27 | strings_buf = tables_buf + tables.tables_size; 28 | read_chk(strings_buf, sizeof(char), tables.strings_size, fp, &str); 29 | 30 | for (i=0; iparser_tables_gram = (D_ParserTables*)(tables_buf + tables.d_parser_tables_loc); 56 | binary_tables->tables = tables_buf; 57 | return binary_tables; 58 | } 59 | 60 | BinaryTables * 61 | read_binary_tables(char *file_name, 62 | D_ReductionCode spec_code, D_ReductionCode final_code) { 63 | FILE *fp = fopen(file_name, "rb"); 64 | if (!fp) 65 | d_fail("error opening tables %s\n", file_name); 66 | return read_binary_tables_internal(fp, 0, spec_code, final_code); 67 | } 68 | 69 | BinaryTables * 70 | read_binary_tables_from_file(FILE *fp, 71 | D_ReductionCode spec_code, D_ReductionCode final_code) { 72 | return read_binary_tables_internal(fp, 0, spec_code, final_code); 73 | } 74 | 75 | BinaryTables * 76 | read_binary_tables_from_string(unsigned char *str, D_ReductionCode spec_code, D_ReductionCode final_code) { 77 | return read_binary_tables_internal(0, str, spec_code, final_code); 78 | } 79 | 80 | void 81 | free_BinaryTables(BinaryTables * binary_tables) { 82 | d_free(binary_tables->tables); 83 | d_free(binary_tables); 84 | } 85 | -------------------------------------------------------------------------------- /RxODE/src/dparser/dparse.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2002-2004 John Plevyak, All Rights Reserved 3 | */ 4 | #ifndef _dparse_H_ 5 | #define _dparse_H_ 6 | 7 | #include 8 | #if defined(__cplusplus) 9 | extern "C" { 10 | #endif 11 | #include "dparse_tables.h" 12 | #include "dsymtab.h" 13 | 14 | struct D_Parser; 15 | struct D_ParserTables; 16 | struct D_Scope; 17 | struct D_ParseNode; 18 | 19 | typedef void *d_voidp; 20 | #ifndef D_ParseNode_User 21 | #define D_ParseNode_User d_voidp 22 | #endif 23 | #ifndef D_ParseNode_Globals 24 | #define D_ParseNode_Globals void 25 | #endif 26 | 27 | typedef void (*D_SyntaxErrorFn)(struct D_Parser *); 28 | typedef struct D_ParseNode *(*D_AmbiguityFn)(struct D_Parser *, 29 | int n, struct D_ParseNode **v); 30 | typedef void (*D_FreeNodeFn)(struct D_ParseNode *d); 31 | 32 | typedef struct D_Parser { 33 | D_ParseNode_Globals *initial_globals; /* global values */ 34 | D_WhiteSpaceFn initial_white_space_fn; 35 | struct D_Scope *initial_scope; 36 | D_SyntaxErrorFn syntax_error_fn; 37 | D_AmbiguityFn ambiguity_fn; 38 | D_FreeNodeFn free_node_fn; 39 | d_loc_t loc; /* initial location, set on error */ 40 | int start_state; // do not move or change without fixing copy_user_configurables() 41 | /* user configurables */ 42 | int sizeof_user_parse_node; 43 | int save_parse_tree; 44 | int dont_compare_stacks; 45 | int dont_fixup_internal_productions; 46 | int fixup_EBNF_productions; 47 | int dont_merge_epsilon_trees; 48 | int dont_use_height_for_disambiguation; 49 | int dont_use_greediness_for_disambiguation; 50 | int commit_actions_interval; /* 0 is immediate */ 51 | int error_recovery; 52 | int partial_parses; 53 | /* parse results */ 54 | int syntax_errors; // do not move or change without fixing copy_user_configurables() 55 | } D_Parser; 56 | 57 | typedef struct D_ParseNode { 58 | int symbol; 59 | d_loc_t start_loc; 60 | char *end; 61 | char *end_skip; 62 | struct D_Scope *scope; 63 | D_WhiteSpaceFn white_space; 64 | D_ParseNode_Globals *globals; 65 | D_ParseNode_User user; 66 | } D_ParseNode; 67 | 68 | D_Parser *new_D_Parser(struct D_ParserTables *t, int sizeof_ParseNode_User); 69 | void free_D_Parser(D_Parser *p); 70 | D_ParseNode *dparse(D_Parser *p, char *buf, int buf_len); 71 | void free_D_ParseNode(D_Parser *p, D_ParseNode *pn); 72 | void free_D_ParseTreeBelow(D_Parser *p, D_ParseNode *pn); 73 | 74 | int d_get_number_of_children(D_ParseNode *pn); 75 | D_ParseNode *d_get_child(D_ParseNode *pn, int child); 76 | D_ParseNode *d_find_in_tree(D_ParseNode *pn, int symbol); 77 | char *d_ws_before(D_Parser *p, D_ParseNode *pn); /* points BEFORE leading ws */ 78 | char *d_ws_after(D_Parser *p, D_ParseNode *pn); /* points AFTER trailing ws */ 79 | 80 | void d_pass(D_Parser *p, D_ParseNode *pn, int pass_number); 81 | 82 | int resolve_amb_greedy(D_Parser *dp, int n, D_ParseNode **v); 83 | 84 | char *d_dup_pathname_str(const char *str); 85 | 86 | #if defined(__cplusplus) 87 | } 88 | #endif 89 | 90 | #endif 91 | -------------------------------------------------------------------------------- /RxODE/src/dparser/faq.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | manual.html 7 | 8 | 9 |
  DParser FAQ
11 |
12 |

13 |
14 |
1. How do 16 | I access the subnodes for expressions like "S: A*;" ?
17 |
19 |
In this case, "A*" is $n0 of type 20 | D_ParseNode.  In dparse.h the functions 21 | d_get_number_of_children(D_ParseNode *) and d_get_child(D_ParseNode *, 22 | int) allow you to get the number of children (A's) by calling 24 | d_get_number_of_children(&$n0) and individual children by calling 25 | d_get_child(&$n0, x).
26 |
27 | See the example: tests/g27.test.g
28 |
29 | 2. Why doesn't '$n0.end_skip' include 30 | the trailing whitespace when $n0 is a string/regex?
31 |
32 |
Whitespace is not skipped as part of the scan of a 33 | string/regex but is done later (when the new parse state is 34 | created).  This makes it possible to change the whitespace parser 35 | as a result of recognition of a particular string/regex.  This is 36 | used in the python grammar to handle implicit line joining.
37 |
38 | See the regex-productions LP RP LB RB LC RC in test/python.test.g.
39 |
40 | 3. What is the difference between 41 | DParser and ANTLR?
42 |

43 | The basic syntax of DParser and ANTLR grammars is very similar.  44 | In fact, the DParser example ANSI-C grammar was ported from ANTLR in 45 | less than an hour. 
46 |
47 | Beyond that there are a number of differences.  First of all ANTRL 48 | has been developed for over a decade while DParser is relatively 49 | young.  Internally, DParser is a table-driven parser while ANTLR 50 | generates directly executable parsers.  DParser is a GLR parser 51 | based on the Tomita algorithm while ANTLR is modified LL(k).  52 | DParser is scannerless while ANTLR uses token streams.  In terms 53 | of power, both DParser and ANTLR are very powerful.  In theory 54 | DParser can handle any context free grammar, though not necessarily in 55 | linear time.  In practice ANTLR is likely to be faster (mostly 56 | because it is more mature).   Beyond that you would really 57 | have ask Terance Parr who is more of a hard core parsing theory guru 58 | than I am.
59 |
60 |
61 | 62 | 63 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/bnf.g.1: -------------------------------------------------------------------------------- 1 | rulelist = 1*( rule / (*c-wsp c-nl) ) 2 | 3 | rule = rulename defined-as elements c-nl 4 | ; continues if next line starts 5 | ; with white space 6 | 7 | rulename = ALPHA *(ALPHA / DIGIT / "-") 8 | 9 | defined-as = *c-wsp ("=" / "=/") *c-wsp 10 | ; basic rules definition and 11 | ; incremental alternatives 12 | 13 | elements = alternation *c-wsp 14 | 15 | c-wsp = WSP / (c-nl WSP) 16 | 17 | c-nl = comment / CRLF 18 | ; comment or newline 19 | 20 | comment = ";" *(WSP / VCHAR) CRLF 21 | 22 | alternation = concatenation 23 | *(*c-wsp "/" *c-wsp concatenation) 24 | 25 | concatenation = repetition *(1*c-wsp repetition) 26 | 27 | repetition = [repeat] element 28 | 29 | repeat = 1*DIGIT / (*DIGIT "*" *DIGIT) 30 | 31 | element = rulename / group / option / 32 | char-val / num-val / prose-val 33 | 34 | group = "(" *c-wsp alternation *c-wsp ")" 35 | 36 | option = "[" *c-wsp alternation *c-wsp "]" 37 | 38 | char-val = DQUOTE *(%x20-21 / %x23-7E) DQUOTE 39 | ; quoted string of SP and VCHAR without DQUOTE 40 | 41 | num-val = "%" (bin-val / dec-val / hex-val) 42 | 43 | bin-val = "b" 1*BIT 44 | [ 1*("." 1*BIT) / ("-" 1*BIT) ] 45 | ; series of concatenated bit values 46 | ; or single ONEOF range 47 | 48 | dec-val = "d" 1*DIGIT 49 | [ 1*("." 1*DIGIT) / ("-" 1*DIGIT) ] 50 | 51 | hex-val = "x" 1*HEXDIG 52 | [ 1*("." 1*HEXDIG) / ("-" 1*HEXDIG) ] 53 | 54 | prose-val = "<" *(%x20-3D / %x3F-7E) ">" 55 | ; bracketed string of SP and VCHAR without angles 56 | ; prose description, to be used as last resort 57 | 58 | 59 | ALPHA = %x41-5A / %x61-7A ; A-Z / a-z 60 | 61 | BIT = "0" / "1" 62 | 63 | CHAR = %x01-7F 64 | ; any 7-bit US-ASCII character, excluding NUL 65 | 66 | CR = %x0D 67 | ; carriage return 68 | 69 | CRLF = CR LF 70 | ; Internet standard newline 71 | 72 | DIGIT = %x30-39 73 | ; 0-9 74 | 75 | DQUOTE = %x22 76 | ; " (Double Quote) 77 | 78 | HEXDIG = DIGIT / "A" / "B" / "C" / "D" / "E" / "F" 79 | 80 | HTAB = %x09 81 | ; horizontal tab 82 | 83 | LF = %x0A 84 | ; linefeed 85 | 86 | LWSP = *(WSP / CRLF WSP) 87 | ; linear white space (past newline) 88 | 89 | OCTET = %x00-FF 90 | ; 8 bits of data 91 | 92 | ;CTL = %x00-1F / %x7F 93 | ; controls 94 | 95 | SP = %x20 96 | ; space 97 | 98 | VCHAR = %x21-7E 99 | ; visible (printing) characters 100 | 101 | WSP = SP / HTAB 102 | ; white space 103 | -------------------------------------------------------------------------------- /RxODE/tests/test-multi.R: -------------------------------------------------------------------------------- 1 | # (Regression) test 3 multiple instances of RxODE objects to ensure 2 | # C symbols and operations don't conflict. 3 | 4 | library("RxODE") 5 | 6 | test.dir <- tempfile("Rxmult-") 7 | 8 | # RxODE instance 1 9 | m1 <- 10 | RxODE( 11 | model = ' 12 | C2 = centr/V2; 13 | C3 = peri/V3; 14 | d/dt(depot) =-KA*depot; 15 | d/dt(centr) = KA*depot - CL*C2 - Q*C2 + Q*C3; 16 | d/dt(peri) = Q*C2 - Q*C3; 17 | d/dt(eff) = Kin - Kout*(1-C2/(EC50+C2))*eff;', 18 | modName = "inst1", 19 | wd = test.dir 20 | ) 21 | et1 <- eventTable(amount.units="ug", time.units = "hours") 22 | et1$add.dosing(dose=10000, nbr.doses=5, dosing.interval = 24) 23 | et1$add.sampling(0:24) 24 | et1$add.sampling(seq(from = 24+8, to = 5*24, by = 8)) 25 | 26 | o1.first <- 27 | m1$solve( 28 | params = c(KA=.291, CL=18.6, V2=40.2, Q=10.5, V3=297.0, 29 | Kin=1.0, Kout=1.0, EC50=200.0), 30 | events = et1, 31 | inits = c(0, 0, 0, 1) 32 | ) 33 | 34 | # RxODE instance 2 (complete example) 35 | m2 <- 36 | RxODE( 37 | model = 'd/dt(y) = r * y * (1.0 - y/K);', 38 | modName = "inst2", 39 | wd = test.dir 40 | ) 41 | et2 <- eventTable(time.units= NA) 42 | et2$add.sampling(seq(from = 0, to = 20, by = 0.2)) 43 | o2.s <- 44 | m2$solve(params=c(r=1, K=10), events=et2, inits=c(y=2), stiff = TRUE) 45 | 46 | # RxODE instance 3 (complete example) 47 | m3 <- 48 | RxODE( 49 | model = ' 50 | d/dt(X) = a*X + Y*Z; 51 | d/dt(Y) = b*(Y - Z); 52 | d/dt(Z) = -X*Y + c*Y - Z;', 53 | modName = "inst3", 54 | wd = tempdir() # don't pollute "./tests" 55 | ) 56 | et3 <- eventTable() # default time units 57 | et3$add.sampling(seq(from=0, to=100, by=0.01)) 58 | o3 <- 59 | m3$solve( params = c(a=-8/3, b=-10, c=28), 60 | events = et3, 61 | inits = c(X=1, Y=1, Z=1) 62 | ) 63 | 64 | # Now go back to model 1 for (same) integration 65 | o1.second <- 66 | m1$solve( 67 | params = c(KA=.291, CL=18.6, V2=40.2, Q=10.5, V3=297.0, 68 | Kin=1.0, Kout=1.0, EC50=200.0), 69 | events = et1, 70 | inits = c(0, 0, 0, 1) 71 | ) 72 | 73 | all.equal(o1.first, o1.second) 74 | 75 | # and go back to model 2 for different ode solver 76 | o2.ns <- 77 | m2$solve(params=c(r=1, K=10), events=et2, inits=c(y=12), stiff = FALSE) 78 | 79 | # Inspect the internal compilation manager in each of the RxODE objects 80 | prt <- 81 | function(obj) 82 | { 83 | cat( 84 | sprintf('Model name: %s\nDyn lib: %s\node_solver symbol: %s\n', 85 | obj$modName, obj$cmpMgr$dllfile, obj$cmpMgr$ode_solver 86 | ) 87 | ) 88 | } 89 | 90 | prt(m1) 91 | prt(m2) 92 | prt(m3) 93 | 94 | # Unload object code (this is platform-dependent, as documented in the 95 | # "Note" section of help("dyn.load"). Remove test.dir. 96 | m1$dynUnload() 97 | m2$dynUnload() 98 | m3$dynUnload() 99 | print(unlink(test.dir, recursive = TRUE)) # 0==success, 1==failed 100 | 101 | 102 | -------------------------------------------------------------------------------- /RxODE/src/dparser/d.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2002-2004 John Plevyak, All Rights Reserved 3 | */ 4 | #ifndef _d_H_ 5 | #define _d_H_ 6 | 7 | #ifdef MEMWATCH 8 | #define MEMWATCH_STDIO 1 9 | #include "../../src/memwatch-2.67/memwatch.h" 10 | #define MEM_GROW_MACRO 11 | #endif 12 | #include 13 | #include 14 | #include 15 | #include 16 | #if !defined(__FreeBSD__) || (__FreeBSD_version >= 500000) 17 | #include 18 | #endif 19 | #include 20 | #include 21 | #ifndef __MINGW32__ 22 | #include 23 | #include 24 | #endif 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | 34 | #ifdef LEAK_DETECT 35 | #define GC_DEBUG 36 | #include "gc.h" 37 | #define MALLOC(n) GC_MALLOC(n) 38 | #define CALLOC(m,n) GC_MALLOC((m)*(n)) 39 | #define FREE(p) GC_FREE(p) 40 | #define REALLOC(p,n) GC_REALLOC((p),(n)) 41 | #define CHECK_LEAKS() GC_gcollect() 42 | #else 43 | #ifdef USE_GC 44 | #include "gc.h" 45 | #define MALLOC GC_MALLOC 46 | #define REALLOC GC_REALLOC 47 | #define FREE(_x) 48 | #define malloc dont_use_malloc_use_MALLOC_instead 49 | #define relloc dont_use_realloc_use_REALLOC_instead 50 | #define free dont_use_free_use_FREE_instead 51 | #else 52 | #define MALLOC malloc 53 | #define REALLOC realloc 54 | #define FREE free 55 | #endif 56 | #endif 57 | 58 | // enough already with the signed/unsiged char issues 59 | #define isspace_(_c) isspace((unsigned char)(_c)) 60 | #define isdigit_(_c) isdigit((unsigned char)(_c)) 61 | #define isxdigit_(_c) isxdigit((unsigned char)(_c)) 62 | #define isprint_(_c) isprint((unsigned char)(_c)) 63 | 64 | #define D_VERSION (\ 65 | (D_MAJOR_VERSION << 24) + (D_MINOR_VERSION << 16) + \ 66 | D_BUILD_VERSION) 67 | 68 | /* Compilation Options 69 | */ 70 | 71 | #define round2(_x,_n) ((_x + ((_n)-1)) & ~((_n)-1)) 72 | #define tohex1(_x) \ 73 | ((((_x)&15) > 9) ? (((_x)&15) - 10 + 'A') : (((_x)&15) + '0')) 74 | #define tohex2(_x) \ 75 | ((((_x)>>4) > 9) ? (((_x)>>4) - 10 + 'A') : (((_x)>>4) + '0')) 76 | #define numberof(_x) ((sizeof(_x))/(sizeof((_x)[0]))) 77 | 78 | typedef char int8; 79 | typedef unsigned char uint8; 80 | typedef int int32; 81 | typedef unsigned int uint32; 82 | typedef long long int64; 83 | typedef unsigned long long uint64; 84 | typedef short int16; 85 | typedef unsigned short uint16; 86 | #ifdef __MINGW32__ 87 | /* already part of most systems */ 88 | typedef unsigned long ulong; 89 | typedef uint32 uint; 90 | #endif 91 | 92 | #include "dparse.h" 93 | #include "arg.h" 94 | #include "util.h" 95 | #include "gram.h" 96 | #include "lr.h" 97 | #include "lex.h" 98 | #include "scan.h" 99 | #include "parse.h" 100 | #include "write_tables.h" 101 | #include "read_binary.h" 102 | 103 | #ifdef D_DEBUG 104 | #define DBG(_x) if (d_debug_level>1) { _x; } 105 | #else 106 | #define DBG(_x) 107 | #endif 108 | 109 | void d_version(char *); 110 | 111 | #define USE_SCANNER 1 112 | 113 | #endif 114 | -------------------------------------------------------------------------------- /RxODE/man/rx.initCmpMgr.Rd: -------------------------------------------------------------------------------- 1 | \name{rx.initCmpMgr} 2 | \alias{rx.initCmpMgr} 3 | \title{ 4 | A compilation manager for RxODE models 5 | } 6 | \description{ 7 | This function parses, compiles, links, and loads the shared 8 | object that implements an RxODE model. 9 | } 10 | \usage{ 11 | rx.initCmpMgr(model, modName, wd) 12 | } 13 | \arguments{ 14 | \item{model}{ 15 | a string containing the source \code{RxODE} model; 16 | } 17 | \item{modName}{ 18 | a string with a model identifier (this string will be used to 19 | construct filenames and C symbols, therefore it must be suitable 20 | for creating those identifiers); 21 | } 22 | \item{wd}{ 23 | a string with a file path to a working directory where to create 24 | various C and object files. 25 | } 26 | } 27 | \details{ 28 | The function parses and compiles (if needed) the \code{RxODE} model 29 | specified in the string \code{model} into a dynamic link library (DLL 30 | on Windows) or a shared object (\code{*.so} on Unix-like systems). 31 | It then dynamically loads this code into the current R session. 32 | (Models previously parsed and compiled in previous R sessions 33 | only need to be dynamically loaded into the current R session.) 34 | } 35 | \value{ 36 | An object (closure) with the following member functions: 37 | \item{parse}{ 38 | this function parses (translates) the ODE-based model 39 | specification and generates a C file to implement the model.} 40 | \item{compile}{ 41 | compiles the generated C file for the ODE system 42 | and dynamically loads the machine code in the shared object.} 43 | \item{dynLoad}{ 44 | if needed, dynamically loads the dynamic library 45 | produced in the \code{compile()} step. Note that the shared 46 | object persists across R sessions, thus the \code{dynLoad} needs 47 | to be issued as needed.} 48 | \item{dynUnload}{ 49 | this function unloads the previously dynamically loaded 50 | model object code. Mainly for internal use.} 51 | \item{ode_solver}{ 52 | a string with the name of the C symbol for this model solver.} 53 | \item{dllfile}{ 54 | a string with the name of the dynamic link (or shared object) file.} 55 | \item{get.modelVars}{ 56 | function that returns a list with 3 character 57 | vectors, \code{params}, \code{state}, and \code{lhs} of variable 58 | names (identifiers) used in the model specification. 59 | These will be output when the model is computed (i.e., the ODE 60 | solved).} 61 | \item{isValid}{ 62 | a function that (naively) checks for model validity, 63 | namely that the C object code reflects the latest model 64 | specification.} 65 | \item{get.index}{ 66 | helper function to extract the index of one or 67 | more system variables (state, parameter, or other).} 68 | \item{getObj}{ 69 | internal (not user callable) function.} 70 | } 71 | \seealso{ 72 | \code{\link{RxODE}} 73 | } 74 | \examples{\dontrun{ 75 | cmpMgt <- rx.initCmpMgr(model, "tst1", wd = ".") 76 | } 77 | } 78 | \keyword{models} 79 | \keyword{ODE} 80 | \concept{ordinary differential equations} 81 | -------------------------------------------------------------------------------- /RxODE/inst/doc/RxODE-intro.R: -------------------------------------------------------------------------------- 1 | ## ----setup, include = FALSE---------------------------------------------- 2 | library(knitr) 3 | 4 | ## ------------------------------------------------------------------------ 5 | ode <- " 6 | C2 = centr/V2; 7 | C3 = peri/V3; 8 | d/dt(depot) =-KA*depot; 9 | d/dt(centr) = KA*depot - CL*C2 - Q*C2 + Q*C3; 10 | d/dt(peri) = Q*C2 - Q*C3; 11 | d/dt(eff) = Kin - Kout*(1-C2/(EC50+C2))*eff; 12 | " 13 | 14 | ## ------------------------------------------------------------------------ 15 | library(RxODE) 16 | work <- tempfile("Rx_intro-") 17 | mod1 <- RxODE(model = ode, modName = "mod1", wd = work) 18 | 19 | ## ------------------------------------------------------------------------ 20 | theta <- 21 | c(KA=2.94E-01, CL=1.86E+01, V2=4.02E+01, # central 22 | Q=1.05E+01, V3=2.97E+02, # peripheral 23 | Kin=1, Kout=1, EC50=200) # effects 24 | 25 | ## ------------------------------------------------------------------------ 26 | inits <- c(depot=0, centr=0, peri=0, eff=1) 27 | 28 | ## ------------------------------------------------------------------------ 29 | ev <- eventTable(amount.units='mg', time.units='hours') 30 | 31 | ## ------------------------------------------------------------------------ 32 | ev$add.dosing(dose=10000, nbr.doses=10, dosing.interval=12) 33 | ev$add.dosing(dose=20000, nbr.doses=5, start.time=120, dosing.interval=24) 34 | ev$add.sampling(0:240) 35 | 36 | ## ------------------------------------------------------------------------ 37 | head(ev$get.dosing()) 38 | 39 | ## ------------------------------------------------------------------------ 40 | head(ev$get.sampling()) 41 | 42 | ## ------------------------------------------------------------------------ 43 | x <- mod1$solve(theta, ev, inits) 44 | head(x) 45 | 46 | ## ----fig.width=10-------------------------------------------------------- 47 | par(mfrow=c(1,2)) 48 | matplot(x[,"C2"], type="l", ylab="Central Concentration") 49 | matplot(x[,"eff"], type="l", ylab = "Effect") 50 | 51 | ## ------------------------------------------------------------------------ 52 | nsub <- 100 #number of subproblems 53 | CL <- 1.86E+01*exp(rnorm(nsub,0,.4^2)) 54 | theta.all <- 55 | cbind(KA=2.94E-01, CL=CL, V2=4.02E+01, # central 56 | Q=1.05E+01, V3=2.97E+02, # peripheral 57 | Kin=1, Kout=1, EC50=200) # effects 58 | head(theta.all) 59 | 60 | ## ----fig.width=10-------------------------------------------------------- 61 | nobs <- ev$get.nobs() 62 | cp.all <- matrix(NA, nobs, nsub) 63 | for (i in 1:nsub) 64 | { 65 | theta <- theta.all[i,] 66 | x <- mod1$solve(theta, ev, inits=inits) 67 | cp.all[, i] <- x[, "C2"] 68 | } 69 | 70 | matplot(cp.all, type="l", ylab="Central Concentration") 71 | 72 | 73 | ## ----fig.width=10-------------------------------------------------------- 74 | cp.q <- apply(cp.all, 1, quantile, prob = c(0.05, 0.50, 0.95)) 75 | matplot(t(cp.q), type="l", lty=c(2,1,2), col=c(2,1,2), ylab="Central Concentration") 76 | 77 | 78 | ## ----cleanup, include = FALSE-------------------------------------------- 79 | mod1$dynUnload() # otherwise we can't unlink(work) 80 | unlink(work, recursive = TRUE) 81 | 82 | -------------------------------------------------------------------------------- /RxODE/inst/Changes.txt: -------------------------------------------------------------------------------- 1 | Version 0.5-1 2 | 3 | * Mainly changes to prepare for CRAN. 4 | 5 | * Added workaround for the Windows issue of folder names with embedded 6 | spaces. 7 | 8 | * Cleaned up the ode directory to remove unused fortran code causing 9 | too many warnings. 10 | 11 | * Added a $copy() method to the eventTable object; reversed the default 12 | time.interval=24 in eventTable$add.dosing(). 13 | 14 | * Added "tests" subdirectory; more scripts need to be written. 15 | 16 | Version 0.5-0 17 | 18 | * Moved to github. 19 | 20 | Version 0.4-1 21 | 22 | * RxODE objects include get.modelVars() to extract model params, lhs, 23 | and state variables 24 | 25 | * Update call_dvode.c to prevent aborting R. 26 | 27 | Version 0.4-0 (svn revision 123, 06Jan2015) 28 | 29 | * Reverted to the simple name "RxODE" from "RxODE2". 30 | 31 | * Added syntax to the ODE modeling language to allow comments. 32 | 33 | * Deprecated the RxODE function "run", use "solve" going forward. 34 | 35 | * Added vignettes and demos. 36 | 37 | * Re-named source subdirectories with more descriptive names. 38 | 39 | * Changes to RxODE() 40 | + Added a filename= argument to allow models to be specified via a 41 | file instead of strings in model= (these two arguments are 42 | mutually exclusive); 43 | + Changed some argument names to better reflect what they are, 44 | namely, "th=" in run() now is "params=". 45 | + Added a solve() synonym to run() (what about "fit()"?) 46 | + Re-factor RxODE and moved all the code that deals with 47 | parsing, compiling, linking, etc., into a "compilation manager" 48 | object "cmpMgr". A new function rx.initCmpMgr() does all this. 49 | + Fixed bug in run() that was producing "observations" at dosing 50 | times (i.e., not only at sampling times). 51 | + Added code in the compilation manager to generate C files 52 | with project-specific C function names (previously we had a single 53 | entry for all models); this allows us to working with multiple 54 | models concurrently. [We may need to revisit this approach.] 55 | 56 | * Changes to eventTable() and its methods: 57 | + Added optional argument "amount.units=" and "time.units="; 58 | + add.dosing() no longer has a default dosing.intervals= 59 | when specifying multiple doses; 60 | + add.dosing() has a new default for "start.time=" (0 for 61 | very first dosing event, otherwise max(time) + duration.time. 62 | [Should we force this not to have a default?] 63 | 64 | * C code 65 | + Renamed jj.c file to tran.c 66 | + Fixed fprintf() non-constant formats (security warnings on 67 | gcc 4.8.2); 68 | + Fixed non-portable casting from 64-bit pointers to 32-bit ints; 69 | + ode/dop831.c, deprecated #include in favor of 70 | #include (required on Mac OS X); 71 | 72 | * Mac OS/X 10.6 73 | + Makefile ld(1) requires a space after -o, i.e., "-o tran.exe"; 74 | 75 | * Windows 76 | + Updated src/Makefile.win for updated file names, etc. 77 | 78 | Version 0.3 79 | 80 | * Self-containing: including build parser & libodeaux.a 81 | 82 | Version 0.2-1 83 | 84 | * Renamed package to RxODE 85 | 86 | Version 0.1-1 87 | 88 | * Initial version. Depends on external commands tran and 89 | prn_tree, plus on external libodeaux.a library. 90 | -------------------------------------------------------------------------------- /RxODE/man/genShinyApp.template.Rd: -------------------------------------------------------------------------------- 1 | \name{genShinyApp.template} 2 | \alias{genShinyApp.template} 3 | \alias{write.template.server} 4 | \alias{write.template.ui} 5 | \title{ 6 | Generate an example (template) of a dosing regimen shiny app 7 | } 8 | \description{ 9 | Create a complete shiny application for exploring dosing regimens 10 | given a (hardcoded) PK/PD model. 11 | } 12 | \usage{ 13 | genShinyApp.template(appDir = "shinyExample", verbose = TRUE, 14 | ODE.config = list( 15 | ode = " 16 | C2 = centr/V2; 17 | C3 = peri/V3; 18 | d/dt(depot) =-KA*depot; 19 | d/dt(centr) = KA*depot - CL*C2 - Q*C2 + Q*C3; 20 | d/dt(peri) = Q*C2 - Q*C3; 21 | d/dt(eff) = Kin - Kout*(1-C2/(EC50+C2))*eff; 22 | ", 23 | 24 | params = 25 | c(KA=.294, CL=18.6, V2=40.2, Q=10.5, V3=297.0, 26 | Kin=1.0, Kout=1.0, EC50=200.0), 27 | 28 | inits = c(depot=0, centr=0, pari=0, eff=1), 29 | stiff = TRUE, 30 | atol = 1e-08, 31 | rtol = 1e-06 32 | ) 33 | ) 34 | } 35 | \arguments{ 36 | \item{appDir}{ 37 | a string with a directory where to store the shiny app, by default 38 | is \code{"shinyExample"}. 39 | The directory \code{appDir} will be created if it does not exist. 40 | } 41 | \item{verbose}{ 42 | logical specifying whether to write messages as the shiny app 43 | is generated. Defaults to \code{TRUE}. 44 | } 45 | \item{ODE.config}{ 46 | a list of ODE configurations with components: (1) ode: a string of 47 | differential equations; (2) params: a named vector of system parameters 48 | in ODEs; (3) inits: initial values of the ODEs; (4) stiff: logical 49 | specifying whether to use a stiff ODE solver; (5) atol: absolute error 50 | tolerance when solving ODEs; (6) atol: relative error 51 | tolerance when solving ODEs. 52 | } 53 | } 54 | \details{ 55 | A PK/PD model is defined using \code{\link{RxODE}}, and 56 | a set of parameters and initial values are defined. Then 57 | the appropriate R scripts for the shiny's user interface \code{ui.R} 58 | and the server logic \code{server.R} are created in the 59 | directory \code{appDir}. 60 | 61 | The function evaluates the following PK/PD model: 62 | \preformatted{ 63 | C2 = centr/V2; 64 | C3 = peri/V3; 65 | d/dt(depot) =-KA*depot; 66 | d/dt(centr) = KA*depot - CL*C2 - Q*C2 + Q*C3; 67 | d/dt(peri) = Q*C2 - Q*C3; 68 | d/dt(eff) = Kin - Kout*(1-C2/(EC50+C2))*eff; 69 | } 70 | 71 | To launch the shiny app, simply issue the \code{runApp(appDir)} 72 | R command. 73 | } 74 | \value{ 75 | None, these functions are used for their side effects. 76 | } 77 | \note{ 78 | These functions create a simple, but working example of a dosing 79 | regimen simulation web application. Users may want to modify the code 80 | to experiment creating shiny applications for their specific 81 | \code{RxODE} models. 82 | } 83 | 84 | \seealso{ 85 | \code{\link{RxODE}}, \code{\link{eventTable}}, and the 86 | package \pkg{shiny} (\url{shiny.rstudio.com}. 87 | } 88 | \examples{ 89 | \dontrun{ 90 | # create the shiny app example (template) 91 | genShinyApp.template(appDir = "myapp") 92 | 93 | # run the shiny app 94 | runApp("myapp") 95 | } 96 | } 97 | \keyword{simulation} 98 | \keyword{nonlinear} 99 | \concept{PK/PD} 100 | \concept{pharmacometrics} 101 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/sample.test.g.22: -------------------------------------------------------------------------------- 1 | a = b 2 | +b+b+b+b+b+b+b+b+b+b 3 | +b+b+b+b+b+b+b+b+b+b 4 | +b+b+b+b+b+b+b+b+b+b 5 | +b+b+b+b+b+b+b+b+b+b 6 | +b+b+b+b+b+b+b+b+b+b 7 | +b+b+b+b+b+b+b+b+b+b // 1 8 | +b+b+b+b+b+b+b+b+b+b 9 | +b+b+b+b+b+b+b+b+b+b 10 | +b+b+b+b+b+b+b+b+b+b 11 | +b+b+b+b+b+b+b+b+b+b 12 | 13 | +b+b+b+b+b+b+b+b+b+b 14 | +b+b+b+b+b+b+b+b+b+b 15 | +b+b+b+b+b+b+b+b+b+b 16 | +b+b+b+b+b+b+b+b+b+b 17 | +b+b+b+b+b+b+b+b+b+b 18 | +b+b+b+b+b+b+b+b+b+b // 2 19 | +b+b+b+b+b+b+b+b+b+b 20 | +b+b+b+b+b+b+b+b+b+b 21 | +b+b+b+b+b+b+b+b+b+b 22 | +b+b+b+b+b+b+b+b+b+b 23 | 24 | +b+b+b+b+b+b+b+b+b+b 25 | +b+b+b+b+b+b+b+b+b+b 26 | +b+b+b+b+b+b+b+b+b+b 27 | +b+b+b+b+b+b+b+b+b+b 28 | +b+b+b+b+b+b+b+b+b+b 29 | +b+b+b+b+b+b+b+b+b+b // 3 30 | +b+b+b+b+b+b+b+b+b+b 31 | +b+b+b+b+b+b+b+b+b+b 32 | +b+b+b+b+b+b+b+b+b+b 33 | +b+b+b+b+b+b+b+b+b+b 34 | 35 | +b+b+b+b+b+b+b+b+b+b 36 | +b+b+b+b+b+b+b+b+b+b 37 | +b+b+b+b+b+b+b+b+b+b 38 | +b+b+b+b+b+b+b+b+b+b 39 | +b+b+b+b+b+b+b+b+b+b 40 | +b+b+b+b+b+b+b+b+b+b // 4 41 | +b+b+b+b+b+b+b+b+b+b 42 | +b+b+b+b+b+b+b+b+b+b 43 | +b+b+b+b+b+b+b+b+b+b 44 | +b+b+b+b+b+b+b+b+b+b 45 | 46 | +b+b+b+b+b+b+b+b+b+b 47 | +b+b+b+b+b+b+b+b+b+b 48 | +b+b+b+b+b+b+b+b+b+b 49 | +b+b+b+b+b+b+b+b+b+b 50 | +b+b+b+b+b+b+b+b+b+b // 5 51 | +b+b+b+b+b+b+b+b+b+b 52 | +b+b+b+b+b+b+b+b+b+b 53 | +b+b+b+b+b+b+b+b+b+b 54 | +b+b+b+b+b+b+b+b+b+b 55 | +b+b+b+b+b+b+b+b+b+b 56 | 57 | +b+b+b+b+b+b+b+b+b+b 58 | +b+b+b+b+b+b+b+b+b+b 59 | +b+b+b+b+b+b+b+b+b+b 60 | +b+b+b+b+b+b+b+b+b+b 61 | +b+b+b+b+b+b+b+b+b+b // 6 62 | +b+b+b+b+b+b+b+b+b+b 63 | +b+b+b+b+b+b+b+b+b+b 64 | +b+b+b+b+b+b+b+b+b+b 65 | +b+b+b+b+b+b+b+b+b+b 66 | +b+b+b+b+b+b+b+b+b+b 67 | 68 | +b+b+b+b+b+b+b+b+b+b 69 | +b+b+b+b+b+b+b+b+b+b 70 | +b+b+b+b+b+b+b+b+b+b 71 | +b+b+b+b+b+b+b+b+b+b 72 | +b+b+b+b+b+b+b+b+b+b // 7 73 | +b+b+b+b+b+b+b+b+b+b 74 | +b+b+b+b+b+b+b+b+b+b 75 | +b+b+b+b+b+b+b+b+b+b 76 | +b+b+b+b+b+b+b+b+b+b 77 | +b+b+b+b+b+b+b+b+b+b 78 | 79 | +b+b+b+b+b+b+b+b+b+b 80 | +b+b+b+b+b+b+b+b+b+b 81 | +b+b+b+b+b+b+b+b+b+b 82 | +b+b+b+b+b+b+b+b+b+b 83 | +b+b+b+b+b+b+b+b+b+b // 8 84 | +b+b+b+b+b+b+b+b+b+b 85 | +b+b+b+b+b+b+b+b+b+b 86 | +b+b+b+b+b+b+b+b+b+b 87 | +b+b+b+b+b+b+b+b+b+b 88 | +b+b+b+b+b+b+b+b+b+b 89 | 90 | +b+b+b+b+b+b+b+b+b+b 91 | +b+b+b+b+b+b+b+b+b+b 92 | +b+b+b+b+b+b+b+b+b+b 93 | +b+b+b+b+b+b+b+b+b+b 94 | +b+b+b+b+b+b+b+b+b+b // 9 95 | +b+b+b+b+b+b+b+b+b+b 96 | +b+b+b+b+b+b+b+b+b+b 97 | +b+b+b+b+b+b+b+b+b+b 98 | +b+b+b+b+b+b+b+b+b+b 99 | +b+b+b+b+b+b+b+b+b+b 100 | 101 | +b+b+b+b+b+b+b+b+b+b 102 | +b+b+b+b+b+b+b+b+b+b 103 | +b+b+b+b+b+b+b+b+b+b 104 | +b+b+b+b+b+b+b+b+b+b 105 | +b+b+b+b+b+b+b+b+b+b // 10 106 | +b+b+b+b+b+b+b+b+b+b 107 | +b+b+b+b+b+b+b+b+b+b 108 | +b+b+b+b+b+b+b+b+b+b 109 | +b+b+b+b+b+b+b+b+b+b 110 | +b+b+b+b+b+b+b+b+b+b 111 | ; 112 | -------------------------------------------------------------------------------- /RxODE/inst/Install-windows.Rmd: -------------------------------------------------------------------------------- 1 | `RxODE` installation under R for Windows 2 | ======================================== 3 | 4 | These notes briefly describe steps to properly install `RxODE` and to 5 | ensure `Rtools` (http://cran-r.project.org/bin/windows/Rtoos) are properly 6 | configured to avoid compilation issues during the use of `RxODE`. 7 | 8 | In a nutshell, installing `RxODE` is very straight forwad, but installing 9 | and configuring `Rtools` is a bit more delicate and you need to 10 | carefully follow the instructions in the "R Installation and Adminstration" 11 | manual, in particular Section 6.3, and Appendix D "The Windows Toolset". 12 | We point out a couple of details worth extra attention. Please read on. 13 | 14 | Steps: 15 | ------ 16 | 17 | 1. Install the appropriate `Rtools` for your R for Windows version, 18 | e.g., `Rtools` 3.2 for R versions 3.1.x through 3.2.x (for full details 19 | see http://cran.r-project.org/bin/windows/Rtools). A couple of 20 | important details: 21 | 22 | * When installing `Rtools`, in the "Select Components" dialog box, 23 | you may select the default "Package authoring installation". 24 | 25 | * In the "Select Additional Tasks" dialog window, check the 26 | option "Edit the system PATH". This is important to be able to 27 | locate the C, Fortran compilers and other tools needed during 28 | the use of `RxODE`. 29 | 30 | * A simple way to test whether `Rtools` was properly installed is 31 | to compile the `hello.c` program. Simply open a new MSDOS command 32 | window, create a text file `hello.c` and compile it as follows: 33 | 34 | ``` 35 | C:\hello> type hello.c 36 | #include 37 | 38 | void main(int argc, char **argv) 39 | { 40 | printf("Hello World!\n"); 41 | } 42 | 43 | C:\hello> gcc -o hello hello.c 44 | 45 | C:\hello> .\hello 46 | Hello World! 47 | ``` 48 | 49 | If you get the error `gcc: error: CreateProcess: No such file or directory` then you know `Rtools` was not properly installed, in particular, 50 | it did not update your system `PATH` variable. 51 | 52 | 2. Obtain the `RxODE` package, either from github or CRAN. The 53 | installation requires use of the gcc compiler, so you'll know if Step 1 54 | was successfully executed. 55 | 56 | * CRAN. Use the usual method for installing pacakges from CRAN. 57 | 58 | * GitHub. First install the `devtools` package (if needed) and 59 | then `RxODE` from GitHub. You may want to avoid using a library 60 | folder that has spaces in its name (see question 4.1 in the 61 | "R for Windows FAQ" and the pointers therein). As of `RxODE` 62 | version 0.5-1, we've been able to test installations on folder with 63 | spaces in their name, but you may want to be on the safe side. 64 | 65 | ``` 66 | install.packages("devtools") 67 | library("devtools", lib = "C:/Rlib") 68 | install_github("hallowkm/RxODE/RxODE") 69 | ``` 70 | 71 | 3. Test the `RxODE` installation: 72 | 73 | ``` 74 | library("RxODE", lib = "C:/Rlib") 75 | demo("demo1","RxODE") 76 | ``` 77 | 78 | If the demo runs without error, click on the plot window and see if a 79 | new plot comes up each time. If so, `RxODE` has been installed correctly. 80 | 81 | See `browseVignettes("RxODE")` for an extended example on using 82 | `RxODE` for simulations. 83 | 84 | -------------------------------------------------------------------------------- /RxODE/src/dparser/python/contrib/dparserpy.el: -------------------------------------------------------------------------------- 1 | ;;; dparserpy.el --- support for working with DParser for Python 2 | ;;; 3 | ;;; Author: Yves Forkl 4 | ;;; Keywords: parser, grammar, syntax 5 | ;;; Version: 0.1 (2004.04.27) 6 | 7 | ;; Copyright (C) 2004 Yves Forkl 8 | 9 | ;; This file is not currently part of GNU Emacs. 10 | 11 | ;; This program is free software; you can redistribute it and/or 12 | ;; modify it under the terms of the GNU General Public License as 13 | ;; published by the Free Software Foundation; either version 2, or (at 14 | ;; your option) any later version. 15 | 16 | ;; This program is distributed in the hope that it will be useful, but 17 | ;; WITHOUT ANY WARRANTY; without even the implied warranty of 18 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 | ;; General Public License for more details. 20 | 21 | ;; You should have received a copy of the GNU General Public License 22 | ;; along with this program ; see the file COPYING. If not, write to 23 | ;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 24 | ;; Boston, MA 02111-1307, USA. 25 | 26 | ;;; Commentary: 27 | 28 | ;; This package tries to provide some support for developing and 29 | ;; running parsers using DParser for Python [1] by Brian Sabbey, a 30 | ;; Python interface to DParser [2] by John Plevyak. 31 | 32 | ;; Code in this package directly relates to DParser for Python, while 33 | ;; general Emacs Lisp code for DParser should be found in dparser.el. 34 | 35 | ;; [1] see http://staff.washington.edu/sabbey/py_dparser/ 36 | ;; [2] see http://dparser.sourceforge.net/ 37 | 38 | ;; Send suggestions, bug reports etc. to the package maintainer: 39 | ;; 40 | 41 | ;;; Change Log: 42 | 43 | ;; V. 0.1 initial release 44 | 45 | ;;; Code: 46 | 47 | (defun dparserpy-goto-trouble-spot () 48 | "Visit place in input file that caused a DParser for Python syntax error. 49 | 50 | Call this function from within the custom syntax error message looking 51 | like this: 52 | 53 | ------------------------------------------------------------------------------- 54 | File /path/to/inputfile: 55 | 56 | [...] text preceding the error ____________ 57 | /syntax error at line X (buffer pos. Y) 58 | ERROR SPOT and more text [...] 59 | ------------------------------------------------------------------------------- 60 | 61 | This will show the input file in an another window and move Point to 62 | the trouble spot." 63 | (interactive) 64 | (let ((startpos (point)) 65 | (startwindow (get-buffer-window (current-buffer)))) 66 | (search-backward (make-string 79 ?-)) 67 | (search-forward "\nFile ") 68 | (let ((filename (buffer-substring (point) (1- (point-at-eol)))) 69 | (pos 70 | (string-to-int 71 | (buffer-substring 72 | (re-search-forward 73 | "/syntax error at line [0-9]+ (buffer pos. ") 74 | (1- (point-at-eol)))))) 75 | (goto-char startpos) 76 | (find-file-other-window filename) 77 | (goto-char (1+ pos)) 78 | (recenter startwindow) 79 | (recenter)))) 80 | 81 | (require 'thingatpt) 82 | 83 | (defun dparserpy-insert-action-template () 84 | "Within DParser Python buffer, insert template for action name at Point." 85 | (interactive) 86 | (let ((bounds (bounds-of-thing-at-point 'word))) 87 | (if bounds 88 | (let* ((start (car bounds)) 89 | (end (cdr bounds)) 90 | (identifier (buffer-substring start end))) 91 | (kill-region start end) 92 | (insert "def d_" identifier "(t):\n" 93 | "\"\"\" " identifier " :\n" 94 | "\"\"\"\n") 95 | (beginning-of-line -1) 96 | (indent-according-to-mode) 97 | (beginning-of-line 2) 98 | (indent-according-to-mode) 99 | (beginning-of-line) 100 | (search-forward "\"\"\"") 101 | (backward-char 3) 102 | (insert " ") 103 | (backward-char 1))))) 104 | -------------------------------------------------------------------------------- /RxODE/src/dparser/parse.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2002-2004 John Plevyak, All Rights Reserved 3 | */ 4 | #ifndef _parse_H_ 5 | #define _parse_H_ 6 | 7 | #define NO_DPN ((D_ParseNode*)0x1) 8 | #define DPN_TO_PN(_dpn) \ 9 | ((PNode *)(((char*)dpn)-(intptr_t)(&((PNode*)0)->parse_node))) 10 | #define is_epsilon_PNode(_pn) \ 11 | ((_pn)->parse_node.start_loc.s == (_pn)->parse_node.end) 12 | 13 | /* #define TRACK_PNODES 1 */ 14 | 15 | struct PNode; 16 | struct SNode; 17 | struct ZNode; 18 | struct Parser; 19 | 20 | typedef Vec(struct ZNode*) VecZNode; 21 | typedef Vec(VecZNode *) VecVecZNode; 22 | typedef Vec(struct SNode*) VecSNode; 23 | typedef Vec(struct PNode*) VecPNode; 24 | 25 | typedef struct PNodeHash { 26 | struct PNode **v; 27 | uint i; /* size index (power of 2) */ 28 | uint m; /* max size (highest prime < i ** 2) */ 29 | uint n; /* size */ 30 | struct PNode *all; 31 | } PNodeHash; 32 | 33 | typedef struct SNodeHash { 34 | struct SNode **v; 35 | uint i; /* size index (power of 2) */ 36 | uint m; /* max size (highest prime < i ** 2) */ 37 | uint n; /* size */ 38 | struct SNode *all; 39 | struct SNode *last_all; 40 | } SNodeHash; 41 | 42 | typedef struct Reduction { 43 | struct ZNode *znode; 44 | struct SNode *snode; 45 | struct D_Reduction *reduction; 46 | struct SNode *new_snode; 47 | int new_depth; 48 | struct Reduction *next; 49 | } Reduction; 50 | 51 | typedef struct Shift { 52 | struct SNode *snode; 53 | struct Shift *next; 54 | } Shift; 55 | 56 | typedef struct Parser { 57 | D_Parser user; 58 | /* string to parse */ 59 | char *start, *end; 60 | struct D_ParserTables *t; 61 | /* statistics */ 62 | int states, pnodes, scans, shifts, reductions, compares, ambiguities; 63 | /* parser state */ 64 | PNodeHash pnode_hash; 65 | SNodeHash snode_hash; 66 | Reduction *reductions_todo; 67 | Shift *shifts_todo; 68 | D_Scope *top_scope; 69 | struct SNode *accept; 70 | int last_syntax_error_line; 71 | /* memory management */ 72 | Reduction *free_reductions; 73 | Shift *free_shifts; 74 | int live_pnodes; 75 | struct PNode *free_pnodes; 76 | struct SNode *free_snodes; 77 | struct ZNode *free_znodes; 78 | Vec(D_Reduction *) error_reductions; 79 | ShiftResult *shift_results; 80 | int nshift_results; 81 | D_Shift *code_shifts; 82 | int ncode_shifts; 83 | /* comments */ 84 | struct Parser *whitespace_parser; 85 | /* interface support */ 86 | void *pinterface1; 87 | #ifdef TRACK_PNODES 88 | struct PNode *xall; 89 | #endif 90 | } Parser; 91 | 92 | /* 93 | Parse Node - the 'symbol' and the constructed parse subtrees. 94 | */ 95 | typedef struct PNode { 96 | uint hash; 97 | AssocKind assoc; 98 | int priority; 99 | AssocKind op_assoc; 100 | int op_priority; 101 | D_Reduction *reduction; 102 | D_Shift *shift; 103 | #ifndef USE_GC 104 | uint32 refcount; 105 | #endif 106 | VecPNode children; 107 | uint height; /* max tree height */ 108 | uint8 evaluated; 109 | uint8 error_recovery; 110 | struct PNode *all_next; 111 | struct PNode *bucket_next; 112 | struct PNode *ambiguities; 113 | struct PNode *latest; /* latest version of this PNode */ 114 | char *ws_before; 115 | char *ws_after; 116 | D_Scope *initial_scope; 117 | void *initial_globals; 118 | D_ParseNode parse_node; /* public fields */ 119 | #ifdef TRACK_PNODES 120 | struct PNode *xnext; 121 | struct PNode *xprev; 122 | #endif 123 | } PNode; 124 | 125 | /* 126 | State Node - the 'state'. 127 | */ 128 | typedef struct SNode { 129 | D_State *state; 130 | D_Scope *initial_scope; 131 | void *initial_globals; 132 | d_loc_t loc; 133 | uint depth; /* max stack depth (less loops) */ 134 | PNode *last_pn; 135 | VecZNode zns; 136 | #ifndef USE_GC 137 | uint32 refcount; 138 | #endif 139 | struct SNode *bucket_next; 140 | struct SNode *all_next; 141 | } SNode; 142 | 143 | /* 144 | (Z)Symbol Node - holds one of the symbols associated with a state. 145 | */ 146 | typedef struct ZNode { 147 | PNode *pn; 148 | VecSNode sns; 149 | } ZNode; 150 | #define znode_next(_z) (*(ZNode**)&((_z)->pn)) 151 | 152 | D_ParseNode * ambiguity_count_fn(D_Parser *pp, int n, D_ParseNode **v); 153 | 154 | #endif 155 | -------------------------------------------------------------------------------- /RxODE/src/dparser/sample_parser.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2002-2004 John Plevyak, All Rights Reserved 3 | */ 4 | 5 | #include "d.h" 6 | 7 | #define SIZEOF_MY_PARSE_NODE 100 /* permit test cases up to this size */ 8 | 9 | extern D_ParserTables parser_tables_gram; 10 | 11 | int save_parse_tree = 1; 12 | int partial_parses = 0; 13 | int fixup = 1; 14 | int fixup_ebnf = 0; 15 | int compare_stacks = 1; 16 | int commit_actions_interval = 100; 17 | int start_state = 0; 18 | int dont_use_greediness_for_disambiguation = 0; 19 | int dont_use_height_for_disambiguation = 0; 20 | 21 | static void help(ArgumentState *arg_state, char *arg_unused); 22 | 23 | ArgumentDescription arg_desc[] = { 24 | {"start_state", 'S', "Start State", "I", &start_state, 25 | "D_PARSE_START_STATE", NULL}, 26 | {"save_parse_tree", 's', "Save Parse Tree", "T", &save_parse_tree, 27 | "D_PARSE_SAVE_PARSE_TREE", NULL}, 28 | {"partial_parses", 'p', "Partial Parses", "T", &partial_parses, 29 | "D_PARSE_PARTIAL_PARSES", NULL}, 30 | {"compare_stacks", 'c', "Compare Stacks", "T", &compare_stacks, 31 | "D_PARSE_COMPARE_STACKS", NULL}, 32 | {"commit_interval", 'i', "Commit Interval", "I", &commit_actions_interval, 33 | "D_PARSE_COMMIT_INTERVAL", NULL}, 34 | {"fixup", 'f', "Fixup Internal Productions", "T", &fixup, 35 | "D_PARSE_FIXUP", NULL}, 36 | {"fixup_ebnf", 'e', "Fixup EBNF Productions", "T", &fixup_ebnf, 37 | "D_PARSE_FIXUP_EBNF", NULL}, 38 | {"nogreedy", 'G', "No Greediness for Disambiguation", "T", 39 | &dont_use_greediness_for_disambiguation, "D_PARSE_GREEDY", NULL}, 40 | {"noheight", 'H', "No Height for Disambiguation", "T", 41 | &dont_use_height_for_disambiguation, "D_PARSE_HEIGHT", NULL}, 42 | {"verbose", 'v', "Verbose", "+", &d_verbose_level, 43 | "D_PARSE_VERBOSE", NULL}, 44 | {"test", 't', "Test", "+", &test_level, 45 | "D_PARSE_TEST", NULL}, 46 | {"debug", 'd', "Debug", "+", &d_debug_level, 47 | "D_PARSE_DEBUG", NULL}, 48 | {"help", 'h', "Help", NULL, NULL, 49 | NULL, help}, 50 | {0} 51 | }; 52 | 53 | ArgumentState arg_state = { 54 | 0, 0, 55 | "program", 56 | arg_desc 57 | }; 58 | 59 | static void 60 | help(ArgumentState *arg_state, char *arg_unused) { 61 | char ver[30]; 62 | d_version(ver); 63 | fprintf(stderr, "Sample DParser Version %s ", ver); 64 | fprintf(stderr, "Copyright (c) 2002-2013 John Plevyak\n"); 65 | usage(arg_state, arg_unused); 66 | } 67 | 68 | char *ops = "+"; 69 | void *ops_cache = NULL; 70 | int ops_scan(char *ops, void *ops_cache, d_loc_t *loc, 71 | unsigned char *op_assoc, int *op_priority) 72 | { 73 | if (loc->s[0] == '+') { 74 | loc->s++; 75 | *op_assoc = ASSOC_BINARY_LEFT; 76 | *op_priority = 9500; 77 | return 1; 78 | } 79 | return 0; 80 | } 81 | 82 | int 83 | main(int argc, char *argv[]) { 84 | int i, len = 0; 85 | char *buf = NULL, *fn; 86 | D_Parser *p; 87 | D_ParseNode *pn = NULL; 88 | 89 | process_args(&arg_state, argv); 90 | if (!arg_state.nfile_arguments) 91 | help(&arg_state, NULL); 92 | p = new_D_Parser(&parser_tables_gram, SIZEOF_MY_PARSE_NODE); 93 | p->save_parse_tree = save_parse_tree; 94 | p->ambiguity_fn = ambiguity_count_fn; 95 | p->partial_parses = partial_parses; 96 | p->dont_fixup_internal_productions = !fixup; 97 | p->fixup_EBNF_productions = fixup_ebnf; 98 | p->dont_compare_stacks = !compare_stacks; 99 | p->commit_actions_interval = commit_actions_interval; 100 | p->start_state = start_state; 101 | p->dont_use_greediness_for_disambiguation = dont_use_greediness_for_disambiguation; 102 | p->dont_use_height_for_disambiguation = dont_use_height_for_disambiguation; 103 | for (i = 0; i < arg_state.nfile_arguments; i++) { 104 | p->loc.pathname = arg_state.file_argument[i]; 105 | p->loc.line = 1; 106 | p->loc.col = 0; 107 | if (buf_read(arg_state.file_argument[i], &buf, &len) > 0) 108 | pn = dparse(p, buf, len); 109 | else 110 | d_fail("unable to read file '%s'", arg_state.file_argument[i]); 111 | if (pn) { 112 | free_D_ParseNode(p, pn); 113 | pn = 0; 114 | } else { 115 | fn = d_dup_pathname_str(p->loc.pathname); 116 | fprintf(stderr, "fatal error, '%s' line %d\n", fn, p->loc.line); 117 | FREE(fn); 118 | } 119 | if (buf) 120 | FREE(buf); 121 | } 122 | free_D_Parser(p); 123 | free_args(&arg_state); 124 | exit(0); 125 | } 126 | 127 | -------------------------------------------------------------------------------- /RxODE/src/dparser/make_dparser.1: -------------------------------------------------------------------------------- 1 | .TH make_dparser 1 "Mar 2003" Unix "User Manuals" 2 | .SH NAME 3 | .PP 4 | make_dparser \(hy D Parser Generator 5 | .SH SYNOPSIS 6 | .PP 7 | .B make_dparser 8 | [\fIoptions\fP] \fIgrammar\fP 9 | .SH DESCRIPTION 10 | .PP 11 | make_dparser is a scannerless GLR parser generator based on the Tomita 12 | algorithm. It is self-hosted and very easy to use. Grammars are written in a 13 | natural style of EBNF and regular expressions and support both speculative and 14 | final actions. 15 | .SH OPTIONS 16 | .PP 17 | .IP "\-l" 18 | Toggle longest match lexical ambiguity resolution. 19 | When ON the scanner only recognizing the longest matching tokens 20 | in a given state. This provides an easy way to build 21 | grammars for languages which use longest match lexical 22 | ambiguity resolution (e.g. ANSI-C, C++). (OFF by default) 23 | .IP "\-T" 24 | Toggle building of a tokenizer for START. When ON, instead of generating 25 | a unique scanner for each state (i.e. a 'scannerless' parser), 26 | generate a single scanner (tokenizer) for the entire grammar. This provides 27 | an easy way to build grammars for languages which assume a 28 | tokenizer (e.g. ANSI C). (OFF by default) 29 | .IP "\-H \fI\-1/0/1\fP" 30 | Write header, 0 : no, 1 : yes, \-1 : only if not empty. 31 | .IP "\-t \fI0/1\fP" 32 | Token type, 0 : #define, 1 : enum. 33 | .IP "\-C" 34 | Toggle computing whitespace states. If 'whitespace' is 35 | defined in the grammar, then use it as a subparser to 36 | consume whitespace. (ON by default) 37 | .IP "\-A" 38 | Toggle computing states for all non-terminals. Ensures that there is a unique 39 | state for each non-terminal so that a subparsers can be invoked for 40 | that non-terminal. (OFF by default) 41 | .IP "\-i \fItag\fP" 42 | Tag for grammar data structures so that multiple sets of tables can 43 | be included in one file/application. (defaults to 'gram') 44 | .IP "\-b \fIblocks\fP" 45 | Number of blocks to which scanner tables are broken up into. 46 | Larger numbers permit more sharing with more overhead. 4 seems to be optimal 47 | for most grammars. (defaults to 4) 48 | files. 49 | .IP "\-p" 50 | Toggle setting of operator priority from rules. Setting of operator 51 | priorities on operator tokens can increase the size of the tables but 52 | can permit unnecessary parse stacks to be pruned earlier. (OFF by default) 53 | .IP "\-r" 54 | Toggle use of right recursion for EBNF productions. Do not change this 55 | unless you really know what you are doing. (OFF by default) 56 | .IP "\-L" 57 | Toggle writing of line numbers. Used to debug the parsing table 58 | generator itself. (ON by default) 59 | .IP "\-X" 60 | Set the extension of the generated code file. For C++ programs (for example) 61 | the extension can be set to .cpp with the option "\-Xcpp". ("\-Xc" by default) 62 | .IP "\-v" 63 | Increase verbosity. 64 | .IP "\-R" 65 | Replace all actions in the grammar with actions printing productions, 66 | 1 : during the speculative parsing process (<\-), 67 | 2 : when reduction is part of any legal final parse (<=), 68 | 3 : both, 69 | 4 : remove all actions from the grammar. 70 | Print the changed grammar to stdout. 71 | Useful for debugging or prototyping new, experimental grammars. 72 | .IP "\-d" 73 | Increase debugging. 74 | .IP "\-h" 75 | Display help. 76 | .SH ENVIRONMENT 77 | .PP 78 | All the options are available through environment variables 79 | with the names: 80 | 81 | .na 82 | .nh 83 | D_MAKE_PARSER_HEADER, 84 | D_MAKE_PARSER_TOKEN, 85 | D_MAKE_PARSER_GRAMMAR_IDENT, 86 | D_MAKE_PARSER_SCANNER_BLOCKS, 87 | D_MAKE_PARSER_SET_PRIORITY, 88 | D_MAKE_PARSER_WRITE_LINE_DIRECTIVES, 89 | D_MAKE_RDEBUG_GRAMMAR, 90 | D_MAKE_PARSER_VERBOSE, 91 | D_MAKE_PARSER_DEBUG. 92 | .ad 93 | .hy 94 | .SH FEATURES 95 | .PP 96 | The features are covered in the documentation. See the README file. 97 | .SH FILES 98 | .PP 99 | None. 100 | .SH NO WARRANTIES 101 | This program is distributed in the hope that it will be useful, 102 | but WITHOUT ANY WARRANTY; without even the implied warranty of 103 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 104 | COPYRIGHT for more details. 105 | .SH SEE ALSO 106 | .PP 107 | .BR flex (1), 108 | .BR yacc (1), 109 | .BR bison (1) 110 | .PP 111 | D Parser Home Page: http://dparser.sourceforge.net/ 112 | .PP 113 | The BSD General Public License. 114 | .SH AUTHOR 115 | .PP 116 | John Plevyak. Use to contact. 117 | 118 | -------------------------------------------------------------------------------- /RxODE/src/dparser/util.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2002-2006 John Plevyak, All Rights Reserved 3 | */ 4 | 5 | #define INITIAL_SET_SIZE_INDEX 2 6 | 7 | #define INITIAL_VEC_SHIFT 3 8 | #define INITIAL_VEC_SIZE (1 << INITIAL_VEC_SHIFT) 9 | #define INITIAL_VEC_SIZE (1 << INITIAL_VEC_SHIFT) 10 | #define INTEGRAL_VEC_SIZE 3 11 | #define INTEGRAL_STACK_SIZE 8 12 | #define TRICK_VEC_SIZE (INITIAL_VEC_SIZE - INTEGRAL_VEC_ELEMENTS) 13 | 14 | #define SET_MAX_SEQUENTIAL 5 15 | 16 | #define IS_BIT_SET(_v, _s) ((_v)[(_s) / 8] & 1 << ((_s) % 8)) 17 | #define SET_BIT(_v, _s) (_v)[(_s) / 8] |= (1 << ((_s) %8)) 18 | 19 | typedef struct AbstractVec { 20 | uint n; 21 | uint i; /* size index for use with sets */ 22 | void **v; 23 | void *e[INTEGRAL_VEC_SIZE]; 24 | } AbstractVec; 25 | #define Vec(_x) struct { \ 26 | uint n; \ 27 | uint i; \ 28 | _x *v; \ 29 | _x e[INTEGRAL_VEC_SIZE]; \ 30 | } 31 | 32 | typedef struct AbstractStack { 33 | void **start; 34 | void **end; 35 | void **cur; 36 | void *initial[INTEGRAL_STACK_SIZE]; 37 | } AbstractStack; 38 | #define Stack(_x) struct { \ 39 | _x *start; _x *end; _x *cur; _x initial[INTEGRAL_STACK_SIZE]; \ 40 | } 41 | 42 | #define vec_move(_a, _b) do { \ 43 | (_a)->n = (_b)->n; \ 44 | if ((_b)->v == (_b)->e) { \ 45 | memcpy(&(_a)->e[0], &(_b)->e[0], sizeof((_a)->e)); \ 46 | (_a)->v = (_a)->e; \ 47 | } else (_a)->v = (_b)->v; \ 48 | vec_clear(_b); \ 49 | } while (0) 50 | 51 | struct hash_fns_t; 52 | typedef uint32 (*hash_fn_t)(void *, struct hash_fns_t*); 53 | typedef int (*cmp_fn_t)(void *, void *, struct hash_fns_t*); 54 | typedef struct hash_fns_t { 55 | hash_fn_t hash_fn; 56 | cmp_fn_t cmp_fn; 57 | void *data[2]; 58 | } hash_fns_t; 59 | 60 | #define vec_add(_v, _i) do { \ 61 | if (!(_v)->v) { \ 62 | ((_v)->v = (_v)->e)[(_v)->n++] = (_i); \ 63 | break; \ 64 | } else if ((_v)->v == ((_v)->e)) { \ 65 | if (((_v)->n < INTEGRAL_VEC_SIZE)) { \ 66 | (_v)->v[(_v)->n++] = (_i); \ 67 | break; \ 68 | } \ 69 | } else if ((_v)->n & (INITIAL_VEC_SIZE - 1)) { \ 70 | (_v)->v[(_v)->n++] = (_i); \ 71 | break; \ 72 | } \ 73 | vec_add_internal((_v), _i); \ 74 | } while (0) 75 | void vec_add_internal(void *v, void *elem); 76 | int vec_eq(void *v, void *vv); 77 | int set_find(void *v, void *t); 78 | int set_add(void *v, void *t); 79 | int set_union(void *v, void *vv); 80 | void *set_add_fn(void *v, void *t, hash_fns_t *fns); 81 | void set_union_fn(void *v, void *vv, hash_fns_t *fns); 82 | void set_to_vec(void *av); 83 | #define vec_clear(_v) do { (_v)->n = 0; (_v)->v = 0; } while(0) 84 | #define vec_free(_v) do { \ 85 | if ((_v)->v && (_v)->v != (_v)->e) FREE((_v)->v); vec_clear(_v); } while(0) 86 | 87 | #define stack_clear(_s) do { \ 88 | (_s)->start = (_s)->cur = (_s)->end = (_s)->initial; \ 89 | (_s)->end += INTEGRAL_STACK_SIZE; \ 90 | } \ 91 | while(0) 92 | #define stack_free(_s) do { \ 93 | if ((_s)->start != (_s)->initial) FREE((_s)->start); \ 94 | stack_clear(_s); \ 95 | } while(0) 96 | #define stack_head(_s) ((_s)->cur[-1]) 97 | #define is_stack_empty(_s) ((_s)->cur == (_s)->start) 98 | #define stack_empty(_s) ((_s)->cur = (_s)->start) 99 | #define stack_depth(_s) ((_s)->cur - (_s)->start) 100 | #define stack_pop(_s) (*--((_s)->cur)) 101 | #define stack_push(_s, _x) do { if ((_s)->cur == (_s)->end ) \ 102 | stack_push_internal((AbstractStack*)((_s)), (void*)(uintptr_t)(_x)); else \ 103 | (*((_s)->cur)++ = (_x)); } while(0) 104 | void * stack_push_internal(AbstractStack*, void*); 105 | 106 | int buf_read(const char *pathname, char **buf, int *len); 107 | char *sbuf_read(const char *pathname); 108 | 109 | #define STREQ(_x,_n,_s) \ 110 | ((_n == sizeof(_s)-1) && !strncasecmp(_x,_s,sizeof(_s)-1)) 111 | 112 | void d_fail(const char *str, ...); 113 | void d_warn(const char *str, ...); 114 | char *dup_str(const char *str, const char *end); 115 | uint strhashl(const char *s, int len); 116 | void d_free(void *); 117 | 118 | void int_list_diff(int *a, int *b, int *c); 119 | void int_list_intersect(int *a, int *b, int *c); 120 | int *int_list_dup(int *aa); 121 | 122 | char *escape_string(char *s); 123 | char *escape_string_single_quote(char *s); 124 | 125 | extern uint d_prime2[]; 126 | extern int d_verbose_level; 127 | extern int d_debug_level; 128 | extern int test_level; 129 | extern int d_rdebug_grammar_level; 130 | 131 | -------------------------------------------------------------------------------- /RxODE/src/dparser/sample.g: -------------------------------------------------------------------------------- 1 | /* 2 | Sample Grammar 3 | */ 4 | 5 | { 6 | #include "d.h" 7 | } 8 | 9 | ${declare longest_match program} 10 | 11 | program : statement*; 12 | 13 | statement : external | definition | expression ';' ; 14 | 15 | definition : identifier ':' expression ';' 16 | { 17 | D_Sym *s; 18 | char *ts = dup_str($n0.start_loc.s, $n0.end); 19 | ${scope} = new_D_Scope(${scope}); 20 | s = NEW_D_SYM(${scope}, $n0.start_loc.s, $n0.end); 21 | printf("def Sym '%s' line %d: %X\n", ts, $n0.start_loc.line, (int)(uintptr_t)s); 22 | d_free(ts); 23 | $$ = s; 24 | }; 25 | 26 | external 27 | : 'extern' external_type identifier ';' 28 | | 'extern' external_type identifier 29 | '(' (external_type (',' external_type)*)? ')' ';' 30 | ; 31 | 32 | external_type : builtin_types; 33 | 34 | expression 35 | : constant 36 | | identifier { 37 | D_Sym *s = find_D_Sym(${scope}, $n0.start_loc.s, $n0.end); 38 | char *ts = dup_str($n0.start_loc.s, $n0.end); 39 | if (s) 40 | printf("ref Sym '%s' line %d val %d: %X of %X\n", 41 | ts, $n0.start_loc.line, 42 | s->user, (int)(uintptr_t)s, (int)(uintptr_t)s->update_of); 43 | else 44 | printf("ref Sym '%s' line %d: not found\n", 45 | ts, $n0.start_loc.line); 46 | d_free(ts); 47 | } 48 | | pre_operator expression 49 | | expression post_operator 50 | | expression binary_operator expression 51 | | '{' expression '}' 52 | | '(' expression ')' 53 | | '[' expression ']' 54 | | expression '?' expression ':' expression $right 8600 55 | | 'if' '(' expression ')' expression $right 6000 56 | | 'if' '(' expression ')' expression 'else' expression $right 6100 57 | | 'while' '(' expression ')' expression $right 6200 58 | | 'do' expression 'while' expression $right 6300 59 | | 'for' '(' expression (';' expression (';' expression)?)? ')' 60 | expression $right 6400 61 | ; 62 | 63 | constant : integer | float | character | strings; 64 | 65 | strings : string+; 66 | 67 | binary_operator 68 | : '::' $binary_op_right 10000 69 | | '.' $binary_op_left 9900 70 | | '->' $binary_op_left 9900 71 | | '*' $binary_op_left 9600 72 | | '/' $binary_op_left 9600 73 | | '%' $binary_op_left 9600 74 | | '+' $binary_op_left 9500 75 | | '-' $binary_op_left 9500 76 | | '<<' $binary_op_left 9400 77 | | '>>' $binary_op_left 9400 78 | | '<' $binary_op_left 9300 79 | | '<=' $binary_op_left 9300 80 | | '>' $binary_op_left 9300 81 | | '>=' $binary_op_left 9300 82 | | '==' $binary_op_left 9200 83 | | '!=' $binary_op_left 9200 84 | | '&' $binary_op_left 9100 85 | | '^' $binary_op_left 9000 86 | | '|' $binary_op_left 8900 87 | | '&&' $binary_op_left 8800 88 | | '||' $binary_op_left 8700 89 | | '=' $binary_op_left 8500 90 | | '*=' $binary_op_left 8500 91 | | '/=' $binary_op_left 8500 92 | | '%=' $binary_op_left 8500 93 | | '+=' $binary_op_left 8500 94 | | '-=' $binary_op_left 8500 95 | | '<<=' $binary_op_left 8500 96 | | '>>=' $binary_op_left 8500 97 | | '&=' $binary_op_left 8500 98 | | '|=' $binary_op_left 8500 99 | | '^=' $binary_op_left 8500 100 | | ',' $binary_op_left 8400 101 | | $binary_op_left 7000 102 | ; 103 | 104 | pre_operator 105 | : '::' $unary_op_right 10000 106 | | '--' $unary_op_right 9800 107 | | '++' $unary_op_right 9800 108 | | '-' $unary_op_right 8600 109 | | '+' $unary_op_right 8600 110 | | '~' $unary_op_right 8600 111 | | '!' $unary_op_right 8600 112 | | '*' $unary_op_right 8600 113 | | '&' $unary_op_right 8600 114 | | '(' external_type ')' $unary_op_right 8600 115 | | 'sizeof' $unary_op_right 8600 116 | ; 117 | 118 | post_operator 119 | : '--' $unary_op_left 9700 120 | | '++' $unary_op_left 9700 121 | | '{' expression '}' $unary_op_left 9700 122 | | '(' expression ')' $unary_op_left 9700 123 | | '[' expression ']' $unary_op_left 9700 124 | ; 125 | 126 | builtin_types 127 | : 'int' 128 | | 'uint' 129 | | 'int8' 130 | | 'uint8' 131 | | 'int16' 132 | | 'uint16' 133 | | 'int32' 134 | | 'uint32' 135 | | 'int64' 136 | | 'uint64' 137 | | 'float' 138 | | 'float32' 139 | | 'float64' 140 | ; 141 | 142 | character: "'[^']*'"; 143 | string: "\"[^\"]*\""; 144 | integer: "-?([0-9]|0(x|X))[0-9]*(u|U|b|B|w|W|L|l)*" $term -1; 145 | float: "[\-+]?([0-9]+\.[0-9]*|\.[0-9]+)([eE][\-+]?[0-9]+)?" $term -2; 146 | 147 | { 148 | char *reserved_words[] = { "if", "else", "extern", "sizeof", "int", "uint", 149 | "int8", "uint8", "int16", "uint16", "int32", "uint32", "int64", "uint64", 150 | "float", "float32", "float64", NULL }; 151 | 152 | static int is_one_of(char *s, char **list) { 153 | while (*list) { if (!strcmp(s, *list)) return 1; list++; } 154 | return 0; 155 | } 156 | } 157 | identifier: "[a-zA-Z_][a-zA-Z_0-9]*" $term -3 [ 158 | char *ts = dup_str($n0.start_loc.s, $n0.end); 159 | if (is_one_of(ts, reserved_words)) { 160 | d_free(ts); 161 | ${reject}; 162 | } 163 | d_free(ts); 164 | ]; 165 | 166 | 167 | 168 | -------------------------------------------------------------------------------- /RxODE/src/dparser/dparse_tables.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2002-2004 John Plevyak, All Rights Reserved 3 | */ 4 | #ifndef _dparse_tables_H_ 5 | #define _dparse_tables_H_ 6 | 7 | #define SCANNER_BLOCKS_POW2 2 8 | #define SCANNER_BLOCKS (1 << SCANNER_BLOCKS_POW2) 9 | #define SCANNER_BLOCK_SHIFT (8 - SCANNER_BLOCKS_POW2) 10 | #define SCANNER_BLOCK_MASK ((1 << SCANNER_BLOCK_SHIFT) - 1) 11 | #define SCANNER_BLOCK_SIZE (256 / SCANNER_BLOCKS) 12 | 13 | struct D_Parser; 14 | struct D_ShiftTable; 15 | 16 | #define D_PN(_x, _o) ((D_ParseNode*)((char*)(_x) + _o)) 17 | 18 | typedef struct d_loc_t { 19 | char *s, *pathname, *ws; 20 | int col, line; 21 | } d_loc_t; 22 | 23 | typedef void (*D_WhiteSpaceFn)(struct D_Parser *p, 24 | d_loc_t *loc, void **p_globals); 25 | typedef int (*D_ScanCode)( 26 | d_loc_t *loc, unsigned short *symbol, 27 | int *term_priority, unsigned char *op_assoc, int *op_priority); 28 | typedef int (*D_ReductionCode)( 29 | void *new_ps, void **children, int n_children, int pn_offset, 30 | struct D_Parser *parser); 31 | 32 | typedef struct D_Reduction { 33 | unsigned short nelements; 34 | unsigned short symbol; 35 | D_ReductionCode speculative_code; 36 | D_ReductionCode final_code; 37 | unsigned short op_assoc; 38 | unsigned short rule_assoc; 39 | int op_priority; 40 | int rule_priority; 41 | int action_index; 42 | int npass_code; 43 | D_ReductionCode *pass_code; 44 | } D_Reduction; 45 | 46 | typedef struct D_RightEpsilonHint { 47 | unsigned short depth; 48 | unsigned short preceeding_state; 49 | D_Reduction *reduction; 50 | } D_RightEpsilonHint; 51 | 52 | typedef struct D_ErrorRecoveryHint { 53 | unsigned short depth; 54 | unsigned short symbol; 55 | const char *string; 56 | } D_ErrorRecoveryHint; 57 | 58 | typedef struct D_Shift { 59 | unsigned short symbol; 60 | unsigned char shift_kind; 61 | unsigned char op_assoc; 62 | int op_priority; 63 | int term_priority; 64 | int action_index; 65 | D_ReductionCode speculative_code; 66 | } D_Shift; 67 | 68 | typedef struct SB_uint8 { 69 | D_Shift **shift; 70 | unsigned char *scanner_block[SCANNER_BLOCKS]; 71 | } SB_uint8; 72 | 73 | typedef struct SB_uint16 { 74 | D_Shift **shift; 75 | unsigned short *scanner_block[SCANNER_BLOCKS]; 76 | } SB_uint16; 77 | 78 | typedef struct SB_uint32 { 79 | D_Shift **shift; 80 | unsigned int *scanner_block[SCANNER_BLOCKS]; 81 | } SB_uint32; 82 | 83 | typedef struct SB_trans_uint8 { 84 | unsigned char *scanner_block[SCANNER_BLOCKS]; 85 | } SB_trans_uint8; 86 | 87 | typedef struct SB_trans_uint16 { 88 | unsigned short *scanner_block[SCANNER_BLOCKS]; 89 | } SB_trans_uint16; 90 | 91 | typedef struct SB_trans_uint32 { 92 | unsigned int *scanner_block[SCANNER_BLOCKS]; 93 | } SB_trans_uint32; 94 | 95 | #define D_SCAN_ALL 0 96 | #define D_SCAN_LONGEST 1 97 | #define D_SCAN_MIXED 2 98 | #define D_SCAN_TRAILING 3 99 | #define D_SCAN_RESERVED 4 100 | #define D_SCAN_DEFAULT D_SCAN_ALL 101 | 102 | typedef struct D_State { 103 | unsigned char *goto_valid; 104 | int goto_table_offset; 105 | struct { 106 | unsigned int n; 107 | D_Reduction **v; 108 | } reductions; 109 | struct { 110 | unsigned int n; 111 | D_RightEpsilonHint *v; 112 | } right_epsilon_hints; 113 | struct { 114 | unsigned int n; 115 | D_ErrorRecoveryHint *v; 116 | } error_recovery_hints; 117 | int shifts; 118 | D_ScanCode scanner_code; 119 | void* scanner_table; 120 | unsigned char scanner_size; 121 | unsigned char accept; 122 | unsigned char scan_kind; 123 | void* transition_table; 124 | D_Shift ***accepts_diff; 125 | int reduces_to; 126 | } D_State; 127 | 128 | #define D_SHIFTS_CODE ((D_Shift**)-1) 129 | 130 | #define D_SYMBOL_NTERM 1 131 | #define D_SYMBOL_INTERNAL 2 132 | #define D_SYMBOL_EBNF 3 133 | #define D_SYMBOL_STRING 4 134 | #define D_SYMBOL_REGEX 5 135 | #define D_SYMBOL_CODE 6 136 | #define D_SYMBOL_TOKEN 7 137 | typedef struct D_Symbol { 138 | unsigned int kind; 139 | const char *name; 140 | int name_len; 141 | int start_symbol; 142 | } D_Symbol; 143 | 144 | #define D_PASS_PRE_ORDER 0x0001 145 | #define D_PASS_POST_ORDER 0x0002 146 | #define D_PASS_MANUAL 0x0004 147 | #define D_PASS_FOR_ALL 0x0008 148 | #define D_PASS_FOR_UNDEFINED 0x0010 149 | typedef struct D_Pass { 150 | char *name; 151 | unsigned int name_len; 152 | unsigned int kind; 153 | unsigned int index; 154 | } D_Pass; 155 | 156 | typedef struct D_ParserTables { 157 | unsigned int nstates; 158 | D_State *state; 159 | unsigned short *goto_table; 160 | unsigned int whitespace_state; 161 | unsigned int nsymbols; 162 | D_Symbol *symbols; 163 | D_WhiteSpaceFn default_white_space; 164 | unsigned int npasses; 165 | D_Pass *passes; 166 | unsigned int save_parse_tree; 167 | } D_ParserTables; 168 | 169 | void parse_whitespace(struct D_Parser *p, d_loc_t *loc, void **p_globals); 170 | 171 | #endif 172 | -------------------------------------------------------------------------------- /RxODE/src/dparser/tests/sample.test.g: -------------------------------------------------------------------------------- 1 | /* 2 | Sample Grammar 3 | */ 4 | 5 | { 6 | #include "d.h" 7 | } 8 | 9 | ${declare longest_match program} 10 | 11 | program : statement*; 12 | 13 | statement : external | definition | expression ';' ; 14 | 15 | definition : identifier ':' expression ';' 16 | { 17 | D_Sym *s; 18 | char *ts = dup_str($n0.start_loc.s, $n0.end); 19 | ${scope} = new_D_Scope(${scope}); 20 | s = NEW_D_SYM(${scope}, $n0.start_loc.s, $n0.end); 21 | printf("def Sym '%s' line %d: %X\n", ts, $n0.start_loc.line, (int)(uintptr_t)s); 22 | d_free(ts); 23 | $$ = s; 24 | }; 25 | 26 | external 27 | : 'extern' external_type identifier ';' 28 | | 'extern' external_type identifier 29 | '(' (external_type (',' external_type)*)? ')' ';' 30 | ; 31 | 32 | external_type : builtin_types; 33 | 34 | expression 35 | : constant 36 | | identifier { 37 | D_Sym *s = find_D_Sym(${scope}, $n0.start_loc.s, $n0.end); 38 | char *ts = dup_str($n0.start_loc.s, $n0.end); 39 | if (s) 40 | printf("ref Sym '%s' line %d val %d: %X of %X\n", 41 | ts, $n0.start_loc.line, 42 | s->user, (int)(uintptr_t)s, (int)(uintptr_t)s->update_of); 43 | else 44 | printf("ref Sym '%s' line %d: not found\n", 45 | ts, $n0.start_loc.line); 46 | d_free(ts); 47 | } 48 | | pre_operator expression 49 | | expression post_operator 50 | | expression binary_operator expression 51 | | '{' expression '}' 52 | | '(' expression ')' 53 | | '[' expression ']' 54 | | expression '?' expression ':' expression $right 8600 55 | | 'if' '(' expression ')' expression $right 6000 56 | | 'if' '(' expression ')' expression 'else' expression $right 6100 57 | | 'while' '(' expression ')' expression $right 6200 58 | | 'do' expression 'while' expression $right 6300 59 | | 'for' '(' expression (';' expression (';' expression)?)? ')' 60 | expression $right 6400 61 | ; 62 | 63 | constant : integer | float | character | strings; 64 | 65 | strings : string+; 66 | 67 | binary_operator 68 | : '::' $binary_op_right 10000 69 | | '.' $binary_op_left 9900 70 | | '->' $binary_op_left 9900 71 | | '*' $binary_op_left 9600 72 | | '/' $binary_op_left 9600 73 | | '%' $binary_op_left 9600 74 | | '+' $binary_op_left 9500 75 | | '-' $binary_op_left 9500 76 | | '<<' $binary_op_left 9400 77 | | '>>' $binary_op_left 9400 78 | | '<' $binary_op_left 9300 79 | | '<=' $binary_op_left 9300 80 | | '>' $binary_op_left 9300 81 | | '>=' $binary_op_left 9300 82 | | '==' $binary_op_left 9200 83 | | '!=' $binary_op_left 9200 84 | | '&' $binary_op_left 9100 85 | | '^' $binary_op_left 9000 86 | | '|' $binary_op_left 8900 87 | | '&&' $binary_op_left 8800 88 | | '||' $binary_op_left 8700 89 | | '=' $binary_op_left 8500 90 | | '*=' $binary_op_left 8500 91 | | '/=' $binary_op_left 8500 92 | | '%=' $binary_op_left 8500 93 | | '+=' $binary_op_left 8500 94 | | '-=' $binary_op_left 8500 95 | | '<<=' $binary_op_left 8500 96 | | '>>=' $binary_op_left 8500 97 | | '&=' $binary_op_left 8500 98 | | '|=' $binary_op_left 8500 99 | | '^=' $binary_op_left 8500 100 | | ',' $binary_op_left 8400 101 | | $binary_op_left 7000 102 | ; 103 | 104 | pre_operator 105 | : '::' $unary_op_right 10000 106 | | '--' $unary_op_right 9800 107 | | '++' $unary_op_right 9800 108 | | '-' $unary_op_right 8600 109 | | '+' $unary_op_right 8600 110 | | '~' $unary_op_right 8600 111 | | '!' $unary_op_right 8600 112 | | '*' $unary_op_right 8600 113 | | '&' $unary_op_right 8600 114 | | '(' external_type ')' $unary_op_right 8600 115 | | 'sizeof' $unary_op_right 8600 116 | ; 117 | 118 | post_operator 119 | : '--' $unary_op_left 9700 120 | | '++' $unary_op_left 9700 121 | | '{' expression '}' $unary_op_left 9700 122 | | '(' expression ')' $unary_op_left 9700 123 | | '[' expression ']' $unary_op_left 9700 124 | ; 125 | 126 | builtin_types 127 | : 'int' 128 | | 'uint' 129 | | 'int8' 130 | | 'uint8' 131 | | 'int16' 132 | | 'uint16' 133 | | 'int32' 134 | | 'uint32' 135 | | 'int64' 136 | | 'uint64' 137 | | 'float' 138 | | 'float32' 139 | | 'float64' 140 | ; 141 | 142 | character: "'[^']*'"; 143 | string: "\"[^\"]*\""; 144 | integer: "-?([0-9]|0(x|X))[0-9]*(u|U|b|B|w|W|L|l)*" $term -1; 145 | float: "[\-+]?([0-9]+\.[0-9]*|\.[0-9]+)([eE][\-+]?[0-9]+)?" $term -2; 146 | 147 | { 148 | char *reserved_words[] = { "if", "else", "extern", "sizeof", "int", "uint", 149 | "int8", "uint8", "int16", "uint16", "int32", "uint32", "int64", "uint64", 150 | "float", "float32", "float64", NULL }; 151 | 152 | static int is_one_of(char *s, char **list) { 153 | while (*list) { if (!strcmp(s, *list)) return 1; list++; } 154 | return 0; 155 | } 156 | } 157 | identifier: "[a-zA-Z_][a-zA-Z_0-9]*" $term -3 [ 158 | char *ts = dup_str($n0.start_loc.s, $n0.end); 159 | if (is_one_of(ts, reserved_words)) { 160 | d_free(ts); 161 | ${reject}; 162 | } 163 | d_free(ts); 164 | ]; 165 | 166 | 167 | 168 | --------------------------------------------------------------------------------