GitXplorerGitXplorer
r

generatejs

public
9 stars
2 forks
0 issues

Commits

List of commits on branch master.
Unverified
3673343fd4a7806a7639396eb01cc17b436e3cc7

added a cabal update to make the build more likely to succeed

rrictic committed 14 years ago
Unverified
8dff07883b9eedd4e68a8ee9f8526d92ec63dd99

what a silly error

rrictic committed 14 years ago
Unverified
724ac417abc01922f743bd90c3fda93c750b5b9d

Updated readme with --stdout option

rrictic committed 15 years ago
Unverified
420a82320c803044a568425f1b410896a311cd84

Case sensitivity!

rrictic committed 15 years ago
Unverified
a148d5902551a0b2273f419d5272cad925ff9237

Applied hlint suggestions

rrictic committed 15 years ago
Unverified
2bb417d15a84df196705ba98257b4ce5478aaf71

Added option --stdout which prints programs one per line to stdout

rrictic committed 15 years ago

README

The README file for this repository.

Javascript Generator

A program for generating widely varied, syntactically valid Javascript source code conforming to the ECMA-262 Standard.

Requires Haskell, easily installed at The Haskell Platform

Getting the Code

The latest version of the code can always be gotten from github, either by cloning it with git:

git clone git://github.com/rictic/generatejs.git
cd generatejs

Or by downloading a tarball:

curl -L http://github.com/rictic/generatejs/tarball/master > generatejs.tar.gz
tar -xzf generatejs.tar.gz
cd *generatejs*/

Installation

Installation should be as simple as

cabal update && cabal install

Running

generatejs [--stdout] <number-of-programs-to-create>

If you include --stdout, the programs are written to standard out, one to a line.

Otherwise it will create a directory gen/ in your current directory. This directory will in turn be filled with numbered subdirectories, each of which holds up to 20000 numbered js programs. This is done to keep the filesystem from freaking out from too many files in any one directory.

Hacking

The command line runner is in generateJS.hs, the actual generation code is in jsgenerator.js.

The code is written in a declarative style, with a pretty direct mapping from the productions in the standard to Symbols in the code.

i.e. the production

SignedInteger ::: 
    DecimalDigits
    + DecimalDigits
    - DecimalDigits

becomes

signedInteger = Nonterminal [
    [decimalDigits],
    [Terminal "+", decimalDigits],
    [Terminal "-", decimalDigits]]

I found it helpful to construct a few Symbols with Terminal and Nonterminal and pass the result to getAll until I was sure I had it worked out.