Find Jobs
Hire Freelancers

Scanner

$30-5000 USD

Completed
Posted over 20 years ago

$30-5000 USD

Paid on delivery
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.
Project ID: 2979969

About the project

5 proposals
Remote project
Active 21 yrs ago

Looking to make some money?

Benefits of bidding on Freelancer

Set your budget and timeframe
Get paid for your work
Outline your proposal
It's free to sign up and bid on jobs
Awarded to:
User Avatar
See private message.
$21.25 USD in 4 days
5.0 (8 reviews)
1.8
1.8
5 freelancers are bidding on average $226 USD for this job
User Avatar
See private message.
$21.25 USD in 4 days
4.9 (22 reviews)
4.8
4.8
User Avatar
See private message.
$850 USD in 4 days
4.7 (15 reviews)
3.8
3.8
User Avatar
See private message.
$25.50 USD in 4 days
5.0 (36 reviews)
3.6
3.6
User Avatar
See private message.
$212.50 USD in 4 days
0.0 (1 review)
0.0
0.0

About the client

Flag of UNITED STATES
United States
4.7
16
Member since Apr 19, 2003

Client Verification

Thanks! We’ve emailed you a link to claim your free credit.
Something went wrong while sending your email. Please try again.
Registered Users Total Jobs Posted
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Loading preview
Permission granted for Geolocation.
Your login session has expired and you have been logged out. Please log in again.