Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
Difference between revisions of "ETrice/GSoC/2012/GACL"
(→Disambiguation) |
(→Useful Links) |
||
(24 intermediate revisions by the same user not shown) | |||
Line 17: | Line 17: | ||
*Casts corresponding to static casts in C . | *Casts corresponding to static casts in C . | ||
− | === Thoughts on Syntax | + | === Thoughts on Syntax & Grammar === |
Although syntax for GACL is still being designed but here are few thought regarding syntax . | Although syntax for GACL is still being designed but here are few thought regarding syntax . | ||
− | + | ==== TypeDeclaration ==== | |
− | + | ===== Syntax ===== | |
− | + | type prt type xyz int | |
+ | type pqr { int Hello , char ch , prt p , op f1:int() , op f2:char(char,char) } type pqr' {pqr e1} | ||
+ | prt {pqr p}; | ||
− | + | ===== Action ===== | |
− | * | + | *Declares a type prt ended with whitespace |
+ | *Creates a type xyz same as int where type declaration ended with newline | ||
+ | *Creates a type pqr representing a structure rather class with abstracted elements Hello of type int , ch of char , p of type prt and f1 and f2 of type op i.e. Operations . f1 and f2 can take use of their arguments and also other elements of pqr i.e. Hello and ch in this case and ended with a tab . | ||
+ | *Creates a type pqr' with e1 of pqr abstracted in it ended with newline | ||
+ | *Creates prt declared already with p of type pqr abstracted in it ended with semicolon | ||
− | + | ===== Grammar ===== | |
− | + | { "type" typename [ existingtype | "{" TypeCode "}" ] [";" | "\n" | "\t" | " "] } | {typename typecode} | |
− | + | ==== VariableDeclaration ==== | |
− | + | ===== Syntax ===== | |
− | + | int x | |
+ | y; | ||
+ | y=2 x=y | ||
+ | x=x+4 y=y+0.5 | ||
− | + | ===== Action ===== | |
− | + | *Declares a variable x of type int , declaration ended with newline . | |
+ | *Declares a variable y , declaration ended with semicolon . | ||
+ | *Instantiate a variable y with value of 2 (2 as expression) (Value of 2 would be type checked and its type would be assigned to y unless and until there exists another assignment of y with type which can be type casted into type of value) instantiation ended with "\t" | ||
+ | *Instantiate a variable x with value of expression y which is currently 2 . | ||
+ | *Assigns variable x with value of expression x+4 which would be solved and accordingly value of x would be assigned | ||
+ | *Assigns variable y with value of expression x+0.5 which would be solved and accordingly value of y would be assigned (In this case type of y would be changed actually while writing it would be statically analyzed whether we need to type cast y and is it possible to type cast ) . | ||
− | + | ===== Grammar ===== | |
− | { Expression | | + | [ [[ETrice/GSoC/2012/GACL#Type_Declaration|type]] ] varname [ "=" { varname2 | [[ETrice/GSoC/2012/GACL#Expression|Expression]] } ] { ";" | "\n" | "\t" | " "} |
− | + | ==== Expression ==== | |
− | + | ===== Syntax ===== | |
− | + | x+4 | |
+ | y==z | ||
− | { StatementList} | + | ===== Action ===== |
+ | |||
+ | *First One is an example of arithmetic expression and would have same action as it have for an arithmetic expression . | ||
+ | *Second One is an example of Logical expression and it would have same action as it have for a logical expression . | ||
+ | |||
+ | ===== Grammar ===== | ||
+ | |||
+ | { [[ETrice/GSoC/2012/GACL#ArithmeticExpression|ArithmeticExpression]] | [[ETrice/GSoC/2012/GACL#LogicalExpression|LogicalExpression]] } | ||
+ | |||
+ | ==== ArithmeticExpression ==== | ||
+ | |||
+ | ===== Syntax ===== | ||
+ | |||
+ | { [[ETrice/GSoC/2012/GACL#Expression|Expression]] { "+" | "-" | "*" | "/" | "**" | "^" | "%" | "div" } [[ETrice/GSoC/2012/GACL#Expression|Expression]] } | ||
+ | | {[[ETrice/GSoC/2012/GACL#Expression|Expression]] { "++" | "--" } } | { { "++" | "--" } [[ETrice/GSoC/2012/GACL#Expression|Expression]] } | ||
+ | |||
+ | ==== LogicalExpression ==== | ||
+ | |||
+ | ===== Syntax ===== | ||
+ | |||
+ | ===== Action ===== | ||
+ | |||
+ | ===== Grammar ===== | ||
+ | |||
+ | { [[ETrice/GSoC/2012/GACL#Expression|Expression]] { "<" | "<=" | "==" | ">" | ">=" | "|" | "||" | "&" | "&&" | "^" } [[ETrice/GSoC/2012/GACL#Expression|Expression]] } | ||
+ | |||
+ | ==== Statement ==== | ||
+ | |||
+ | ===== Syntax ===== | ||
+ | |||
+ | ===== Action ===== | ||
+ | |||
+ | ===== Grammar ===== | ||
+ | |||
+ | { [[ETrice/GSoC/2012/GACL#TypeDeclaration|TypeDeclaration]] | [[ETrice/GSoC/2012/GACL#VariableDeclaration|VariableDeclaration]] | [[ETrice/GSoC/2012/GACL#Expression|Expression]] } | ||
+ | |||
+ | ==== StatementList ==== | ||
+ | |||
+ | ===== Syntax ===== | ||
+ | |||
+ | ===== Action ===== | ||
+ | |||
+ | ===== Grammar ===== | ||
+ | |||
+ | { [[ETrice/GSoC/2012/GACL#Empty|Empty]] | [[ETrice/GSoC/2012/GACL#Statement|Statement]] { { "\n" | "\t" | " "}* } [[ETrice/GSoC/2012/GACL#Statementlist|Statementlist]] } | ||
+ | |||
+ | ==== Program ==== | ||
+ | |||
+ | ===== Syntax ===== | ||
+ | |||
+ | ===== Action ===== | ||
+ | |||
+ | ===== Grammar ===== | ||
+ | |||
+ | { [[ETrice/GSoC/2012/GACL#Statementlist| Statementlist]] } | ||
<br> | <br> | ||
− | == Disambiguation == | + | == Disambiguation == |
The syntax used to specify the grammar in brief is | The syntax used to specify the grammar in brief is | ||
− | *Things written in double quotes ("") stand as string written in source . | + | *Things written in double quotes ("") stand as string written in source . |
*Content inside braces ({}) represents required content . | *Content inside braces ({}) represents required content . | ||
− | *Content inside square brackets ([]) represents optional content . | + | *Content inside square brackets ([]) represents optional content . |
− | *Everything rest is either terminal or non-terminals . | + | *Everything rest is either terminal or non-terminals . |
*Empty and statement list need a more thought to be done . We would surely finally come up with a better solution . | *Empty and statement list need a more thought to be done . We would surely finally come up with a better solution . | ||
Line 82: | Line 151: | ||
*[http://github.com/hckkid My Github profile page] | *[http://github.com/hckkid My Github profile page] | ||
*[http://www.eclipse.org/forums/eclipse.etrice eTrice Forums page] | *[http://www.eclipse.org/forums/eclipse.etrice eTrice Forums page] | ||
+ | |||
+ | [[Category:eTrice]] |
Latest revision as of 05:41, 20 April 2013
Contents
- 1 Generic Action Code Language (GACL)
- 2 Development Details and Core Information
- 3 Disambiguation
- 4 Project Proposal
- 5 Useful Links
Generic Action Code Language (GACL)
GACL is the language to describe the Detail Code for execution of ROOM Models in eTrice plugin . GACL aims at dealing with all features commonly available in imperative languages , especially Java , C/C++ . It will act as complement of current version of eTrice which uses code written in target language stored in a string as execution code . GACL would make user able to write execution code independent of target language .
Development Details and Core Information
Features of GACL
- Variable Declarations ( with optional initializers ) and Function Declaration .
- Comparison & arithmetic expressions .
- Basic types , and user defined types .
- If-else blocks and ladders .
- For , while , for each , enhanched for each .
- Support for iterators (that can be used by for each loops ) .
- Function Calls with arguments & diff types i.e. ref/value/address .
- type checking and as much as possible implicit type casting .
- Casts corresponding to static casts in C .
Thoughts on Syntax & Grammar
Although syntax for GACL is still being designed but here are few thought regarding syntax .
TypeDeclaration
Syntax
type prt type xyz int type pqr { int Hello , char ch , prt p , op f1:int() , op f2:char(char,char) } type pqr' {pqr e1} prt {pqr p};
Action
- Declares a type prt ended with whitespace
- Creates a type xyz same as int where type declaration ended with newline
- Creates a type pqr representing a structure rather class with abstracted elements Hello of type int , ch of char , p of type prt and f1 and f2 of type op i.e. Operations . f1 and f2 can take use of their arguments and also other elements of pqr i.e. Hello and ch in this case and ended with a tab .
- Creates a type pqr' with e1 of pqr abstracted in it ended with newline
- Creates prt declared already with p of type pqr abstracted in it ended with semicolon
Grammar
{ "type" typename [ existingtype | "{" TypeCode "}" ] [";" | "\n" | "\t" | " "] } | {typename typecode}
VariableDeclaration
Syntax
int x y; y=2 x=y x=x+4 y=y+0.5
Action
- Declares a variable x of type int , declaration ended with newline .
- Declares a variable y , declaration ended with semicolon .
- Instantiate a variable y with value of 2 (2 as expression) (Value of 2 would be type checked and its type would be assigned to y unless and until there exists another assignment of y with type which can be type casted into type of value) instantiation ended with "\t"
- Instantiate a variable x with value of expression y which is currently 2 .
- Assigns variable x with value of expression x+4 which would be solved and accordingly value of x would be assigned
- Assigns variable y with value of expression x+0.5 which would be solved and accordingly value of y would be assigned (In this case type of y would be changed actually while writing it would be statically analyzed whether we need to type cast y and is it possible to type cast ) .
Grammar
[ type ] varname [ "=" { varname2 | Expression } ] { ";" | "\n" | "\t" | " "}
Expression
Syntax
x+4 y==z
Action
- First One is an example of arithmetic expression and would have same action as it have for an arithmetic expression .
- Second One is an example of Logical expression and it would have same action as it have for a logical expression .
Grammar
{ ArithmeticExpression | LogicalExpression }
ArithmeticExpression
Syntax
{ Expression { "+" | "-" | "*" | "/" | "**" | "^" | "%" | "div" } Expression } | {Expression { "++" | "--" } } | { { "++" | "--" } Expression }
LogicalExpression
Syntax
Action
Grammar
{ Expression { "<" | "<=" | "==" | ">" | ">=" | "|" | "||" | "&" | "&&" | "^" } Expression }
Statement
Syntax
Action
Grammar
{ TypeDeclaration | VariableDeclaration | Expression }
StatementList
Syntax
Action
Grammar
{ Empty | Statement { { "\n" | "\t" | " "}* } Statementlist }
Program
Syntax
Action
Grammar
{ Statementlist }
Disambiguation
The syntax used to specify the grammar in brief is
- Things written in double quotes ("") stand as string written in source .
- Content inside braces ({}) represents required content .
- Content inside square brackets ([]) represents optional content .
- Everything rest is either terminal or non-terminals .
- Empty and statement list need a more thought to be done . We would surely finally come up with a better solution .
Project Proposal
Click Here to see the project proposal at gsoc's website .
Click Here to see the project proposal in my github repository .