Find Jobs
Hire Freelancers

Scanner

$30-5000 USD

Dokončeno
Zveřejněno před více než 20 roky

$30-5000 USD

Zaplaceno při doručení
Write a Complete compiler for a small language (implemented in C) The language for the project is a hybrid of C++ and Java. A program will consist of just one class, as a wrapper for the program. Code will be strictly procedural with no object instantiation. Class components will be public. Class will inherit from a common class Object (as in Java) but there will be no other inheritance Phase 1 is the scanner: Each call to the scanner should return the next token along with its value if needed. Also record the line number and starting character position on the line of each token. This is useful for error reporting. The input should be read from a text file. A driver program should be written that takes the input file name as a command line parameter and prints a list of tokens, their values, and their location in the input text. Compiler Project: Preliminary Specification The source language for the compiler project has elements derived from both C++ and Java but considerably simplified from both. It will be referred to as CJ--. You may choose the implementation language and tools for building the compiler. The implementation environment must be either Unix/Linux or MS Windows. The target language will be a much-restricted version of C++ to be run on either Unix systems or MS Windows. ## Deliverables 1) Complete and fully-functional working program(s) in executable form as well as complete source code of all work done. 2) Installation package that will install the software (in ready-to-run condition) on the platform(s) specified in this bid request. 3) Exclusive and complete copyrights to all work purchased. (No GPL, 3rd party components, etc. unless all copyright ramifications are explained AND AGREED TO by the buyer on the site). Lexical Conventions · The ASCII character set will be used. · Comments and whitespace will be ignored except that they serve as separators for other language components o Comments begin with // and run to the end of the line o Whitespace characters are space, tab, carriage return, and newline · The main classes of tokens are Identifier, Reserved Word, Literal, Separator, and Operator · Line terminators in source code will depend on implementation platform Tokens · Basic Keywords: cin class cout else float if int return void while · Additional Keywords: boolean break continue false new null this true · Basic Special characters: + - * / % ! = , < > ( ) { } == != << >> ; · Additional Special characters: || && <= >= . · Indentifier : The regular definition for the identifier is: identifier: letter (letter | digit)* letter: [A-Z]|[a-z]|_ digit: [0-9] · Integer literal : The following is regular definition for integer numbers in CJ--: integer_num: digit (digit)* digit: [0-9] · Floating-point literal : The following regular definition is for floats in CJ--: float_num: digit*fraction exponent? | digit+. | digit+.?exponent digit: [0-9] fraction: .digit+ exponent: (E|e)(+|-)?digit+ · String literal : The following is regular definition for strings in CJ--: string_literal: quote non_quote_char* quote quote: " non_quote_char: [^"]|\"|\n · Boolean literal : The following is regular definition for strings in CJ--: boolean_literal: true | false · Null literal : The following is regular definition for strings in CJ--: null_leteral: null Program Structure The following are the grammar rules in EBNF for CJ--: These are the CJ-- statements: · program: class_decl+ · class_decl: class identifier class_def · class_def: '{'decls+'}' · decls: decl decl* · decl: function_decl | var_decl · function_decl: type_specifier identifier '('param_decl_list')' compound_st · param_decl_list: param_decl(',' param_decl)* · type_specifier: 'int'| 'float' | 'boolean' | 'void' | identifiertype · param_decl: type_specifier identifier · compound_st: '{'(var_decl* statement+)? '}' · var_decl: type_specifier var_decl_list';' · var_decl_list: variable_ident(',' variable_ident)* · variable_ident: identifier('=' expression)? · statement: compound_st | conditional_st | while_st | 'break' ';'| 'continue' ';' | 'return' expression ';' | expression? ';' | io_stmt · conditional_st: 'if' '('expression')' statement ('else' statement )? · while_st: 'while' '(' expression ')' statement · io_stmt: 'cin' '>>' element_access ';' | 'cout' '<<' expression ';' Below are the types of expressions in CJ--. Each of these carries a value of one of the allowed CJ-- types (int, float, or boolean). · expression: identifier '='expression | condition · condition: disjunction · disjunction: conjunction | disjunction '||' conjunction · conjunction: comparison | conjunction '&&' comparison · comparison: relation | relation ('==' | '!=') relation · relation: sum | sum ('<' | '<=' | '>' | '>=') ## Platform The implementation environment must be either Unix/Linux or MS Windows. cont. sum · sum: term | sum ('+' | '-') term · term: factor | term ('*' | '/') factor · factor: cast | ('!' | '-') factor · cast: '(' type_specifier ')' identifier | primary . primary: literal | element_access | class_instance_creation | method_invocation | '(' expression ')' · literal: integer_num | float_num | string_literal | boolean_literal | null_literal · element_access: identifier | primary '.' identifier · clsss_instance_creation: 'new' identifiertype '(' arguments ')' · arguments: expression+ · method_invocation: method_call | primary '.' method_call · method_call: identifiermethod '(' arguments ')' Note: Some aspects of CJ-- are borrowed from C-- designed by Bill Waite (UC Boulder) and Lynn Carter (CMU) and used as the project for the undergraduate compiler-writing course at Colorado State University.
IČ projektu: 2979969

O projektu

5 nabídky
Vzdálený projekt
Aktivní před 21 roky

Chcete si vydělat nějaké peníze?

Výhody podávání nabídek na Freelancer

Stanovte si rozpočet a časový rámec
Získejte za svou práci zaplaceno
Načrtněte svůj návrh
Registrace a podávání nabídek je zdarma
Uděleno:
Avatar uživatele
See private message.
$21,25 USD v 4 dnech
5,0 (8 recenze)
1,8
1,8
5 freelanceři nabízejí v průměru $226 USD za tuto práci
Avatar uživatele
See private message.
$21,25 USD v 4 dnech
4,9 (22 recenze)
4,8
4,8
Avatar uživatele
See private message.
$850 USD v 4 dnech
4,7 (15 recenze)
3,8
3,8
Avatar uživatele
See private message.
$25,50 USD v 4 dnech
5,0 (36 recenze)
3,6
3,6
Avatar uživatele
See private message.
$212,50 USD v 4 dnech
0,0 (1 recenze)
0,0
0,0

O klientovi

Pochází z UNITED STATES
United States
4,7
16
Členem od dub 19, 2003

Ověření klienta

Díky! Poslali jsme vám e-mailem odkaz pro získání kreditu zdarma.
Při odesílání e-mailu se něco pokazilo. Zkuste to prosím znovu.
Registrovaných uživatelů Zveřejněných projektů
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Načítání náhledu
Bylo uděleno povolení ke geolokaci.
Vaše doba přihlášení vypršela a byli jste odhlášeni. Přihlaste se znovu.