khei4 / sym_diff

symbolic differentiation optimizer
MIT License
1 stars 0 forks source link

数式の定義, Parse #2

Closed khei4 closed 3 years ago

khei4 commented 3 years ago

似たような多項式のを書いたから多分一瞬

expr := term, ( ( '+' | '-' ),  term)*;
term := factor ( ( '*' | '/' ),  factor)*;
factor := unary ( '^' unary )*;
unary := ( '+' | '-' )* ( func | primary );
func := "cos" '(' expr ')' | "sin" '(' expr ')' | "tan" '(' expr ')' | "log" '(' expr ')' | "exp" '(' expr ')';
primary :=  number | var | '(' expr ')' ;
number := ( "1" | "2" | ... | "9" ) digit*;
var := letter ( letter | digit )*;
letter = ("a" | "b" | ... | "z" | "A" | ... | "Z");
digit = "0" | "1" | "2" | ... | "9";
khei4 commented 3 years ago

結局変数は出現するのを管理する必要ありそうね

khei4 commented 3 years ago

テストを書く