Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1378)

Side by Side Diff: packages/petitparser/lib/lisp.dart

Issue 2989763002: Update charted to 0.4.8 and roll (Closed)
Patch Set: Removed Cutch from list of reviewers Created 3 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « packages/petitparser/lib/json.dart ('k') | packages/petitparser/lib/petitparser.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /// This package contains a simple grammar and evaluator for LISP.
2 ///
3 /// The code is reasonably complete to run and evaluate reasonably complex
4 /// programs from the console and from the web browser.
5 library petitparser.lisp;
6
7 import 'dart:collection';
8 import 'petitparser.dart';
9
10 part 'src/lisp/cons.dart';
11 part 'src/lisp/environment.dart';
12 part 'src/lisp/grammar.dart';
13 part 'src/lisp/name.dart';
14 part 'src/lisp/natives.dart';
15 part 'src/lisp/parser.dart';
16 part 'src/lisp/standard.dart';
17
18 /// The standard lisp parser definition.
19 final lispParser = new LispParser();
20
21 /// The evaluation function.
22 eval(Environment env, expr) {
23 if (expr is Cons) {
24 return eval(env, expr.head)(env, expr.tail);
25 } else if (expr is Name) {
26 return env[expr];
27 } else {
28 return expr;
29 }
30 }
31
32 /// Evaluate a cons of instructions.
33 evalList(Environment env, expr) {
34 var result = null;
35 while (expr is Cons) {
36 result = eval(env, expr.head);
37 expr = expr.tail;
38 }
39 return result;
40 }
41
42 /// The arguments evaluation function.
43 evalArguments(Environment env, args) {
44 if (args is Cons) {
45 return new Cons(eval(env, args.head), evalArguments(env, args.tail));
46 } else {
47 return null;
48 }
49 }
50
51 /// Reads and evaluates a [script].
52 evalString(Parser parser, Environment env, String script) {
53 var result = null;
54 for (var cell in parser.parse(script).value) {
55 result = eval(env, cell);
56 }
57 return result;
58 }
OLDNEW
« no previous file with comments | « packages/petitparser/lib/json.dart ('k') | packages/petitparser/lib/petitparser.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698