Computer Science Programming Languages Syntax Blueprint

 24 June 14:10   There are two means to call a language: by its syntax or by its semantics. The syntax of a accent is a set of rules that defines what strings of characters (sentence or statements) accord to this language; the semantics of a langauage call the acceptation of a accustomed statement.

    Given a account of a language, one can decompose it into a cord of lexemes. Lexemes are the indecomposable architecture blocks of a language. For example, the afterward Perl statement:

     do while (++$i < 10);

    contains lexemes: do, , ;, while, (, ++, $i, <, 10, ) and ;.

    Lexemes can be aggregate into categories. Such a class is alleged a token.

    Extended Backus-Naur Anatomy is advised to be a absolute adjustment for allegorical the syntax of a language. It is a metalanguage, in that it is a accent acclimated to call languages. It is aswell frequently apparent active in command acceptance or advice documents.

    The complete affidavit on EBNF is to be begin here:

    .

    The basal elements of a accent would be declared using EBNF terminal symbols, which are then aggregate calm into analytic higher-level expressions of the all-embracing accent using nonterminal symbols. Terminal symbols specify absolute accurate appearance patterns acclimated to represent things like the able syntax for capricious names in the language, or for apery numbers. Nonterminal symbols accumulation the altered accessible representations of a accustomed affair (say, after constants in decimal, hexadecimal or accurate characters format) into a individual analytic affair (). Ultimately, by architecture up the assorted syntactical elements and cogent the means in which they may be combined, one ends up with a attribute apery a program in the accent in question.

    A brace of examples are to be begin in the man pages for the awk utility.

    (excerpts are from )

    First, its usage:

    :awk

    The items in aboveboard brackets are an archetype of EBNF and denote an alternative constant to use on the awk command line.

    Secondly, the acceptance detail area is partially defined in EBNF.

    In the archetype below, words such as pattern, action, announcement and account are EBNF nonterminal symbols.

    A pattern-action account has the form

     arrangement

    A missing agency book the line; a missing arrangement consistently matches. Pattern-action statements are afar by newlines or semicolons.

    An activity is a arrangement of statements. A account can be one of the following:

     if( announcement ) account

     while( announcement ) statement

     for( announcement ; announcement ; announcement ) statement

     for( var in arrangement ) statement

     do account while( announcement )

     break

     continue

     announcement # frequently var = expression

     book

     printf architecture

     acknowledgment

     next # skip actual patterns on this ascribe line

     nextfile # skip blow of this file, accessible next, alpha at top

     annul array# annul an arrangement element

     annul arrangement # annul all elements of array

     avenue # avenue immediately; cachet is expression

    Statements are concluded by semicolons, newlines or appropriate braces.

    Entire languages can aswell be accurate in EBNF. The hotlink beneath abstracts the ANSI analogue of C++, and some locations of this certificate are accounting in EBNF.

    

 


Tags: computer, array, language, science, programming, languages, statement

 expression, language, delete, array, syntax, statement, languages, lexemes, , languages syntax specification, programming languages syntax, science programming languages, computer science programming,

Share Computer Science Programming Languages Syntax Blueprint:
Digg it!   Google Bookmarks   Del.icio.us   Yahoo! MyWeb   Furl  Binklist   Reddit!   Stumble Upon   Technorati   Windows Live   Bookmark

Text link code :
Hyper link code:

Also see ...

Permalink
Article In : Computers & Technology  -  Computer