联系方式

  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-23:00
  • 微信:codinghelp

您当前位置:首页 >> C/C++编程C/C++编程

日期:2019-09-13 11:14

Assignment 1 Description

Weighting and Due Date

Marks for this assignment contribute 5% of the overall course mark.

Marks for functionality will be awarded automatically by the web submission system.

Due dates: Milestone - 11:55pm Tuesday of week 7, Final - 11:55pm Friday of week 7.

Late penalties: For each part, the maximum mark awarded will be reduced by 25% per day / part

day late. If your mark is greater than the maximum, it will be reduced to the maximum.

Core Body of Knowledge (CBOK) Areas: abstraction, design, hardware and software, data and

information, and programming.

Project Description

In this assignment you will implement a tokeniser that with minor changes could be used to complete

variations of projects 6, 7, 8, 10 and 11 in the nand2tetris course. A detailed description of the

requirements are shown below. The exectuable programs, tokens and tokens-context will read

text from standard input and produce a list of tokens in the text on standard output.

Note: you should complete workshop 05 before attempting this assignment.

SVN Repository

You must create a directory in your svn repository named: <year>/<semester>/cs/assignment1. This

directory must only contain the following files and directories - the web submission system

(https://cs.adelaide.edu.au/services/websubmission) will check this:

Makefile - this file is used by make to compile your tokeniser program - do not modify this file.

Makefile-extras - this file is used by make to compile your tokeniser program - do not modify this

file.

tokens - executable script that will run your compiled tokens program - do not modify this file.

tokens.cpp C++ source file containing the main() function for tokens - do not modify this file.

tokens-context - executable script that will run your compiled tokens-context program - do not

modify this file.

tokens-context.cpp C++ source file containing the main() function for tokens-context - do not

modify this file.

tokeniser.cpp C++ source files containing the next_token() function.

bin - this directory contains precompiled programs and scripts - do not modify this directory.

lib - this directory contains precompiled components - do not modify this directory.

includes - this directory contains .h files for the library - do not modify this directory.

tests - this directory contains sample test data, it can be used to store any extra files you need for

testing

Note: you must use the following command to add your startup files to your svn repository:

% svn add Makefile Makefile-extras bin includes lib tests tokens tokens.cpp tokens-context tokens-co

% svn add Makefile Makefile-extras bin includes lib tests tokens tokens.cpp tokens-context tokens-co

ntext.cpp tokeniser.cpp lib/*/lib.a

Submission and Marking Scheme

This assignment has two assignments in the web submission system

(https://cs.adelaide.edu.au/services/websubmission) named: Assignment 1 - Milestone

Submissions and Assignment 1 - Final Submissions. The assessment is based on "Assessment of

Programming Assignments (https://myuni.adelaide.edu.au/courses/44936/pages/assessment-ofprogramming-assignments)

". A submission to either assignment in the web submission system

(https://cs.adelaide.edu.au/services/websubmission) will automatically result in a submission to the other

assignment.

Assignment 1 - Milestone Submissions: due 11:55pm Tuesday of

week 7

The marks awarded by the web submission system (https://cs.adelaide.edu.au/services/websubmission)

for the milestone submission contribute up to 20% of your marks for assignment 1. Your milestone

submission mark, after the application of late penalties, will be posted to the myuni gradebook when the

assignment marking is complete.

Your tokeniser program must be written in C++ and will be tested using the set of test files that are

attached below. Although a wide range of tests may be run, including a number of secret tests, marks

will only be recorded for those tests that test the milestone token definitions shown below using

your tokens program. Your tokens and tokens-context programs will be compiled using the

Makefile and the tokens.cpp or tokens-context.cpp files included in the zip file attached below

together with the tokeniser.cpp file in your svn directory.

Assignment 1 - Final Submissions: due 11:55pm Friday of week 7

The marks awarded for the final submission contribute up to 80% of your marks for assignment 1.

Your final submission mark will be the geometric mean of the marks awarded by the web submission

system (https://cs.adelaide.edu.au/services/websubmission/) , a mark for your logbook and a mark for your

code. It will be limited to 20% more than the marks awarded by the web submission system

(https://cs.adelaide.edu.au/services/websubmission) . See "Assessment - Mark Calculations

(https://myuni.adelaide.edu.au/courses/44936/pages/assessment-mark-calculations) " for examples of how the

marks are combined. Your final submission mark, after the application of late penalties, will be posted to

the myuni gradebook when the assignment marking is complete.

Automatic Marking

The automatic marking will compile and test your tokens and tokens-context programs in exactly the

same way as for the milestone submission. The difference is that marks will be recorded for all of the

tests including the secret tests. Note: if your program fails any of these secret tests you will not receive

any feedback about these secret tests, even if you ask!

Logbook Marking

Important: the logbook must have entries for all work in this assignment, including your milestone

submissions. See "Assessment - Logbook Review

(https://myuni.adelaide.edu.au/courses/44936/pages/assessment-logbook-review) " for details of how your

logbook will be assessed.

Code Review Marking

For each of your programming assignments you are expected to submit well written code. See

"Assessment - Code Review (https://myuni.adelaide.edu.au/courses/44936/pages/assessment-code-review)

" for details of how your code will be assessed.

Assignment 1 - Participation Marks

Any submissions to the Final Submissions assignment made more than one week before but less than

two weeks before the due date for the Final Submissions assignment, may be awarded participation

marks. The participation marks will be calculated by scaling the best mark awarded by the automatic

marking of an eligible submission to be a number between 1 and 10. A maximum of 10 participation

marks are available.

Tokenisers

Background

The primary task of any language translator is to work out how the structure and meaning of an input in a

given language so that an appropriate translation can be output in another language. If you think of this

in terms of a natural language such as English. When you attempt to read a sentence you do not spend

your time worrying about what characters there are, how much space is between the letters or where

lines are broken. What you do is consider the words and attempt to derive structure and meaning from

their order and arrangement into English language sentences, paragraphs, sections, chapters etc. In the

same way, when we attempt to write translators from assembly language, virtual machine language or a

programming language into another form, we attempt to focus on things like keywords, identifiers,

operators and logical structures rather than individual characters.

The role of a tokeniser is to take the input text and break it up into tokens (words in natural language) so

that the assembler or compiler using it only needs to concern itself with higher level structure and

meaning. This division of labor is reflected in most programming language definitions in that they usually

have a separate syntax definition for tokens and another for structures formed from the tokens.

The focus of this assignment is writing a tokeniser to recognise tokens that conform to a specific set of

rules. The set of tokens may or may not correspond to a particular language because a tokeniser is a

fairly generic tool. After completing this assignment we will assume that you know how to write a

tokeniser and we will provide you a working tokeniser to use in each of the remaining programming

assignments. This will permit you to take the later assignments much further than would be otherwise

possible in the limited time available.

Writing Your Program

You are required to complete the implementation of the C++ file tokeniser.cpp which is used to compile

the programs tokens and tokens-context. You will complete the implementation of a

the programs tokens and tokens-context. You will complete the implementation of a

function, next_token(), that will read text character by character using the static function nextch(), and

return the next recognised token in the input. The tokens that must be recognised in the milestone and

final submissions are specified below and in the file includes/tokeniser.h.

Your tokens and tokens-context programs will be compiled using the Makefile in the zip file attached

below using the command:

% make

Note: Do not modify the Makefile, tokens.cpp, tokens-context.cpp or the sub-directories

bin, includes and lib. They will be replaced during testing by the web submission system.

Testing Your Program

For each file in the tests directory, the output of the tokens and tokens-context programs must match

the corresponding .tokens and .context output files respectively. You must not produce any output of

your own. You can both compile and test your programs against all of the supplied tests using the

command:

% make

The testing will not show you any program output, just whether or not a test was passed or failed. If you

want to see the actual output, the commands used to run the tests are shown in string quotes ("). Simply

copy the commands between the string quotes (") and paste them into your shell.

The web submission system will test your program in exactly this way. The key difference between your

testing and the web submission testing is that the web submission system has some secret tests that it

will use.

If you want to try additional tests, just create some new files in the tests sub-directory and generate the

correct outputs using the command:

% make test-add

This will increase the number of tests that will be run in the future.

Milestone Tokens

Your milestone submission will be marked using tests that require the correct recognition of the

tokens, tk_identifier, tk_integer, tk_at, tk_semi, tk_colon, tk_not, tk_comma, tk_stop,

tk_lcb, tk_rcb, tk_lrb, tk_rrb, tk_lsb, tk_rsb and tk_div.

Note: the includes/tokeniser.h file describes

the grammar rules for all tokens,

the rules for preprocessing tab and carriage return characters (not required for the milestone),

the rules for differentiating identifiers and keywords (not required for the milestone),

the rules governing the context of some token spelling's (not required for the milestone) and

the rules governing error handling.

Notes: all input must be read using the function next_ch() next_ch() which must use the external

Notes: all input must be read using the function next_ch() next_ch() which must use the external

function read_char() read_char().

Final Submission Tokens

Your final submission will be marked using tests that require the correct recognition of the following

tokens in addition to the milestone tokens listed above: tk_eol_comment, tk_adhoc_comment,

tk_float, tk_string, tk_do, tk_for, tk_pointer, tk_real, tk_this, tk_eq and tk_spaceship,

In addition your final submission also has to fully implement the function token_is_in() so that it

recognises the group tokens tk_number, tk_keyword, and tk_symbol.

Finally, your submission has to fully implement the function token_context().

Tests

In addition to the test files in the zip file attached below, we will use a number of secret tests that may

contain illegal characters or character combinations that may defeat your tokenisers. Note: these tests

are secret, if your programs fail any of these secret tests you will not receive any feedback about these

secret tests, even if you ask!

Startup Files

The startup files in the attached zip file should work on most 64-bit Linux systems and on a Mac. Please

see the Startup Files for Workshops and Assignments

(https://myuni.adelaide.edu.au/courses/44936/pages/startup-files-for-workshops-and-assignments) page for

more information.

assignment-tokeniser.zip (https://myuni.adelaide.edu.au/courses/44936/files/5214649/download?wrap=1)


版权所有:留学生编程辅导网 2020 All Rights Reserved 联系方式:QQ:99515681 微信:codinghelp 电子信箱:99515681@qq.com
免责声明:本站部分内容从网络整理而来,只供参考!如有版权问题可联系本站删除。 站长地图

python代写
微信客服:codinghelp