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

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

Issue 1400473008: Roll Observatory packages and add a roll script (Closed) Base URL: git@github.com:dart-lang/observatory_pub_packages.git@master
Patch Set: Created 5 years, 2 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 | « petitparser/lib/json.dart ('k') | 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 /**
2 * This package contains a simple grammar and evaluator for LISP.
3 *
4 * The code is reasonably complete to run and evaluate reasonably complex
5 * programs from the console and from the web browser.
6 */
7 library lisp;
8
9 import 'dart:collection';
10 import 'package:petitparser/petitparser.dart';
11
12 part 'src/lisp/cons.dart';
13 part 'src/lisp/environment.dart';
14 part 'src/lisp/grammar.dart';
15 part 'src/lisp/name.dart';
16 part 'src/lisp/natives.dart';
17 part 'src/lisp/parser.dart';
18 part 'src/lisp/standard.dart';
19
20 /** The standard lisp parser definition. */
21 final lispParser = new LispParser();
22
23 /** The evaluation function. */
24 eval(Environment env, expr) {
25 if (expr is Cons) {
26 return eval(env, expr.head)(env, expr.tail);
27 } else if (expr is Name) {
28 return env[expr];
29 } else {
30 return expr;
31 }
32 }
33
34 /** Evaluate a cons of instructions. */
35 evalList(Environment env, expr) {
36 var result = null;
37 while (expr is Cons) {
38 result = eval(env, expr.head);
39 expr = expr.tail;
40 }
41 return result;
42 }
43
44 /** The arguments evaluation function. */
45 evalArguments(Environment env, args) {
46 if (args is Cons) {
47 return new Cons(eval(env, args.head), evalArguments(env, args.tail));
48 } else {
49 return null;
50 }
51 }
52
53 /** Reads and evaluates a [script]. */
54 evalString(Parser parser, Environment env, String script) {
55 var result = null;
56 for (var cell in parser.parse(script).value) {
57 result = eval(env, cell);
58 }
59 return result;
60 }
OLDNEW
« no previous file with comments | « petitparser/lib/json.dart ('k') | petitparser/lib/petitparser.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698