Skip to content
This repository was archived by the owner on Feb 17, 2024. It is now read-only.

QuinnCG/BCL

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BCL

A compiler for "Basic Command Language".

Basic Command Language is a personel experiment for generating IL code. It's not feature complete and provides terrible error messages. It was initially made in one afternoon; though there may be some fixes here and there.

BCL Example

var int x 5
var int y 7
var int result

call add x y result
call print result

Types:

  • int
  • long
  • float
  • double
  • string

Commands:

  • var [type] [name] [optiona-value]
  • call [func-name] [func-arg-1] [func-arg-2] [etc.]

Functions:

  • print [variable]
  • add [varA] [varB] [var-to-store-result]
  • subtract [varA] [varB] [var-to-store-result]
  • multiply [varA] [varB] [var-to-store-result]
  • divide [varA] [varB] [var-to-store-result]
  • read [var-to-store-result]
  • goto [label]
  • goto [label] [varA] [comparison-operator] [varB]
  • pause

Comparison Operators:

  • =: equals.
  • !: not equals.
  • >=: greater or equal.
  • <=: less or equal.
  • >: greater.
  • <: less.

Pogram Examples

Hello World

var string msg Hello World!
call print msg

Math

var int x 5
var int y 7

var int sum
var int difference
var int product
var int remainder

call add x y sum
call subtract x y difference
call multiply x y product
call divide x y remainder

call print sum
call print difference
call print product
call print remainder

For Loop

var int index 0
var int max 10
var int one 1

label start
call print index
call add index one index
call goto start index < max

If Statement

var int x 5
var int y 5

call goto true x = y
call goto false

label true
var string msgTrue True!
call print msgTrue
call goto end

label false
var string msgFalse False!
call print msgFalse

label end

About

A compiler for "Basic Command Language".

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages