PluginProbe
Code Block Pro – Beautiful Syntax Highlighting / 1.13.0
Code Block Pro – Beautiful Syntax Highlighting v1.13.0
1.27.1 1.27.2 1.27.3 1.27.4 1.27.5 1.27.6 1.27.7 1.28.0 1.3.0 1.4.0 1.5.0 1.5.1 1.5.2 1.6.0 1.7.0 1.8.0 1.9.0 1.9.1 1.9.2 1.9.3 trunk 1.1.0 1.10.0 1.11.0 1.11.1 All 63 releases
code-block-pro / build / shiki / samples / jison.sample

jison.sample in Code Block Pro – Beautiful Syntax Highlighting 1.13.0, at build/shiki/samples/jison.sample

61 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /* description: Parses end executes mathematical expressions. */
2
3 /* lexical grammar */
4 %lex
5
6 %%
7 \s+ /* skip whitespace */
8 [0-9]+("."[0-9]+)?\b return 'NUMBER';
9 "*" return '*';
10 "/" return '/';
11 "-" return '-';
12 "+" return '+';
13 "^" return '^';
14 "(" return '(';
15 ")" return ')';
16 "PI" return 'PI';
17 "E" return 'E';
18 <<EOF>> return 'EOF';
19
20 /lex
21
22 /* operator associations and precedence */
23
24 %left '+' '-'
25 %left '*' '/'
26 %left '^'
27 %left UMINUS
28
29 %start expressions
30
31 %% /* language grammar */
32
33 expressions
34 : e EOF
35 {print($1); return $1;}
36 ;
37
38 e
39 : e '+' e
40 {$$ = $1+$3;}
41 | e '-' e
42 {$$ = $1-$3;}
43 | e '*' e
44 {$$ = $1*$3;}
45 | e '/' e
46 {$$ = $1/$3;}
47 | e '^' e
48 {$$ = Math.pow($1, $3);}
49 | '-' e %prec UMINUS
50 {$$ = -$2;}
51 | '(' e ')'
52 {$$ = $2;}
53 | NUMBER
54 {$$ = Number(yytext);}
55 | E
56 {$$ = Math.E;}
57 | PI
58 {$$ = Math.PI;}
59 ;
60
61 /* From https://gerhobbelt.github.io/jison/docs/#specifying-a-language */