Agda as a programming language [closed] - documentation

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 5 years ago.
Improve this question
I have found a lot of useful information on using Agda as a proof system. I have found virtually no information on using Agda to write usable programs. I cannot even find a "hello world" example that compiles with the most recent version of Agda.
So,
Are there any good tutorials on Agda as a programming language?
Are there other languages of a similar nature (lazy functional dependently typed) that have more mature documentation for using them as a programming language? (I found tons of great documentation on Coq, but, again, no "Hello World").

To print a string in Agda, you need the std lib. You can find a "hello world" example here for Agda 2.2.6 and std lib 0.3. This example doesn't work for current Agda 2.3.0 and std lib 0.6. I read some sources in std lib 0.6, and find that the following one works:
module hello where
open import IO.Primitive using (IO; putStrLn)
open import Data.String using (toCostring; String)
open import Foreign.Haskell using (Unit)
main : IO Unit
main = putStrLn (toCostring "Hello, Agda!")
To compile it, you need
save it to "./hello.agda"
download lib-0.6.tar.gz, and unpack it to somewhere, say DIR
cd DIR/ffi && cabal install
agda -i DIR/src -i . -c hello.agda
On my MacOSX Lion with ghc-7.4.2 and cabal-1.16.0, this example works fine. I get an executable program named "hello" with size 19.1M.

This is nascent, but one-day might become a useful resource:
https://github.com/liamoc/learn-you-an-agda

Related

Compiler for Dog programming language [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I recently came across a new programming language - "The Dog programming language"
I was searching for a compiler for this language.
I found an article about the Dog language.
I found a Dog compiler written in the Perl language but I don't know how to use it.
Thanks in advance!
How to use the Perl DOG compiler
Windows
First, install perl and make sure it is in your path:
Download it here: http://www.perl.org/get.html
You can use strawberry perl (possibly the other one too).
Then, download the compiler from http://viewsourcecode.org/code/perl/dog.txt and save it as dog.txt(you can actually name it whatever you want but these instructions assume you named it dog.txt).
Make a DOG source code file. Let's assume it is called helloworld.dog.
Here's some code you can put into helloworld.dog:
bark "Hello world!\n"
Run it in a terminal (command prompt):
perl dog.txt helloworld.dog
Linux/Mac/Unix
Download the compiler:
wget http://viewsourcecode.org/code/perl/dog.txt
Make it executable:
chmod +x dog.txt
Make a DOG source code file. Let's assume it is called helloworld.dog.
Here's some code you can put into helloworld.dog:
bark "Hello world!\n"
Run it:
./dog.txt helloworld.dog

Need help designing an interpreter [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 4 years ago.
Improve this question
i'm thinking on doing an undergrad project on building an interpreter for a simple/rudimentary custom language (perl / C like). I would be be glad if someone could point me in the right direction to start. Most of the books/resources i find are on theoretical implementation of compilers. Are there any resources aimed at interpreters ? i'm thinking of implementing it in C++, but have very little knowledge on the subject of interpreter design, so any pointers to books/references will be appreciated
The parsing of the source code is not very much different between a compiler and an interpreter. And that is what most textbooks on compilers are about.
There are some nice tools now to implement custom languages.
You might want to checkout Xtext in the Eclipse Modelling Package (http://www.eclipse.org) or MPS (http://www.jetbrains.com/mps/), the language workbench of IntelliJ which is freely available.
Both allow you to create languages and provide the tools to generate code from the source and the tooling to help creating the code.
They also create abstract syntax trees which may be directly manipulated, i.e. executed. Then you have an interpreter.
The classical approach would be to use bison/yacc for as a lexer, respectively parser, and many newer tools are currently available like antlr. The output of the parser is then again the abstract syntax tree ready to do interprete or generate code from.
An Incremental Approach to Compiler Construction - it's about creating compilers, but it might be a good starting point to find references from.
I wrote an interpreter for reading and converting logic expressions at Uni. Wrote it in C, Lexx and Yacc which old school Unix and C programmers seem to swear by. Pretty powerful once you get the hang of them, but reasonably steep learning curve I would say.
http://www.lugbe.ch/action/reports/lex_yacc.pdf

Favorite Documentation Generator system? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 6 years ago.
Improve this question
I'm a jack-of-all-trades-master-of-none programmer and as I jump around languages, quality consistent documentation is becoming more and more important to me. I've recently been using Doxygen, but Wikipedia reveals the usual ridiculous list of similar frameworks.
What is your favorite documentation generator and why? (Vote where you agree to keep it tidy!)
I use different files written in MediaWiki MarkUp, since this is easy to learn for everyone. I convert this to HTML and a CHM file, and to LaTeX for the PDF documentation.
This was the most painless way for me to generate Online documentation AND printable documentation in one strike with a simple way of input.
The tools I use are org.eclipse.mylyn.wikitext with a custom DocumentBuilder for LaTeX, the Microsoft Help compiler (which sadly only runs on windows), and a LaTeX distribution.
EDIT: I managed to get the Microsoft Help compiler running with Wine, so my Linux build server is now able to create the whole documentation automatically.

Do tools exist which automatically find copy-and-paste code? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 6 years ago.
Improve this question
Are there tools out there which could automatically find copy-and-paste code among a set of files?
I was thinking of writing a script for this, which would just search for equal strings, but such script would find mostly irrelevant equalities. (Such as private final static ...).
Yes, try the Copy Paste Detector.
Our CloneDR is a tool for finding exact and near-miss blocks of code constructed by copy and paste activities.
It can handle systems of millions of lines of code.
It uses precise language grammars to pick out language structures (identifiers, expressions, statements, blocks, functions, classes, packages, ...) that have been copied, and to determine the points of variation across the sets of clones (any of those structures can be parameters!)
CloneDR operates on a wide variety of languages: C, C++, C#, Java, PHP, COBOL, Python, Ada, Fortran, EGL and visual basic (VBScript, VB6, VB.net).
The website has a number of sample clone detection reports from a variety of those languages.
This product is available for evaluation on http://www.semanticdesigns.com. Other open source alternatives are Simian and PMD CPD
http://patterninsight.com/products/cp-miner.php
Related paper - http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.123.113
CloneDigger for Python and Java.

Lua's bytecode specification [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 5 years ago.
Improve this question
Can anyone tell me where to find Lua's bytecode specification? I've been searching for 15 minutes, and I can't find anything.
The official definition is in lopcodes.h.
Maybe A No-Frills Introduction to Lua 5.1 VM Instructions contains what you're looking for?
There is also a table of the Lua 5.0 instruction set (Figure 5) in:
Ierusalimschy, R.; Figueiredo, L. H.; Celes, W. (2005), "The implementation of Lua 5.0", J. of Universal Comp. Sci. 11 (7): 1159-1176
You can find the full text with a search on Google Scholar and I believe it's on lua.org as well. This reference is used by the Lua page on Wikipedia, which is always a good place to look for such things. :-)
The only specifications for Lua are the language, standard libraries, and the C API. The creators of Lua intentionally left the VM unspecified for a couple main reasons:
Lua can be fully implemented with any underlying architecture (VM, interpreter, compiler, etc.)
The official Lua distribution doesn't have to worry about maintaining VM compatibility between versions
This means, for example, that you generally shouldn't use the Lua VM as a target for a compiler. If you'd like to know how the official Lua distribution's VM works as an example for your own curiosity, see the other answers.
You can read The Implementation of Lua 5.0 online.