Code Monkey home page Code Monkey logo

cfpl's Introduction

CFPL

An interpreter for the CIT-U First Programming Language written in Java.

CFPL is a very simple programming language that allows the programmer to achieve fluency in minutes. It is a strongly typed programming language.

From the sample program written below:

* my first program in CFPL
VAR abc, b, c AS INT
VAR x, w_23=’w’ AS CHAR
VAR t=”TRUE” AS BOOL
START
  abc=b=10
  w_23=’a’
  * this is a comment
  OUTPUT: abc & “hi” & b & “#” & w_23 & “[#]”
STOP

The console should show:

10hi10
a#

Language Grammar

Program Structure:

  • every line contains a single statement
  • all variable declaration is found on top of the program
  • a line that starts with asterisk(*) is considered as a comment and comment can be found in any part of the program
  • executable code should be found inside the START and STOP block
  • all reserved words are in capital letters
  • sharp sign(#) signifies next line or carriage return
  • ampersand(&) serves as a concatenator
  • the square braces([]) are as escape code

Data Types:

  1. INT – an ordinary number with no decimal part. It uses 32 bits. It can be positive or negative.
  2. CHAR – a single symbol. It uses UNICODE.
  3. BOOL – represents the literals true or false.
  4. FLOAT – a number with decimal part. It uses 64 bits.

Operators: Arithmetic operators

  1. ( ) - parenthesis
  2. *, /, % - multiplication, division, modulo
  3. +, - - addition, subtraction
  4. >, < - greater than, lesser than
  5. >=, <= - greater than or equal to, lesser than or equal to
  6. ==, <> - equal, not equal

Logical operators ()

  1. AND - needs the two BOOL expression to be true to result to true, else false
  2. OR - if one of the BOOL expressions evaluates to true, returns true, else false
  3. NOT - the reverse value of the BOOL value

Unary operator

  1. + - positive
  2. - - negative

cfpl's People

Contributors

papelias avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.