forked from GitHub/gf-core
reorganize the directories under src, and rescue the JavaScript interpreter from deprecated
This commit is contained in:
@@ -1,19 +0,0 @@
|
||||
CC = gcc
|
||||
CFLAGS += -O2 -W -Wall
|
||||
|
||||
.PHONY: all clean
|
||||
|
||||
all: libgfcc.a
|
||||
|
||||
libgfcc.a: gfcc-tree.o gfcc-term.o
|
||||
ar r $@ $^
|
||||
|
||||
gfcc-tree.o: gfcc-tree.c gfcc-tree.h
|
||||
$(CC) $(CFLAGS) -c -o $@ $<
|
||||
|
||||
gfcc-term.o: gfcc-term.c gfcc-term.h
|
||||
$(CC) $(CFLAGS) -c -o $@ $<
|
||||
|
||||
clean:
|
||||
-rm -f libgfcc.a
|
||||
-rm -f *.o
|
||||
@@ -1,203 +0,0 @@
|
||||
#include "gfcc-term.h"
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
static void *buffer = NULL;
|
||||
static size_t current;
|
||||
|
||||
extern void term_alloc_pool(size_t size) {
|
||||
if (buffer == NULL)
|
||||
buffer = malloc(size);
|
||||
current = 0;
|
||||
}
|
||||
|
||||
extern void term_free_pool() {
|
||||
if (buffer != NULL)
|
||||
free(buffer);
|
||||
buffer = NULL;
|
||||
}
|
||||
|
||||
extern void *term_alloc(size_t size) {
|
||||
void *off = buffer + current;
|
||||
current += size;
|
||||
return off;
|
||||
}
|
||||
|
||||
static inline Term *create_term(TermType type, int n) {
|
||||
Term *t = (Term*)term_alloc(sizeof(Term) + n * sizeof(Term *));
|
||||
t->type = type;
|
||||
t->value.size = n; /* FIXME: hack! */
|
||||
return t;
|
||||
}
|
||||
|
||||
extern Term *term_array(int n, ...) {
|
||||
Term *t = create_term(TERM_ARRAY, n);
|
||||
va_list ap;
|
||||
int i;
|
||||
|
||||
va_start(ap, n);
|
||||
for (i = 0; i < n; i++) {
|
||||
term_set_child(t, i, va_arg(ap, Term *));
|
||||
}
|
||||
va_end(ap);
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
extern Term *term_seq(int n, ...) {
|
||||
Term *t = create_term(TERM_SEQUENCE, n);
|
||||
va_list ap;
|
||||
int i;
|
||||
|
||||
va_start(ap, n);
|
||||
for (i = 0; i < n; i++) {
|
||||
term_set_child(t, i, va_arg(ap, Term *));
|
||||
}
|
||||
va_end(ap);
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
extern Term *term_variants(int n, ...) {
|
||||
Term *t = create_term(TERM_VARIANTS, n);
|
||||
va_list ap;
|
||||
int i;
|
||||
|
||||
va_start(ap, n);
|
||||
for (i = 0; i < n; i++) {
|
||||
term_set_child(t, i, va_arg(ap, Term *));
|
||||
}
|
||||
va_end(ap);
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
extern Term *term_glue(int n, ...) {
|
||||
Term *t = create_term(TERM_GLUE, n);
|
||||
va_list ap;
|
||||
int i;
|
||||
|
||||
va_start(ap, n);
|
||||
for (i = 0; i < n; i++) {
|
||||
term_set_child(t, i, va_arg(ap, Term *));
|
||||
}
|
||||
va_end(ap);
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
extern Term *term_rp(Term *t1, Term *t2) {
|
||||
Term *t = create_term(TERM_RECORD_PARAM, 2);
|
||||
term_set_child(t, 0, t1);
|
||||
term_set_child(t, 1, t2);
|
||||
return t;
|
||||
}
|
||||
|
||||
extern Term *term_suffix(const char *pref, Term *suf) {
|
||||
Term *t = create_term(TERM_SUFFIX_TABLE, 2);
|
||||
term_set_child(t,0,term_str(pref));
|
||||
term_set_child(t,1,suf);
|
||||
return t;
|
||||
}
|
||||
|
||||
extern Term *term_str(const char *s) {
|
||||
Term *t = create_term(TERM_STRING, 0);
|
||||
t->value.string_value = s;
|
||||
return t;
|
||||
}
|
||||
|
||||
extern Term *term_int(int i) {
|
||||
Term *t = create_term(TERM_INTEGER,0);
|
||||
t->value.integer_value = i;
|
||||
return t;
|
||||
}
|
||||
|
||||
extern Term *term_meta() {
|
||||
return create_term(TERM_META, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
extern Term *term_sel_int(Term *t, int i) {
|
||||
switch (t->type) {
|
||||
case TERM_ARRAY:
|
||||
return term_get_child(t,i);
|
||||
case TERM_SUFFIX_TABLE:
|
||||
return term_glue(2,
|
||||
term_get_child(t,0),
|
||||
term_sel_int(term_get_child(t,1),i));
|
||||
case TERM_META:
|
||||
return t;
|
||||
default:
|
||||
fprintf(stderr,"Error: term_sel_int %d %d\n", t->type, i);
|
||||
exit(1);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
extern Term *term_sel(Term *t1, Term *t2) {
|
||||
switch (t2->type) {
|
||||
case TERM_INTEGER:
|
||||
return term_sel_int(t1, t2->value.integer_value);
|
||||
case TERM_RECORD_PARAM:
|
||||
return term_sel(t1,term_get_child(t2,0));
|
||||
case TERM_META:
|
||||
return term_sel_int(t1,0);
|
||||
default:
|
||||
fprintf(stderr,"Error: term_sel %d %d\n", t1->type, t2->type);
|
||||
exit(1);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void term_print_sep(FILE *stream, Term *t, const char *sep) {
|
||||
int n = t->value.size;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < n; i++) {
|
||||
term_print(stream, term_get_child(t,i));
|
||||
if (i < n-1) {
|
||||
fputs(sep, stream);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extern void term_print(FILE *stream, Term *t) {
|
||||
switch (t->type) {
|
||||
case TERM_ARRAY:
|
||||
term_print(stream, term_get_child(t,0));
|
||||
break;
|
||||
case TERM_SEQUENCE:
|
||||
term_print_sep(stream, t, " ");
|
||||
break;
|
||||
case TERM_VARIANTS:
|
||||
term_print_sep(stream, t, "/");
|
||||
break;
|
||||
case TERM_GLUE:
|
||||
term_print_sep(stream, t, "");
|
||||
break;
|
||||
case TERM_RECORD_PARAM:
|
||||
term_print(stream, term_get_child(t,0));
|
||||
break;
|
||||
case TERM_SUFFIX_TABLE:
|
||||
term_print(stream, term_get_child(t,0));
|
||||
term_print(stream, term_get_child(t,1));
|
||||
break;
|
||||
case TERM_META:
|
||||
fputs("?", stream);
|
||||
break;
|
||||
case TERM_STRING:
|
||||
fputs(t->value.string_value, stream);
|
||||
break;
|
||||
case TERM_INTEGER:
|
||||
fprintf(stream, "%d", t->value.integer_value);
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr,"Error: term_print %d\n", t->type);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
@@ -1,65 +0,0 @@
|
||||
#ifndef GFCC_TERM_H
|
||||
#define GFCC_TERM_H
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
typedef enum {
|
||||
/* size = variable */
|
||||
TERM_ARRAY,
|
||||
TERM_SEQUENCE,
|
||||
TERM_VARIANTS,
|
||||
TERM_GLUE,
|
||||
/* size = 2 */
|
||||
TERM_RECORD_PARAM,
|
||||
TERM_SUFFIX_TABLE,
|
||||
/* size = 0 */
|
||||
TERM_META,
|
||||
TERM_STRING,
|
||||
TERM_INTEGER
|
||||
} TermType;
|
||||
|
||||
struct Term_ {
|
||||
TermType type;
|
||||
union {
|
||||
const char *string_value;
|
||||
int integer_value;
|
||||
int size;
|
||||
} value;
|
||||
struct Term_ *args[0];
|
||||
};
|
||||
|
||||
typedef struct Term_ Term;
|
||||
|
||||
|
||||
|
||||
static inline Term *term_get_child(Term *t, int n) {
|
||||
return t->args[n];
|
||||
}
|
||||
|
||||
static inline void term_set_child(Term *t, int n, Term *c) {
|
||||
t->args[n] = c;
|
||||
}
|
||||
|
||||
extern void term_alloc_pool(size_t size);
|
||||
extern void term_free_pool();
|
||||
extern void *term_alloc(size_t size);
|
||||
|
||||
|
||||
extern Term *term_array(int n, ...);
|
||||
extern Term *term_seq(int n, ...);
|
||||
extern Term *term_variants(int n, ...);
|
||||
extern Term *term_glue(int n, ...);
|
||||
|
||||
extern Term *term_rp(Term *t1, Term *t2);
|
||||
extern Term *term_suffix(const char *pref, Term *suf);
|
||||
extern Term *term_str(const char *s);
|
||||
extern Term *term_int(int i);
|
||||
extern Term *term_meta();
|
||||
|
||||
extern Term *term_sel_int(Term *t, int i);
|
||||
extern Term *term_sel(Term *t1, Term *t2);
|
||||
|
||||
|
||||
extern void term_print(FILE *stream, Term *t);
|
||||
|
||||
#endif
|
||||
@@ -1,61 +0,0 @@
|
||||
#include "gfcc-tree.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
extern int arity(Tree *t) {
|
||||
switch (t->type) {
|
||||
case ATOM_STRING:
|
||||
case ATOM_INTEGER:
|
||||
case ATOM_DOUBLE:
|
||||
case ATOM_META:
|
||||
return 0;
|
||||
default:
|
||||
return t->value.size;
|
||||
}
|
||||
}
|
||||
|
||||
static Tree *create_tree(atom_type c, int n) {
|
||||
Tree *t = (Tree *)malloc(sizeof(Tree) + n * sizeof(Tree *));
|
||||
t->type = c;
|
||||
return t;
|
||||
}
|
||||
|
||||
extern Tree *tree_string(const char *s) {
|
||||
Tree *t = create_tree(ATOM_STRING, 0);
|
||||
t->value.string_value = s;
|
||||
return t;
|
||||
}
|
||||
|
||||
extern Tree *tree_integer(int i) {
|
||||
Tree *t = create_tree(ATOM_INTEGER, 0);
|
||||
t->value.integer_value = i;
|
||||
return t;
|
||||
}
|
||||
|
||||
extern Tree *tree_double(double d) {
|
||||
Tree *t = create_tree(ATOM_DOUBLE, 0);
|
||||
t->value.double_value = d;
|
||||
return t;
|
||||
}
|
||||
|
||||
extern Tree *tree_meta() {
|
||||
return create_tree(ATOM_META, 0);
|
||||
}
|
||||
|
||||
extern Tree *tree_fun(atom_type f, int n) {
|
||||
Tree *t = create_tree(f, n);
|
||||
t->value.size = n;
|
||||
return t;
|
||||
}
|
||||
|
||||
|
||||
extern void tree_free(Tree *t) {
|
||||
int n = arity(t);
|
||||
int i;
|
||||
|
||||
for (i = 0; i < n; i++) {
|
||||
tree_free(tree_get_child(t,i));
|
||||
}
|
||||
free(t);
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
#ifndef GFCC_TREE_H
|
||||
#define GFCC_TREE_H
|
||||
|
||||
typedef enum {
|
||||
ATOM_STRING,
|
||||
ATOM_INTEGER,
|
||||
ATOM_DOUBLE,
|
||||
ATOM_META,
|
||||
ATOM_FIRST_FUN
|
||||
} atom_type;
|
||||
|
||||
struct Tree_{
|
||||
atom_type type;
|
||||
union {
|
||||
const char *string_value;
|
||||
int integer_value;
|
||||
double double_value;
|
||||
int size;
|
||||
} value;
|
||||
struct Tree_ *args[0];
|
||||
};
|
||||
|
||||
typedef struct Tree_ Tree;
|
||||
|
||||
static inline Tree *tree_get_child(Tree *t, int n) {
|
||||
return t->args[n];
|
||||
}
|
||||
|
||||
static inline void tree_set_child(Tree *t, int n, Tree *a) {
|
||||
t->args[n] = a;
|
||||
}
|
||||
|
||||
extern int arity(Tree *t);
|
||||
|
||||
|
||||
extern Tree *tree_string(const char *s);
|
||||
|
||||
extern Tree *tree_integer(int i);
|
||||
|
||||
extern Tree *tree_double(double d);
|
||||
|
||||
extern Tree *tree_meta();
|
||||
|
||||
extern Tree *tree_fun(atom_type f, int n);
|
||||
|
||||
|
||||
extern void tree_free(Tree *t);
|
||||
|
||||
#endif
|
||||
@@ -1,17 +0,0 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
<link rel="stylesheet" type="text/css" href="style.css" />
|
||||
<script type="text/javascript" src="gflib.js"></script>
|
||||
<script type="text/javascript" src="editorGrammar.js"></script>
|
||||
<script type="text/javascript" src="grammar.js"></script>
|
||||
<script type="text/javascript" src="gfjseditor.js"></script>
|
||||
<title>Web-based Syntax Editor</title>
|
||||
</head>
|
||||
<body onload="mkEditor('editor', Food)" onkeydown="hotKeys(event)">
|
||||
<div id="editor">
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
File diff suppressed because one or more lines are too long
Binary file not shown.
|
Before Width: | Height: | Size: 161 B |
File diff suppressed because it is too large
Load Diff
@@ -1,54 +0,0 @@
|
||||
/* Output */
|
||||
|
||||
function sayText(text) {
|
||||
document.voice_output_text = text;
|
||||
activateForm("voice_output");
|
||||
}
|
||||
|
||||
/* XHTML+Voice Utilities */
|
||||
|
||||
function activateForm(formid) {
|
||||
var form = document.getElementById(formid);
|
||||
var e = document.createEvent("UIEvents");
|
||||
e.initEvent("DOMActivate","true","true");
|
||||
form.dispatchEvent(e);
|
||||
}
|
||||
|
||||
|
||||
/* DOM utilities */
|
||||
|
||||
/* Gets the head element of the document. */
|
||||
function getHeadElement() {
|
||||
var hs = document.getElementsByTagName("head");
|
||||
if (hs.length == 0) {
|
||||
var head = document.createElement("head");
|
||||
document.documentElement.insertBefore(head, document.documentElement.firstChild);
|
||||
return head;
|
||||
} else {
|
||||
return hs[0];
|
||||
}
|
||||
}
|
||||
|
||||
/* Gets the body element of the document. */
|
||||
function getBodyElement() {
|
||||
var bs = document.getElementsByTagName("body");
|
||||
if (bs.length == 0) {
|
||||
var body = document.createElement("body");
|
||||
document.documentElement.appendChild(body);
|
||||
return body;
|
||||
} else {
|
||||
return bs[0];
|
||||
}
|
||||
}
|
||||
|
||||
/* Removes all the children of a node */
|
||||
function removeChildren(node) {
|
||||
while (node.hasChildNodes()) {
|
||||
node.removeChild(node.firstChild);
|
||||
}
|
||||
}
|
||||
|
||||
function setText(node, text) {
|
||||
removeChildren(node);
|
||||
node.appendChild(document.createTextNode(text));
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
Binary file not shown.
|
Before Width: | Height: | Size: 201 B |
Binary file not shown.
|
Before Width: | Height: | Size: 229 B |
@@ -1,241 +0,0 @@
|
||||
body {
|
||||
font-family:arial,helvetica,sans-serif;
|
||||
font-size:12px;
|
||||
background-color: white;
|
||||
}
|
||||
|
||||
#wrapper {
|
||||
width:740px;
|
||||
height:520px;
|
||||
margin:auto 50px;
|
||||
border:1px solid gray;
|
||||
padding:10px;
|
||||
|
||||
}
|
||||
|
||||
#absFrame {
|
||||
width:250px;
|
||||
height:250px;
|
||||
padding:10px;
|
||||
border:1px solid gray;
|
||||
float:left;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
#conFrame {
|
||||
width:436px;
|
||||
height:250px;
|
||||
margin-left:10px;
|
||||
padding:10px;
|
||||
border:1px solid gray;
|
||||
float:left;
|
||||
white-space: normal;
|
||||
overflow:auto;
|
||||
}
|
||||
|
||||
#actFrame {
|
||||
width:250px;
|
||||
height:170px;
|
||||
margin-top:10px;
|
||||
padding:10px;
|
||||
border:1px solid gray;
|
||||
float:left;
|
||||
overflow:auto;
|
||||
}
|
||||
|
||||
#refFrame {
|
||||
width:436px;
|
||||
height:170px;
|
||||
margin-left:10px;
|
||||
margin-top:10px;
|
||||
padding:10px;
|
||||
border:1px solid gray;
|
||||
float:left;
|
||||
overflow:auto;
|
||||
}
|
||||
|
||||
#messageFrame {
|
||||
width:506px;
|
||||
height:15px;
|
||||
margin-top:10px;
|
||||
margin-right:10px;
|
||||
padding:10px;
|
||||
border:1px solid gray;
|
||||
float:left;
|
||||
overflow:hidden;
|
||||
}
|
||||
|
||||
#clipboardFrame {
|
||||
width:180px;
|
||||
height:15px;
|
||||
margin-top:10px;
|
||||
padding:10px;
|
||||
border:1px solid gray;
|
||||
float:left;
|
||||
overflow:auto;
|
||||
}
|
||||
|
||||
#tree {
|
||||
left: -10px;
|
||||
top: -10px;
|
||||
width: 250px;
|
||||
height: 250px;
|
||||
margin: 0px;
|
||||
padding: 10px;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
ul {
|
||||
position: relative;
|
||||
list-style: none;
|
||||
margin-left: 20px;
|
||||
padding: 0px;
|
||||
}
|
||||
|
||||
li {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
img.tree-menu {
|
||||
margin-right: 5px;
|
||||
}
|
||||
|
||||
a.tree:link, a.tree:visited, a.tree:active {
|
||||
color: black;
|
||||
background-color: white;
|
||||
text-decoration: none;
|
||||
margin-right:10px;
|
||||
}
|
||||
|
||||
a.tree:hover {
|
||||
color: blue;
|
||||
background-color: white;
|
||||
text-decoration: underline;
|
||||
margin-right:10px;
|
||||
}
|
||||
|
||||
a.treeSelected:link, a.treeSelected:visited, a.treeSelected:active {
|
||||
color: white;
|
||||
background-color: #3366CC;
|
||||
text-decoration: none;
|
||||
margin-right:10px;
|
||||
}
|
||||
|
||||
a.treeSelected:hover {
|
||||
color: white;
|
||||
background-color: #3366CC;
|
||||
text-decoration: underline;
|
||||
margin-right:10px;
|
||||
}
|
||||
|
||||
a.treeGray:link, a.treeGray:visited, a.treeGray:active {
|
||||
color: silver;
|
||||
background-color: white;
|
||||
text-decoration: none;
|
||||
margin-right:10px;
|
||||
}
|
||||
|
||||
a.treeGray:hover {
|
||||
color: silver;
|
||||
background-color: white;
|
||||
text-decoration: none;
|
||||
margin-right:10px;
|
||||
}
|
||||
|
||||
table.action, table.refinement, table.wrapper, table.tree, table.language {
|
||||
margin: 0px;
|
||||
padding: 0px;
|
||||
border-style: none;
|
||||
border-collapse: collapse;
|
||||
border-spacing: 0px;
|
||||
}
|
||||
|
||||
tr.selected {
|
||||
color: white;
|
||||
background-color: #3366CC;
|
||||
}
|
||||
|
||||
tr.unavailable, tr.closed {
|
||||
color: silver;
|
||||
background-color: white;
|
||||
}
|
||||
|
||||
tr.unavailable:hover {
|
||||
color: silver;
|
||||
background-color: #3366CC;
|
||||
}
|
||||
|
||||
tr.action, tr.refinement, tr.wrapper, tr.tree {
|
||||
color: black;
|
||||
background-color: white;
|
||||
}
|
||||
|
||||
tr.action:hover, tr.refinement:hover, tr.wrapper:hover, tr.tree:hover {
|
||||
color: white;
|
||||
background-color: #3366CC;
|
||||
}
|
||||
|
||||
td.action {
|
||||
width: 220px;
|
||||
margin: 0px;
|
||||
padding: 0px;
|
||||
}
|
||||
|
||||
td.refinement, td.wrapper, td.tree {
|
||||
width: 515px;
|
||||
margin: 0px;
|
||||
padding: 0px;
|
||||
}
|
||||
|
||||
td.hotKey {
|
||||
width: 30px;
|
||||
margin: 0px;
|
||||
padding: 0px;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
td.language {
|
||||
color: black;
|
||||
background-color: white;
|
||||
margin: 1px;
|
||||
padding: 1px;
|
||||
}
|
||||
|
||||
td.language:hover {
|
||||
color: blue;
|
||||
background-color: white;
|
||||
text-decoration: underline;
|
||||
margin: 1px;
|
||||
padding: 1px;
|
||||
}
|
||||
|
||||
td.selected {
|
||||
color: white;
|
||||
background-color: #3366CC;
|
||||
margin: 1px;
|
||||
padding: 1px;
|
||||
}
|
||||
|
||||
td.selected:hover {
|
||||
color: white;
|
||||
background-color: #3366CC;
|
||||
text-decoration: underline;
|
||||
margin: 1px;
|
||||
padding: 1px;
|
||||
}
|
||||
|
||||
p {
|
||||
margin-bottom: 40px;
|
||||
}
|
||||
|
||||
span.normal {
|
||||
color: black;
|
||||
background-color: white;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
span.selected {
|
||||
color: white;
|
||||
background-color: #3366CC;
|
||||
text-decoration: none;
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
body {
|
||||
color: black;
|
||||
background-color: white;
|
||||
}
|
||||
|
||||
dl {
|
||||
|
||||
}
|
||||
|
||||
dt {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
dl dd {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
dl.fromLang dt {
|
||||
display: none;
|
||||
}
|
||||
|
||||
dl.toLang {
|
||||
border-width: 1px 0 0 0;
|
||||
border-style: solid;
|
||||
border-color: #c0c0c0;
|
||||
}
|
||||
|
||||
dl.toLang dt {
|
||||
color: #c0c0c0;
|
||||
display: block;
|
||||
float: left;
|
||||
width: 5em;
|
||||
}
|
||||
|
||||
|
||||
dl.toLang dd {
|
||||
border-width: 0 0 1px 0;
|
||||
border-style: solid;
|
||||
border-color: #c0c0c0;
|
||||
}
|
||||
|
||||
|
||||
ul {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
li {
|
||||
list-style-type: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
<link rel="stylesheet" type="text/css" href="translator.css" />
|
||||
<script type="text/javascript" src="gflib.js"></script>
|
||||
<script type="text/javascript" src="grammar.js"></script>
|
||||
<script type="text/javascript" src="translator.js"></script>
|
||||
<script type="text/javascript">
|
||||
/* CHANGE ME */
|
||||
var grammar = Food;
|
||||
|
||||
function updateTranslation () {
|
||||
var input = document.getElementById('inputText').value;
|
||||
var fromLang = document.getElementById('fromLang').value;
|
||||
var toLang = document.getElementById('toLang').value;
|
||||
var output = document.getElementById('output');
|
||||
var translation = grammar.translate(input, fromLang, toLang);
|
||||
removeChildren(output);
|
||||
output.appendChild(formatTranslation(translation));
|
||||
}
|
||||
|
||||
function populateLangs () {
|
||||
var f = document.getElementById('fromLang');
|
||||
var t = document.getElementById('toLang');
|
||||
for (var c in grammar.concretes) {
|
||||
addOption(f, c, c);
|
||||
addOption(t, c, c);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<title>Web-based GF Translator</title>
|
||||
</head>
|
||||
<body onload="populateLangs(Food, 'fromLang', 'toLang')">
|
||||
<form id="translate">
|
||||
<p>
|
||||
<input type="text" name="inputText" id="inputText" value="this cheese is warm" size="50" />
|
||||
</p>
|
||||
<p>
|
||||
From: <select name="fromLang" id="fromLang" onchange=""><option value="">Any language</option></select>
|
||||
To: <select name="toLang" id="toLang"><option value="">All languages</option></select>
|
||||
<input type="button" value="Translate" onclick="updateTranslation()" />
|
||||
</p>
|
||||
</form>
|
||||
<div id="output"></div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,51 +0,0 @@
|
||||
function formatTranslation (outputs) {
|
||||
var dl1 = document.createElement("dl");
|
||||
dl1.className = "fromLang";
|
||||
for (var fromLang in outputs) {
|
||||
var ul = document.createElement("ul");
|
||||
addDefinition(dl1, document.createTextNode(fromLang), ul);
|
||||
for (var i in outputs[fromLang]) {
|
||||
var dl2 = document.createElement("dl");
|
||||
dl2.className = "toLang";
|
||||
for (var toLang in outputs[fromLang][i]) {
|
||||
addDefinition(dl2, document.createTextNode(toLang), document.createTextNode(outputs[fromLang][i][toLang]));
|
||||
}
|
||||
addItem(ul, dl2);
|
||||
}
|
||||
}
|
||||
|
||||
return dl1;
|
||||
}
|
||||
|
||||
/* DOM utilities for specific tags */
|
||||
|
||||
function addDefinition (dl, t, d) {
|
||||
var dt = document.createElement("dt");
|
||||
dt.appendChild(t);
|
||||
dl.appendChild(dt);
|
||||
var dd = document.createElement("dd");
|
||||
dd.appendChild(d);
|
||||
dl.appendChild(dd);
|
||||
}
|
||||
|
||||
function addItem (ul, i) {
|
||||
var li = document.createElement("li");
|
||||
li.appendChild(i);
|
||||
ul.appendChild(li);
|
||||
}
|
||||
|
||||
function addOption (select, value, content) {
|
||||
var option = document.createElement("option");
|
||||
option.value = value;
|
||||
option.appendChild(document.createTextNode(content));
|
||||
select.appendChild(option);
|
||||
}
|
||||
|
||||
/* General DOM utilities */
|
||||
|
||||
/* Removes all the children of a node */
|
||||
function removeChildren(node) {
|
||||
while (node.hasChildNodes()) {
|
||||
node.removeChild(node.firstChild);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user