<commit_before># DCPU-Bas

DCPU-Bas is a simple QuickBASIC-like compiler for virtual DCPU in Notch's [0x10c Game](http://www.0x10c.com), written in [Go language](http://golang.org).
Compiler structure and engine is heavily inspired by [Let's Build a Compiler, by <NAME>](http://compilers.iecc.com/crenshaw/).

## Features

* Arithmetics: + - * /
* Boolean operators: & ~ !
* Relational operators: == <> < > <= >=
* Control structures: IF, WHILE
* Variables (integer only for now)
* Statements: CLS, LOCATE, PRINT

### IF

Usage:
	IF _condition_ THEN
		...
	[ELSE
		...]
	END IF

Executes a code block if _condition_ is met. Optional ELSE block executed if _condition_ is NOT met.

### WHILE

Usage:
	WHILE _condition_
		...
	END WHILE

Loops through a code block when _condition_ is met.

### CLS

Usage:
	CLS

Clears whole 32x16 screen (video buffer at 0x8000)

### PRINT

Usage:
	PRINT _expression_

Prints _expression_ at current screen cursor location

### LOCATE

Usage:
	LOCATE _Y_[, _X_]

Sets current cursor location to _X_, _Y_. Set's only _Y_ if _X_ is not provided.

### END

Program MUST end with an END statement.

## Sample Program

	VAR A, B, C, D
	A = 5
	B = 20+A*10
	C = B - 6
	D = C
	WHILE D > 0
		D = D / 10
		PRINT 0
	END WHILE
	PRINT C / 2
	END

This program declares three variables, then does some math, and finally prints the result (which is 32) to video memory.
You can test the program with some web based emulators: [Donzanoid's real-time editor](http://dwilliamson.github.com/) or [Mappum's emulator](http://mappum.github.com/DCPU-16/).
Output of the program isn't pretty, but hey, it works!

## More complex sample program

This little program gets a number, then pads it with 0's. There's a variable 'big' that let's you choose if you want
a big or small number.

	VAR num, pad, test, big

	big = 1

	pad = 4
	test = 1

	IF big == 1 THEN
		num = 32
	ELSE
		num = 9
	END IF

	WHILE pad <> 0
		pad = pad - 1
		test = test * 10
	END WHILE

	pad = num

	WHILE pad < test
		pad = pad * 10
		PRINT 0
	END WHILE

	PRINT num

	END

## Licence

This code is licenced on the terms of the [http://www.opensource.org/licenses/mit-license.php](MIT Licence).<commit_msg>I suck at GIT and Markdown (README corrections)<commit_after># DCPU-Bas

DCPU-Bas is a simple QuickBASIC-like compiler for virtual DCPU in Notch's [0x10c Game](http://www.0x10c.com), written in [Go language](http://golang.org).
Compiler structure and engine is heavily inspired by [Let's Build a Compiler, by <NAME>](http://compilers.iecc.com/crenshaw/).

## Features

* Arithmetics: + - * /
* Boolean operators: & ~ !
* Relational operators: == <> < > <= >=
* Control structures: IF, WHILE
* Variables (integer only for now)
* Statements: CLS, LOCATE, PRINT

### IF

Usage:
	IF _condition_ THEN
		...
	[ELSE
		...]
	END IF

Executes a code block if _condition_ is met. Optional ELSE block executed if _condition_ is NOT met.

### WHILE

Usage:
	WHILE _condition_
		...
	END WHILE

Loops through a code block when _condition_ is met.

### CLS

Usage:
	CLS

Clears whole 32x16 screen (video buffer at 0x8000)

### PRINT

Usage:
	PRINT _expression_

Prints _expression_ at current screen cursor location

### LOCATE

Usage:
	LOCATE _Y_[, _X_]

Sets current cursor location to _X_, _Y_. Set's only _Y_ if _X_ is not provided.

### END

Program MUST end with an END statement.

## Sample Program

	VAR A, B, C, D
	A = 5
	B = 20+A*10
	C = B - 6
	D = C
	WHILE D > 0
		D = D / 10
		PRINT 0
	END WHILE
	PRINT C / 2
	END

This program declares three variables, then does some math, and finally prints the result (which is 32) to video memory.
You can test the program with some web based emulators: [Donzanoid's real-time editor](http://dwilliamson.github.com/) or [Mappum's emulator](http://mappum.github.com/DCPU-16/).
Output of the program isn't pretty, but hey, it works!

## More complex sample program

This little program gets a number, then pads it with 0's. There's a variable 'big' that let's you choose if you want
a big or small number.

	VAR num, pad, test, big

	big = 1

	pad = 4
	test = 1

	IF big == 1 THEN
		num = 32
	ELSE
		num = 9
	END IF

	WHILE pad <> 0
		pad = pad - 1
		test = test * 10
	END WHILE

	pad = num

	WHILE pad < test
		pad = pad * 10
		PRINT 0
	END WHILE

	PRINT num

	END

## Licence

This code is licenced on the terms of the [MIT Licence](http://www.opensource.org/licenses/mit-license.php).
{'fraction_non_alphanumeric': 0.10163339382940109, 'fraction_numerical': 0.02041742286751361, 'mean_word_length': 3.2231800766283527, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '33398', 'n_tokens_mistral': 1691, 'n_tokens_neox': 1513, 'n_words': 624}