/sim-c1

A dynamically typed high-level front end for C

Primary LanguagePythonGNU General Public License v3.0GPL-3.0

sim-C

GitHub GitHub stars GitHub contributors PRs Welcome GitHub last commit GitHub issues GitHub closed issues GitHub closed pull requests

What is sim-C?

Often people have trouble programming in C (especially beginners) due to its low level syntax and unavailability of stable third party libraries. We present sim-C a high-level front end for C which creates a dynamically typed syntax for C. User can write code in this high level syntax and then compile it to optimized C code. sim-C does not process the code and simply translates it to C thus, there is no possibility of the code running slowly. So, with sim-C users can write code faster using the high level syntax and at the same time be able to harness the power and speed of a C program. Let us make C cool again.

Pipeline

Discussion

For doubts related to implementation of a feature or to know more about future releases join the official subreddit - r/cimplec.

New Developers

New developers can join simC New Devs slack channel where they can get help from core developers on their issues, link to the slack channel - simC New Devs Slack

Start Contributing

sim-C which has a highly intuitive codebase, you'll be ready to contribute in no time! While adding any functionality to sim-C you need to make changes in the following files only:

1. lexical_analyzer.py Lexical analysis is the first phase of a compiler. It takes the modified source code from language preprocessors that are written in the form of sentences. The lexical analyzer breaks these syntaxes into a series of tokens, by removing any whitespace or comments in the source code. Depending on the type of functionality add it to the respective function: is_keyword, numeric_val, string_val, keyword_identifier and/or lexical_analyze.

2. op_code.py It is responsible for creating opcodes. If need be you need to change the opcode2dig function only which returns the integer representation of opcode type.

3. simc_parser.py Parser is an interpreter component that is used to break the data into smaller elements coming from lexical analysis phase. A parser takes input in the form of sequence of tokens and produces output. Here you may need to create a separate function which defines the grammar and checks for the syntax. The function should return the OpCode. Also, if need be you have to append the functionality to the parse function which parses the tokens, calls the particular function and returns opcodes.

4. compiler.py Finally you need to define the opcode type in the compiler and write the expected C syntax for the functonality.

You can write a test in test.simc and verify whether it's producing results in the test.c file.

Contributing

To get started with simC follow the official documentation:- https://cimplec.github.io/docs/

The following resources are a good place to get to know more about simC:-

  1. Writing code in C? Simplify your life with sim-C Dev.to, Medium.
  2. Getting Started with sim-C Dev.to, Medium.

Apart from these blog posts, you can also checkout the official docs.

License

sim-C is licensed under GNU General Public License (GPL) v3.0. LICENSE

The Team