Lengkap

Working with FLEX++ & BISON+++

Lexical Analysis

Syntax of a mini programming language is described by the following grammar (upper case is used to show variables in the grammar):

Grammar G

PROGRAM  program DECLARATIONS ; STATEMENTS end

DECLARATIONS  DECLARATION | DECLARATION; DECLARATIONS

DECLARATION  VARIABLES_LIST : TYPE

TYPE  real | integer

VARIABLES_LIST  VARIABLE | VARIABLES_LIST , VARIABLE

VARIABLE  id | id [int_number]

STATEMENTS  STATEMENT | STATEMENT; STATEMENTS

STATEMENT  RECEIVER = EXPRESSION

|

if CONDITION then STATEMENTS else STATEMENTS end_if

|

loop STATEMENTS until CONDITION end_loop

|

start DECLARATIONS ; STATEMENTS end

RECEIVER  id | id[EXPRESSION]

EXPRESSION  number | id | id[EXPRESSION] |

id ar_op EXPRESSION

CONDITION  EXPRESSION rel_op EXPRESSION

Groups of tokens:

keywords: are shown in bold

ar_op : arithmetic operations - addition (+) or multiplication (*)

rel_op : comparison operations < , <= , == , != , > , >=

id : - may contain letters (lower and upper case) and digits

- can start only with letter

- may contain underscores (קו תחתון) for example: ab_cd_ef;

- several underscores can not appear one after another (for example ab___cd is

not a legal id)

- id can not end with underscore (for example ab_ is illegal)

int_number : - unsigned integer (e.g. 123)

number : - can be integer (e.g. 123) or real fixed point (e.g. 12.345)

- can be only unsigned

separation signs: colon , semicolon, brackets: [ ]

Comments

At every place in the program, a comment can be placed:

- comment starts with /*

- comment ends with */

Tasks

1. Implement lexical analyzer (using FLEX), as follows:

- Lexical analyzer will read text from the input file and identify tokens. This

happens when function Next_Token is called.

- When a token is identified in the input text, it should be stored in a data

structure. For each token, the following attributes are saved:

* token type

* token lexeme

* number of the line in the input text in which this token was found.

- Comments, blanks, tabs, new lines – are not tokens, and should be ignored

- For each token, print (on a separate line) its type and lexeme

2. Error handling:

- Lexical errors: when the lexical analyzer finds a symbol that doesn't start

any legal token, it prints an appropriate message

- Each error message includes information on the relevant line number (so that

the user can easily localize the place in input where the error occurs).

3. Structure of implementation:

- a file with FLEX definitions (from which the tool will generate LEXYY.c);

it contains:

* regular expressions that describe tokens of the language;

* actions that lexical analyzer should perform when it identifies tokens in the

input text

- .H file containing token definitions (token structure, list of token types)

- .C and .H files (module) that provides services related to creation and storage

of tokens; it should provide the following services:

create_and_store_token

next_token

back_token

Kemahiran: Pengaturcaraan C, Pengaturcaraan C++

Lihat lagi: variables in programming, using regular expressions, using regular expression, unsigned integer, types of programming language, types of programming errors, types data structure, type of data structure in c, syntax programming, syntax in programming, regular expression using, regular expression starts with, regular expressions list, regular expressions in c, regular expressions example, regular expressions c, regular expression or example, regular expression integer, regular expression function, regular expression for integer

Tentang Majikan:
( 2 ulasan ) tel aviv, Israel

ID Projek: #10115163

Dianugerahkan kepada:

prince2502

I have been using YACC (Bison) and LEX (FLEX) since I was in my grad. I have worked on more parsers in my life than I had crushes in high school. I have worked with LR parsers, LL, SLR parsers. Infact my last proje Lagi

$55 USD dalam 2 hari
(19 Ulasan)
4.6

4 pekerja bebas membida secara purata $90 untuk pekerjaan ini

SyntaX5

We have seen your requirements and totally understand them. We promise to deliver you the best solution for your project. We have an excellent team that will be dedicated to working on your project. We have been workin Lagi

$120 USD dalam 3 hari
(2 Ulasan)
3.4
kliopk

<<<< Please chat first i can help you low budget >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ((((((((((((((((((((((((((((((((((((((((((((((((((((((((((())))))))))))))))))))))))))))))))))))

$30 USD dalam sehari
(0 Ulasan)
0.0
metasoft7

Dear Prospect Hiring Manager. Thank you for giving me a chance to bid on your project. i am a serious bidder here and i have already worked on a similar project before and can deliver as u have mentioned I have c Lagi

$155 USD dalam 3 hari
(1 Ulasan)
0.0