🎉 initiate project *astro_rewrite*
This commit is contained in:
parent
ffd4d5e86c
commit
2ba37bfbe3
8658 changed files with 2268794 additions and 2538 deletions
61
node_modules/shiki/samples/jison.sample
generated
vendored
Normal file
61
node_modules/shiki/samples/jison.sample
generated
vendored
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
/* description: Parses end executes mathematical expressions. */
|
||||
|
||||
/* lexical grammar */
|
||||
%lex
|
||||
|
||||
%%
|
||||
\s+ /* skip whitespace */
|
||||
[0-9]+("."[0-9]+)?\b return 'NUMBER';
|
||||
"*" return '*';
|
||||
"/" return '/';
|
||||
"-" return '-';
|
||||
"+" return '+';
|
||||
"^" return '^';
|
||||
"(" return '(';
|
||||
")" return ')';
|
||||
"PI" return 'PI';
|
||||
"E" return 'E';
|
||||
<<EOF>> return 'EOF';
|
||||
|
||||
/lex
|
||||
|
||||
/* operator associations and precedence */
|
||||
|
||||
%left '+' '-'
|
||||
%left '*' '/'
|
||||
%left '^'
|
||||
%left UMINUS
|
||||
|
||||
%start expressions
|
||||
|
||||
%% /* language grammar */
|
||||
|
||||
expressions
|
||||
: e EOF
|
||||
{print($1); return $1;}
|
||||
;
|
||||
|
||||
e
|
||||
: e '+' e
|
||||
{$$ = $1+$3;}
|
||||
| e '-' e
|
||||
{$$ = $1-$3;}
|
||||
| e '*' e
|
||||
{$$ = $1*$3;}
|
||||
| e '/' e
|
||||
{$$ = $1/$3;}
|
||||
| e '^' e
|
||||
{$$ = Math.pow($1, $3);}
|
||||
| '-' e %prec UMINUS
|
||||
{$$ = -$2;}
|
||||
| '(' e ')'
|
||||
{$$ = $2;}
|
||||
| NUMBER
|
||||
{$$ = Number(yytext);}
|
||||
| E
|
||||
{$$ = Math.E;}
|
||||
| PI
|
||||
{$$ = Math.PI;}
|
||||
;
|
||||
|
||||
/* From https://gerhobbelt.github.io/jison/docs/#specifying-a-language */
|
||||
Loading…
Add table
Add a link
Reference in a new issue