C2JS
C2JS
A C COMPILER
ADVISORS:
MR. MAHMOOD SIDDIQUE (INTERNAL) MR. BILAL GHAFFAR (EXTERNAL)
Members:
C2JS - CORE
A C compiler that compiles (translates) C source into JavaScript source.
Sourc e Targe t
.C
C2JS
.JS
Desired result will be achieved by defining syntax level equivalence between C & JavaScript languages.
Support for C language standard library (ANSI C) will be provided.
C2JS RUNTIME
The generated JavaScript source could very well be executed in a JavaScript engine, whether it is inside a browser or any desktop based runtime environment.
Sourc e Targe t
100110 001001 111010
.JS
RISE OF C
IMPORTANCE OF JAVASCRIPT
Browser support NodeJS
JavaScript on the Desktop JavaScript on embedded Devices JavaScript on server scale machinery
PhoneGap
JavaScript on the smart phones (iOS, Android, BlackBerry,
Windows Phone)
WHY C TO JS?
Cross Platform Executes in the browser Rapid Prototyping for C Bridges the gap between C & JS learning Opens C to JS ecosystem Enables the possibility of a web framework
JAVASCRIPT ECOSYSTEM
Apple iTunes Store
(till 2013) : 40 billion apps downloaded
Google Play
2013)
:
:
(till
(till
C VALIDATE EMAIL
int isemail (char *email) { int atsign = -1, dot = -1, i = 0; if (! isalpha(email[0]) ) return 0;
int length = strlen(email); for (i = 0; i < length; i++) { if (email[i] == '@') { if (atsign == -1) atsign = i; else return 0; }
Browser based Integrated Development Environment Efficient Mapping between C & JS libraries Management of the local compilation & execution
MOTIVATION
Add C to the list of languages that compile down to JS Abstract the compilation from user space Provide a way to rapidly develop C & JS applications Enable C developers to become stakeholders of JS
ecosystem
RELATED PRODUCTS
Overview of a compiler
RELATED PRODUCTS
Overview of a compiler
Sourc e
Lexer Parse r Optimizer
Front-End
Semantic Analyzer
IR
Back-End
Code Generator
Targe t
RELATED PRODUCTS
Emscripten
Assumes that the input file is syntactically correct.
Source Targe t
Corre ct.C
Emscripten
.JS
RELATED PRODUCTS
C2JS vs Emscripten
Sourc e
Lexer
Parse r
Optimizer
Targe t
.C
Front-End
Semantic Analyzer
IR
Back-End
Code Generator
.JS
.C
RELATED PRODUCTS
ONLINE C COMPILERS
.C
Cloud
[C compiler]
.ex e
Cloud
User Browser
Program Input
Program Output
[C Runtime]
Progra m Input
User Browser
[C2JS web-page]
Program Output
PROJECT PLAN