Permalink
Browse files

Moving all sources to 'src' subdirectory and some tab-normalization.

  • Loading branch information...
1 parent bc93c81 commit 32ee766b7386a379d815df27a0d3bab99c5b1c69 @akoprow akoprow committed Feb 2, 2012
View
1 .gitignore
@@ -2,3 +2,4 @@
_build
_tracks
*~
+*.log
View
8 Makefile
@@ -1,11 +1,15 @@
NAME = webshell.exe
SRC = parser.opa editor.opa webshell.opa login.opa fb_login.opa search.opa
+SRCS = $(SRC:%=src/%)
all: $(NAME)
-$(NAME): $(SRC)
- opa --parser js-like $(SRC) -o $(NAME)
+$(NAME): $(SRCS)
+ opa --parser js-like $(SRCS) -o $(NAME)
+
+run: $(NAME)
+ ./$(NAME)
clean:
rm -f $(NAME)
View
55 parser.opa
@@ -1,55 +0,0 @@
-// license: AGPL
-// (c) MLstate, 2011
-// author: Adam Koprowski, Henri Binsztok
-
-client module Calc {
-
- function int_of_string(string str) { (option(int)) Parser.try_parse(Rule.integer, str); }
- function nat_of_string(string str) { (option(int)) Parser.try_parse(Rule.natural, str); }
-
- function ws(p) {
- parser
- | Rule.ws res=p Rule.ws -> res
- }
-
- `(` = ws(parser | "(" -> void)
- `)` = ws(parser | ")" -> void)
-
- term = parser
- | f = {ws(Rule.float)} -> f
- | `(` ~expr `)` -> expr
-
- factor = parser
- | ~term "*" ~factor -> term * factor
- | ~term "/" ~factor -> term / factor
- | ~term -> term
-
- expr = parser
- | ~factor "+" ~expr -> factor + expr
- | ~factor "-" ~expr -> factor - expr
- | ~factor -> factor
-
- search = ws(parser | "search" -> void)
- set = ws(parser | "set" -> void)
- next = ws(parser | "next" -> void)
- prev = ws(parser | "prev" -> void)
- page = ws(parser | "page" -> void)
-
- args = parser | txt=(.*) -> List.map(String.trim,String.explode(" ",Text.to_string(txt)))
-
- shell = parser
- | search ~args -> { search:args }
- | set ~args -> { set:args }
- | next -> { next }
- | prev -> { prev }
- | page pagenum={ws(Rule.natural)} -> { ~pagenum }
- | command={ws(Rule.ident)} arg={ws(Rule.ident)} -> { ~command, ~arg }
- | ~expr -> {value: expr}
-
- function compute(s) {
- match (Parser.try_parse(expr, s)) {
- case {some: result}: "{result}";
- case {none}: "unknown";
- }
- }
-}
View
0 editor.opa → src/editor.opa
File renamed without changes.
View
0 fb_login.opa → src/fb_login.opa
File renamed without changes.
View
0 login.opa → src/login.opa
File renamed without changes.
View
60 src/parser.opa
@@ -0,0 +1,60 @@
+// license: AGPL
+// (c) MLstate, 2011, 2012
+// author: Adam Koprowski, Henri Binsztok
+
+client module Calc {
+
+ function int_of_string(string str) {
+ (option(int)) Parser.try_parse(Rule.integer, str);
+ }
+
+ function nat_of_string(string str) {
+ (option(int)) Parser.try_parse(Rule.natural, str);
+ }
+
+ function ws(p) {
+ parser
+ | Rule.ws res=p Rule.ws -> res
+ }
+
+ `(` = ws(parser | "(" -> void)
+ `)` = ws(parser | ")" -> void)
+
+ term = parser
+ | f = {ws(Rule.float)} -> f
+ | `(` ~expr `)` -> expr
+
+ factor = parser
+ | ~term "*" ~factor -> term * factor
+ | ~term "/" ~factor -> term / factor
+ | ~term -> term
+
+ expr = parser
+ | ~factor "+" ~expr -> factor + expr
+ | ~factor "-" ~expr -> factor - expr
+ | ~factor -> factor
+
+ search = ws(parser | "search" -> void)
+ set = ws(parser | "set" -> void)
+ next = ws(parser | "next" -> void)
+ prev = ws(parser | "prev" -> void)
+ page = ws(parser | "page" -> void)
+
+ args = parser | txt=(.*) -> List.map(String.trim,String.explode(" ",Text.to_string(txt)))
+
+ shell = parser
+ | search ~args -> { search:args }
+ | set ~args -> { set:args }
+ | next -> { next }
+ | prev -> { prev }
+ | page pagenum={ws(Rule.natural)} -> { ~pagenum }
+ | command={ws(Rule.ident)} arg={ws(Rule.ident)} -> { ~command, ~arg }
+ | ~expr -> {value: expr}
+
+ function compute(s) {
+ match (Parser.try_parse(expr, s)) {
+ case {some: result}: "{result}";
+ case {none}: "unknown";
+ }
+ }
+}
View
0 search.opa → src/search.opa
File renamed without changes.
View
0 user.opa → src/user.opa
File renamed without changes.
View
52 webshell.opa → src/webshell.opa
@@ -11,8 +11,8 @@ type User.t = {guest} or {FbLogin.user fb_user}
WB = WBootstrap
function focus(set) {
- Log.warning("focus", set);
- #status = "Focus: {set}";
+ Log.warning("focus", set);
+ #status = "Focus: {set}";
}
function prompt() {
@@ -24,45 +24,45 @@ function prompt() {
}
function warner(msg) {
- #terminal_prev =+ msg;
+ #terminal_prev =+ msg;
}
function asker(_f, msg) {
- #terminal_prev =+ msg;
+ #terminal_prev =+ msg;
}
function loop(ua)(_) {
- LineEditor.init(ua, #editor, readevalwrite(_), true);
+ LineEditor.init(ua, #editor, readevalwrite(_), true);
}
function answer(expr) {
- (xhtml) match (Parser.try_parse(Calc.shell, expr)) {
- case { none }: <>syntax error</>
- case { some: { value: result } }: <>{result}</>
- case { some: { ~command, ~arg } }: <>{command}({arg})</>
- case { some: { search:args } }: Search.search(args)
- case { some: { set:args } }: Search.set(args)
- case { some: { next } }: Search.next()
- case { some: { prev } }: Search.prev()
- case { some: { ~pagenum } }: Search.page(pagenum)
- }
+ (xhtml) match (Parser.try_parse(Calc.shell, expr)) {
+ case { none }: <>syntax error</>
+ case { some: { value: result } }: <>{result}</>
+ case { some: { ~command, ~arg } }: <>{command}({arg})</>
+ case { some: { search:args } }: Search.search(args)
+ case { some: { set:args } }: Search.set(args)
+ case { some: { next } }: Search.next()
+ case { some: { prev } }: Search.prev()
+ case { some: { ~pagenum } }: Search.page(pagenum)
+ }
}
function readevalwrite(expr) {
- element =
- <div>
- <span>{prompt()}</span>
- <span>{expr}</span>
- </div>
- <div>{answer(expr)}</div>;
- update(element);
+ element =
+ <div>
+ <span>{prompt()}</span>
+ <span>{expr}</span>
+ </div>
+ <div>{answer(expr)}</div>;
+ update(element);
}
client function update(xhtml element) {
- #terminal_prev =+ element;
- LineEditor.clear();
- Dom.scroll_to_bottom(#terminal);
- Dom.scroll_to_bottom(Dom.select_window());
+ #terminal_prev =+ element;
+ LineEditor.clear();
+ Dom.scroll_to_bottom(#terminal);
+ Dom.scroll_to_bottom(Dom.select_window());
}
function login_box() {

0 comments on commit 32ee766

Please sign in to comment.