Giter VIP home page Giter VIP logo

plc's Introduction

OVERVIEW ✨

This documentation contains general semantic rules and briefly summarizes details regarding the lexical analyzer.

GOAL 🎯

The semantic for the language was designed to be readable and easy to learn

How to run

flex mohi.l
bison mohi.y -d
gcc mohi.tab.c -lfl -o mohi
./mohi
Note: input3.mpl should generate an error

Variables

Types

  • number: represents integers and float numbers.
  • text: represents all alphabet characters singular, or plural

Variables declaration
all variables identifiers should start with an underscore and every statement should end with a newline, no semicolons needed.

Variables assignment
assignment can be done upon declaration or in a new statement

example:
number _apples
_apples = 5000
or
number _trees = _apples / 50

Arithmatic operations

  • + addition operator
  • - substraction operator
  • * multiplication operator
  • / division operator

example:
number _x = 5 * 4

Boolean expressions & Comparison operators

equals checks for equality between two variabls
not equals checks for inequality between two variables
bigger than returns true if left hand variable is bigger than the right hand variable
less than returns true if the left hand variable is less than the right hand variable

example
number _students = 5
number _teachers = 4
_students equals _teachers should evaluate to false

IF/ELSE Statement

semantic and structure
if expression
      statements
if not
      statements

example
if _x equals 5
      _x = _x + 1
if not
      _x = 5

While Loop

semantic and structure
while expression
      statements

example
while _age bigger than 18
      _adults = _adults + 1

Presedence Rules

/ * - + left to right
equals, not equals, bigger than, less than left to right

plc's People

Contributors

mohi2code avatar

Watchers

 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.