Saturday, April 6, 2019
Syntax and Semantics Essay Example for Free
syntax and Semantics EssayIn planming language theory, semantics is the field concerned with the rigorous numeral study of the subject matter of computer programing languages. It does so by evaluating the meaning of syntactically licit strings delimitate by a specific programming language, showing the computation involved. In such a showcase that the evaluation would be of syntactically illegal strings, the result would be non-computation. Semantics describes the processes a computer follows when execution a program in that specific language. This can be shown by describing the dealinghip between the input and takings of a program, or an explanation of how the program will execute on a certain platform, and then creating a model of computation. Semantics reveals the meaning of syntactically valid strings in a language. For natural languages, this instrument correlating sentences and phrases with the objects, thought processs, and feelings of our experiences. For p rogramming languages, semantics describes the behavior that a computer follows when executing a program in the language. We might find out this behavior by describing the relationship between the input and output of a program or by a step-by-step explanation of how a program will execute on a really or an abstract cable car.Semantics is concerned with the interpretation or understanding of programs and how to predict the outcome of program transaction. The semantics of a programming language describe the relation between the syntax and the model of computation. Semantics can be thought of as a function which maps syntactical constructs to the computational model.This approach is called syntax-directed semantics There be several wide employ techniques ( algebraic, axiomatic, de nonational, operational, and translation) for the description of the semantics of programming languages. Algebraic semantics describe the meaning of a program by delimit an algebra. The algebraic relati onships and operations are described by axioms and equations. Axiomatic semantics defines the meaning of the program implicitly. It makes assertions about relationships that assert at each point in the execution of the program. Axioms define the properties of the control structures and state the properties that may be inferred. A property about a program is deduced by using the axioms. Each program has a pre-condition which describes the initial conditions required by the program prior to execution and a post-condition which describes, upon termination of the program, the desired program property.Denotational semantics tell what is computed by giving a mathematical object (typically a function) which is the meaning of the program. Denotational semantics are used in comparitive studies of programming langauges. Operational semantics tell how a computation is performed by defining how to simulate the execution of the program. Operational semantics may describe the syntactic transform ations which mimic the execution of the program on an abstract machine or define a translation of the program into recursive functions. Operational semantics are used when accomplishment a programming language and by compiler writers.Translation semantics describe how to translate a program into an other langauge usually the language of a machine. Translation semantics are used in compilers. Much of the make water in the semantics of programming languages is motivated by the problems encountered in trying to construct and understand imperative programs programs with assigning commands. Since the assignment command reassigns values to variables, the assignment can have unexpected effects in outside portions of the program. SyntaxIn computer science, the syntax of a computer language is the set of rules that defines the combinations of symbols that are considered to be correctly structured document or fragment in that language. This applies both to programming languages, where the document represents generator code, and markup languages, where the document represents data. The syntax of a language defines its surface form.1 Text-based computer languages are based on sequences of characters, go visual programming languages are based on the spatial layout and connections between symbols (which may be textual or graphical). Documents that are syntactically invalid are said to have a syntax error.Syntax refers to the ways symbols may be combined to create well-formed sentences (or programs) in the language. Syntax denes the formal relations between the constituents of a language, thereby providing a structural description of the various expressions that make up legal strings in the language. Syntax deals solely with the form and structure of symbols in a language without both consideration given to their meaning.Syntax the form is contrasted with semantics the meaning. In processing computer languages, semantic processing generally comes after syntactic p rocessing, but in some cases semantic processing is necessary for complete syntactic analysis, and these are done together or concurrently. In a compiler, the syntactic analysis comprises the frontend, while semantic analysis comprises the backend (and middle end, if this phase is distinguished).Syntax versus semantics The syntax of a language describes the form of a valid program, but does not provide any information about the meaning of the program or the results of executing that program. The meaning given to a combination of symbols is handled by semantics (either formal or hard-coded in a indite implementation). Not all syntactically correct programs are semantically correct. many syntactically correct programs are nonetheless ill-formed, per the languages rules and may (depending on the language specification and the soundness of the implementation) result in an error on translation or execution.In some cases, such programs may exhibit undefined behavior. Even when a program is well-defined within a language, it may still have a meaning that is not intended by the person who wrote it. Using natural language as an example, it may not be possible to assign a meaning to a grammatically correct sentence or the sentence may be false Colorless green ideas sleep furiously. is grammatically well-formed but has no generally accepted meaning. John is a married bachelor. is grammatically well-formed but expresses a meaning that cannot be true.Statement In computer programming a statement is the smallest standalone element of an imperative programming language. A program written in such a language is formed by a sequence of one or more statements. A statement will have internal components (e.g., expressions). Many languages (e.g. C) make a distinction between statements and definitions, with a statement only containing executable code and a definition declaring an identifier. A distinction can also be made between simple and abstruse statements the latter may cont ain statements as components.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.