Find Jobs
Hire Freelancers

Scanner

$30-5000 USD

Abgeschlossen
Veröffentlicht vor mehr als 20 Jahren

$30-5000 USD

Bezahlt bei Lieferung
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.
Projekt-ID: 2979969

Über das Projekt

5 Vorschläge
Remote Projekt
Aktiv vor 21 Jahren

Möchten Sie etwas Geld verdienen?

Vorteile einer Ausschreibung auf Freelancer

Legen Sie Ihr Budget und Ihren Zeitrahmen fest
Für Ihre Arbeit bezahlt werden
Skizzieren Sie Ihren Vorschlag
Sie können sich kostenlos anmelden und auf Aufträge bieten
Vergeben an:
Avatar des Nutzers
See private message.
$21,25 USD in 4 Tagen
5,0 (8 Bewertungen)
1,8
1,8
5 Freelancer bieten im Durchschnitt $226 USD für diesen Auftrag
Avatar des Nutzers
See private message.
$21,25 USD in 4 Tagen
4,9 (22 Bewertungen)
4,8
4,8
Avatar des Nutzers
See private message.
$850 USD in 4 Tagen
4,7 (15 Bewertungen)
3,8
3,8
Avatar des Nutzers
See private message.
$25,50 USD in 4 Tagen
5,0 (36 Bewertungen)
3,6
3,6
Avatar des Nutzers
See private message.
$212,50 USD in 4 Tagen
0,0 (1 Bewertung)
0,0
0,0

Über den Kunden

Flagge von UNITED STATES
United States
4,7
16
Mitglied seit Apr. 19, 2003

Kundenüberprüfung

Danke! Wir haben Ihnen per E-Mail einen Link geschickt, über den Sie Ihr kostenloses Guthaben anfordern können.
Beim Senden Ihrer E-Mail ist ein Fehler aufgetreten. Bitte versuchen Sie es erneut.
Registrierte Benutzer Veröffentlichte Jobs
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Vorschau wird geladen
Erlaubnis zur Geolokalisierung erteilt.
Ihre Anmeldesitzung ist abgelaufen und Sie wurden abgemeldet. Bitte melden Sie sich erneut an.