Meh... Database error last time i tried to post this, sorry if its already been answered...
Tokens: (Part of the Lexical Analysis part of Translating code)
When translating code, the processor needs to know what words are used in the code, but if words are encountered multiple
times, then you are wasting a lot of time reading each word over again.
So a translator goes through the code and replaces every word with a 'token' (like - another way of referring to that particular word).
The code is translated into a list of tokens, and then this is given to the parser.
How does the translator figure out when to add in tokens?
Well, each character is looked at individually, and the translator has a list of reserved words for that language. It goes through each character, and when it comes across a string of characters that matches one of the reserved words (which are called 'lexemes'), it replaces that word with a 'token'. If the characters arent recognised it chucks up an error.
The whole code is done like this (I think it does the whole code anyway).
Parsed: (My understanding of 'parsing' is searching something, like a string, looking for characters/patterns of characters...)
So I would say that what you might mean is that parsing happens in the Syntactical Analysis bit of translation, where the
'Parser' searches the code to see if everything is 'in order'... Like, whether tokens are syntactically in order... So say that token 1A could only be before token 2F, and the code didnt have 1A before 2F, then a syntax error would be given.
So 'parsed tokens' would be tokens that are in their correct syntactical arrangement (according to the EBNF rules of the specific language)
Hope that helps for that... You should also look at things like type-checking and then how code is actually produced, which both happen after the code has been analysed as above.
OK - the easier questions...
Relational relates to something else, so like your equalities situations, so >,<, <= and >= are relational operators
Arithmetic is math stuff, so things like +, -, *, /
Assignment is = (but if it asks for this in BNF then it's ::=)... Think of assigning something a value, which you do with something = something else... (like, meAge = x )
Others: Logical/Boolean operators: things like AND/OR/NOT
And things like string operators but i dont know whether you need them...
Sorting Letter Arrays: (Depending on routine used)
This is how a computer does it:
All of the sorts we deal with compare each item individually against another item, and they pass over the list a number of times in order to compare each item with each other item. (I'm not going to worry about actual routines here... there are other threads with that stuff in it.)
But with letters, when it comes across a letter, the computer converts the letter to its ascii equivalent (or whatever encoding you are using, but dont worry about that either) and then compares based on this ascii character.
Some ascii character rules for sorting letters:
(What text book do you have? There is an ascii chart on page 336 in Davis' book)
What you will see is that Capital letters are lower than lower case, so capital 'A' is sorted before 'a'.
If the first character in each string is the same, then the next character is looked at, and so on until they can be discriminated...
AB BA ZA ZB AR BD WR DS FG and Im meant to do a selection sort on it in descending order and its not working
I ended up getting AB BA FG LK AR BD DS WR 2A 2B
You have a couple not included in your answer... Like LK.
Do it ascending first, thats easier to recognise:
AB first, as A is lowest ascii value.
AR next, as A is looked at first, then R.
Then BD as B next after A, and so on...
So ascending:
AB,AR,BA,BD,DS,FG,WR,ZA,ZB (and the reverse for descending...)
Winston answered your word size question I think, so I wont do that one.
Damn computer keeps adding extra lines in this message...