'e' Basics Part-I

Print

Lexical Conventions
Since e language was developed based on other programming languages, Most of the syntax is more or less same as other programming language. So if you know lexical conventions of C++ or C, then you can follow e language without any problem.

File Structures

e files should have .e as extension.
Example

1 <'

 2

 3 import hello_world.e;

 4 import memory;

 5

 6 // Rest of the code

 7

 8

 9 '>
As you see, first file has .e extension and second file does not. Well in e language, we don't need to specify the extension of e file, the compiler assumes .e as extension.

Within file, we can have code segments. Beginning of code segment is marked with <' and end of code segment is marked with '> . And code that does not fall within this code segments are treated as comments

  1 // Anything here is comment
  2 <'
  3 //Code here
  4 
  5 
  6 
  7 '>
  8 
  9 //This is also comment
 10 
 11 <'
 12 //Code continue
 13 
 14 '>

White Spaces and Comments

White spaces are same as in any programming languages, you can refer to Verilog tutorial section if you need to know more on this.

As of comments, in e language, we can comment code in three ways

·         1 <'

·         2 -- Single line comment

·         3 // This is also single line comment

·         4

·         5 //Code here

·         6

·         7 '>

·         8 Multipe line comment

·         9 So ignored

·        10

·        11 <'

·        12 //Code continue..

·        13

·        14 '>

Literals and Constants

·         1

·         2 <'

·         3 // Example of numeric values

·         4 struct abc {

·         5 data : int ;

·         6

·         7   my_method () is {

·         8    // Unsigned numbers

·         9    data = 0x1; // Hexadecimal

·        10    data = 33;  // Decimal

·        11    data = 0b11111_00000;//Binary

·        12    data = 0o777_333; // Octal

·        13    // Signed numbers

·        14    data = 32'hDEAD_BEAF; // 32 bit Hexadecimal

·        15    data = 8'd33; // 8 bit decimal

·        16    data = 9'b1111_0000; // 8 bit binary

·        17    data = 18'o777_333; // 18 bit Octal

·        18    // Kilo and Mega

·        19    data = 1K; // 1024

·        20    data = 5M; // 1024*1024*5

·        21   };

·        22

·        23 };

·        24 '>

 Bạn Có Đam Mê Với Vi Mạch hay Nhúng      -     Bạn Muốn Trau Dồi Thêm Kĩ Năng

Mong Muốn Có Thêm Cơ Hội Trong Công Việc

Và Trở Thành Một Người Có Giá Trị Hơn

Bạn Chưa Biết Phương Thức Nào Nhanh Chóng Để Đạt Được Chúng

Hãy Để Chúng Tôi Hỗ Trợ Cho Bạn. SEMICON  

Last Updated ( Tuesday, 03 May 2022 19:53 )