100 likes | 222 Views
Prog . techniques. Standard prog . techniques. Complex programs can be broken down into simpler parts called “Modules” These come in 2 types,“Procedures ” and “Functions This allows multiple programmers to work on the same project at the same time
E N D
Standard prog. techniques • Complex programs can be broken down into simpler parts called “Modules” • These come in 2 types,“Procedures” and “Functions • This allows multiple programmers to work on the same project at the same time • This means you can assign more complex modules to higher level programmers
Parameters • variables passed to modules • Can be declared when calling the module or declared inside the module itself • These are known as “Local” variables • Local variables reset once the module is exited • Variables that have to be used by multiple modules are called “Global” variables
Calling procedures • When a procedure is called, the computer has to save the location of the current module so that it can return once finished • This is ok for simple programs when only 1 procedure is called at a time but when multiple procedures need to be called, the computer has to store the locations in order • This can be done through the use of a stack (first in, last out)
Defining syntax • Languages do not evolve but are invented • The language must stick to a set of rules so that the translator can run correctly • Each set of rules are language specific • “for i = 0 to 5” in VB • For(i=0;i<=5;i++){ in AS2
Terminal symbols • These are the base characters (e.g. A, B, C, 1, 2, 3, etc) • ABC is a combination of letters – can be described as “Letter, letter, letter” • A is not a combination as it is a base character
BNF • In BNF, you can define combinations using this syntax • ::= “Is defined as” • | “Or” • E.g. <WORD>::=<LETTER><LETTER><LETTER> • This allows words exactly 3 characters large • To allow for unlimited characters, you can nest the definition • E.G <WORD>::=<LETTER><LETTER>|<WORD><LETTER>
Syntax Diagrams • This is a more visual method for defining syntax • Combinations are shown in flow graph format • E.G