view src/kryshen/tema/GlobalContext.java @ 2:6c41a0b43e58

Tema 0.3 (imported from CVS).
author Mikhail Kryshen <mikhail@kryshen.net>
date Tue, 19 Feb 2008 20:32:17 +0300
parents
children e9d13c7ffeb1
line source
1 /*
2 * Copyright 2006-2008 Mikhail Kryshen
3 *
4 * This file is part of Tema.
5 *
6 * Tema is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU Lesser General Public License as
8 * published by the Free Software Foundation, either version 3 of the
9 * License, or (at your option) any later version.
10 *
11 * Tema is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Lesser General Public License for more details.
15 *
16 * You should have received a copy of the
17 * GNU Lesser General Public License along with Tema.
18 * If not, see <http://www.gnu.org/licenses/>.
19 *
20 * $Id: GlobalContext.java,v 1.16 2008/02/19 16:21:00 mikhail Exp $
21 */
23 package kryshen.tema;
25 import java.io.File;
26 import kryshen.tema.functions.Database;
27 import kryshen.tema.functions.Define;
28 import kryshen.tema.functions.IO;
29 import kryshen.tema.functions.ImageConverter;
30 import kryshen.tema.functions.Control;
31 import kryshen.tema.functions.Standard;
32 import kryshen.tema.functions.Strings;
34 /**
35 * Context to hold exported variables and standard Tema definitions.
36 *
37 * @author Mikhail Kryshen
38 */
39 class GlobalContext extends Context {
41 GlobalContext() {
42 super(new File(System.getProperty("user.dir")));
44 // Register all standard functions.
45 // TODO: arithmetics
47 set("tema", Standard.TEMA);
48 set("echo", Standard.ECHO);
49 set("", Standard.ECHO);
50 set("!", Standard.SKIP);
51 set("silent", Standard.SILENT);
52 set("set", Standard.SET);
53 set("unset", Standard.UNSET);
54 set("export", Standard.EXPORT);
55 set("assign", Standard.ASSIGN);
56 set("invoke", Standard.INVOKE);
57 set("load", Standard.LOAD);
59 set("to_upper", Strings.TO_UPPER);
60 set("to_lower", Strings.TO_LOWER);
61 set("substring", Strings.SUBSTRING);
62 set("equal", Strings.EQUAL);
63 set("xml_escape", Strings.XML_ESCAPE);
64 set("xml_cdata", Strings.XML_CDATA);
65 set("char", Strings.CHAR);
66 set("replace", Strings.REPLACE);
67 set("regex_match", Strings.REGEX_MATCH);
68 set("regex_replace_first", Strings.REGEX_REPLACE_FIRST);
69 set("regex_replace_all", Strings.REGEX_REPLACE_ALL);
71 set("define", Define.DEFINE);
73 set("write", IO.WRITE);
74 set("read", IO.READ);
75 set("include", IO.INCLUDE);
76 set("copy", IO.COPY);
77 set("file", IO.FILE);
79 set("false", Control.FALSE);
80 set("true", Control.TRUE);
81 set("not", Control.NOT);
82 set("optional", Control.OPTIONAL);
83 set("if", Control.IF);
84 set("if_else", Control.IF_ELSE);
85 set("while", Control.WHILE);
87 set("db_connect", Database.CONNECT);
88 set("db_prepare", Database.PREPARE);
89 set("db_query", Database.QUERY);
91 set("convert_image", ImageConverter.CONVERT_IMAGE);
93 // Other functions are defined in classes Database and Define.
94 }
95 }