Skip to content

Instantly share code, notes, and snippets.

@jeremyroman
Created February 8, 2011 04:24
Show Gist options
  • Save jeremyroman/815849 to your computer and use it in GitHub Desktop.
Save jeremyroman/815849 to your computer and use it in GitHub Desktop.
One possible way of describing languages
languages = {
"C": {
'main_file': "{bot}.c",
'nuke_globs': ["*.o", "{bot}"],
'compile': [
System("gcc -O3 -c {file}", glob="*.c"),
System("gcc -O2 -lm -o {bot}", glob="*.o"),
],
'run': "./{bot}",
},
"C#": {
'main_file': "{bot}.cs",
'nuke_globs': ["{bot}.exe"],
'compile': System("gmcs -warn:0 -out:{bot}.exe", glob="*.cs"),
'run': "mono ./{bot}.exe",
},
"C++": {
'main_file': ["{bot}.cc", "{bot}.cpp", "{bot}.cxx"],
'nuke_globs': ["*.o", "{bot}"],
'compile': [
System("g++ -O3 -c {file}", glob=["*.c","*.cc","*.cpp","*.cxx"]),
System("g++ -O2 -lm -o {bot}"),
],
'run': "./{bot}",
},
"Clojure": {
'main_file': "{bot}.clj",
'run': "clojure {bot}.clj",
},
"CoffeeScript": {
'main_file': "{bot}.coffee",
'run': "coffee {bot}.coffee",
},
"Go": {
'main_file': "{bot}.go",
'nuke_globs': ["*.8", "{bot}"],
'compile': [
System("8g -o _go_.8", glob="*.go"),
System("8l -o {bot} _go_.8"),
],
'run': "./{bot}",
},
"Groovy": {
'main_file': "{bot}.groovy",
'nuke_globs': ["*.class", "*.jar"],
'compile': [
System("groovyc", glob="*.groovy"),
System("jar cfe {bot}.jar {bot}"),
],
'run': "java -cp {bot}.jar:/usr/share/groovy/"
"embeddable/groovy-all-1.7.0.jar {bot}",
},
"Haskell": {
'main_file': "{bot}.hs",
'nuke_globs': ["{bot}"],
'compile': System("ghc --make {bot}.hs -O2 -v0"),
'run': "./{bot}.hs",
},
"Java": {
'main_file': "{bot}.java",
'nuke_globs': ["*.class", "*.jar"],
'compile': [
System("javac", deepglob="*.class"),
System("jar cfe {bot}.jar {bot}"),
],
'run': "java -jar {bot}.jar",
},
"JavaScript": {
'main_file': "{bot}.js",
'run': "node {bot}.js",
},
"Lisp": {
'main_file': "{bot}.lisp",
'nuke_globs': ["{bot}"],
'compile':
System("sbcl --end-runtime-options --no-sysinit --no-userinit "
"--disable-debugger --load {bot}.lisp --eval "
"(save-lisp-and-die \"{bot}\" :executable t :toplevel "
"#'bot::main)"),
'run': "./bot",
},
"Lua": {
'main_file': "{bot}.lua",
'run': "lua {bot}.lua",
},
"OCaml": {
'main_file': "{bot}.ml",
'nuke_globs': ["{bot}native"],
'compile': System("ocamlbuild {bot}.native"),
'run': "./{bot}.native",
},
"Perl": {
'main_file': "{bot}.pl",
'run': "perl {bot}.pl",
},
"PHP": {
'main_file': "{bot}.php",
'run': "php {bot}.php",
},
"Python": {
'main_file': "{bot}.py",
'nuke_globs': ["*.pyc"],
'run': "python {bot}.py",
},
"Ruby": {
'main_file': "{bot}.rb",
'run': "ruby {bot}.rb",
},
"Scala": {
'main_file': "{bot}.scala",
'nuke_globs': ["*.class", "*.jar"],
'compile': System("scalac", glob="*.scala"),
'run': "scala {bot}"
},
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment