IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)

Kit : Améliorations de la gestion du code

Date de publication : 16/11/2006 , Date de mise à jour : 28/01/2006



5. Quelques uns des nouveaux langages supportés
5-A. Ruby, RHTML
5-B. POV-Ray
5-C. Latex
5-D. Batch
5-E. Coldfusion
5-F. Ocaml
5-G. Makefile
5-H. Assembleur x86
5-I. Ada95
5-J. ANTLR
5-K. Apache conf
5-L. Aspect J
5-M. Eiffel
5-N. Cobol
5-O. Fortran
5-P. Frremarker
5-Q. Erlang
5-R. Groovy
5-S. JSP
5-T. Lisp
5-U. Objective C
5-V. Postscript
5-W. Propriétés
5-X. Relax NG
5-Y. Smalltalk
5-Z. XSL


5. Quelques uns des nouveaux langages supportés


5-A. Ruby, RHTML

Ruby
class Carnet 
    def initialize
        @personnes = []
    end
    def ajoute(personne)
        @personnes.push(personne)
        @personnes = @personnes.sort { |a, b| par_nom(a, b) }
    end
    def retire(personne)
        @personnes.delete(personne)
    end
    def par_nom(a, b)
        if a.prenom == b.prenom
            a.nom <=> b.nom
        else
            a.prenom <=> b.prenom
        end
    end
end
RHTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
       "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
	<title><%= @page_title %></title>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<%= stylesheet_link_tag "main" %>
	<%= javascript_include_tag :defaults %>
</head>

<body<% if @page_class %> class="<%= @page_class %>"<% end %>>

	<% unless session[:user_id] %><%= render :partial => "generic/loginstuff" -%><% end %>

	<div id="container">
	
		<div id="header">
		</div>
	
		<% unless @message_override && @message_override == 1 %>
			<%= render :partial => "generic/messageboxes" %>
		<% end %>
	
		<div id="main">
			<%= yield %>
		</div>
	
		<div id="footer">
		</div>
	
	</div>

</body>
</html>

5-B. POV-Ray

POV-Ray
#include "colors.inc"
 camera {
   location <3, 1, -10>
   look_at <3,0,0>
 }
 light_source { <500,500,-1000> White }
 text {
   ttf "timrom.ttf" "Hello world!" 1, 0
   pigment { White }
 }

5-C. Latex

Latex
\documentclass[a4paper, 11pt]{article}

\title{Exemple de document \LaTeX}
\author{Moi}

\begin{document}
    \maketitle
    $\sum_{n=1}^{+\infty}\frac{1}{n^2}=\frac{\pi^2}{6}$
\end{document}

5-D. Batch

Batch
@rem -----------------------------
@rem G?n?rateur d'articles
@rem -----------------------------
@echo off

@if "%OS%"=="" deltree /Y .\..\html\%1 >buildart.txt
@if not "%OS%"=="" rmdir /s /q .\..\html\%1 >buildart.txt
@if "%OS%"=="" deltree /Y .\..\cache\%1 >buildart.txt
@if not "%OS%"=="" rmdir /s /q .\..\cache\%1 >buildart.txt

@mkdir .\..\archives >>buildart.txt

@mkdir .\..\html >>buildart.txt
@mkdir .\..\html\%1 >>buildart.txt
@mkdir .\..\html\%1\fichiers >>buildart.txt
@mkdir .\..\html\%1\images >>buildart.txt

@mkdir .\..\cache >>buildart.txt
@mkdir .\..\cache\%1 >>buildart.txt
@mkdir .\..\cache\%1\fichiers >>buildart.txt
@mkdir .\..\cache\%1\images >>buildart.txt

@copy .\..\css\article.css .\..\html\%1 >>buildart.log
@copy .\..\images\*.* .\..\html\%1\images >>buildart.log
@copy .\..\documents\%1\fichiers\*.* .\..\html\%1\fichiers >>buildart.log
@copy .\..\documents\%1\images\*.*   .\..\html\%1\images >>buildart.log
@copy .\..\documents\%1\fichiers\*.* .\..\cache\%1\fichiers >>buildart.log
@copy .\..\documents\%1\images\*.*   .\..\cache\%1\images >>buildart.log


@echo applique la coloration syntaxique :
@perl coloration.pl .\..\documents\%1\%1.xml .\..\ArtTmp.xml >>buildart.log

@echo construction des pages HTML
@perl buildArt.pl .\..\ArtTmp.xml .\..\html\%1\ .\..\cache\%1 %1

rem  construction du zip pour consultation off-line
@cd .\..\html 
if exist .\..\archives\%1.zip @del /s/q .\..\archives\%1.zip 
   java -jar .\..\script\lib\Zippeur.jar .\..\archives\%1.zip %1 
@cd .\..\script

@copy .\..\documents\%1\%1.xml   .\..\html\%1 >>buildart.log

5-E. Coldfusion

ColdFusion
<html>
<head>
<title>Exemple de code ColdFusion inséré dans du code HTML</title>
</head>
<body>

     <CFSET nb = 42>
     <CFOUTPUT>Valeur de nb : #nb#</CFOUTPUT>
<CFQUERY NAME="ma_requete" DATASOURCE="ma_source">
     SELECT prenom
     FROM employes
     WHERE prenom LIKE 'J%'
     ORDER BY prenom ASC
</CFQUERY>

Nombre d'employés : <CFOUTPUT>#ma_requete.recordcount#</CFOUTPUT><br>
<CFOUTPUT QUERY="ma_requete">
    Prénom : #ma_requete.prenom#<br>
</CFOUTPUT>


</body>
</html>

5-F. Ocaml

ocaml
(* Le parcours *)
 (* 
    g correspond au graphe,
    aetevisite est la liste des sommets visité
    avisiter sont les sommets à visiter
    fAjout la fonction
    fTraitement la fonction qui traite le sommet
 *)
let rec parcours g aetevisite avisiter fAjout fTraitement =
   match avisiter with 
     [] -> ()
     |sommetCourant::reste ->  
            if (isinListe aetevisite sommetCourant) then 
	         parcours g aetevisite reste fAjout fTraitement                 
            else
             begin
              fTraitement sommetCourant;
              
              let voisins = getVoisins g sommetCourant 
              in
              
              let resteavisiter = fAjout reste voisins 
              in
	          
              let cequiaetevisite = sommetCourant::aetevisite 
              in
              
                 parcours g cequiaetevisite resteavisiter fAjout fTraitement
             end
   ;;

5-G. Makefile

makefile
DEBUG=yes
CC=gcc
ifeq ($(DEBUG),yes)
	CFLAGS=-Wall -ansi -g
	LDFLAGS=-Wall -ansi -g
else
	CFLAGS=-Wall -ansi
	LDFLAGS=-Wall -ansi
endif
EXEC=hello
SRC= $(wildcard *.c)
OBJ= $(SRC:.c=.o)

all: $(EXEC)

ifeq ($(DEBUG),yes)
	@echo "Génération en mode debug"
else
	@echo "Génération en mode release"
endif

hello: $(OBJ)
	@$(CC) -o $@ $^ $(LDFLAGS)

main.o: hello.h

%.o: %.c
	@$(CC) -o $@ -c $< $(CFLAGS)

.PHONY: clean mrproper

clean:
	@rm -rf *.o

mrproper: clean
	@rm -rf $(EXEC)

5-H. Assembleur x86

assembly-x86
Org     0;
       
        Jmp     Start
       
;---------------------;
; Programme principal ;
;---------------------;
Start:
        Cli
        Mov     Ax,07C0h
        Mov     Ds,Ax
        Mov     Es,Ax
        ; Initialisation de la pile ici
        Sti

; Programme de boot proprement dit...
Hang:
   Jmp Hang
       
End.:

   ;--- 00 jusqu'à 510 ---
   times 510

5-I. Ada95

Ada95
declare
   type Global is access Server;        --  see 9.1
   A, B : Server;
   G    : Global;
begin
   --  activation of A and B
   declare
      type Local is access Server;
      X : Global := new Server;  --  activation of X.all
      L : Local  := new Server;  --  activation of L.all
      C : Server;
   begin
      --  activation of C
      G := X;  --  both G and X designate the same task object
      ...
   end;  --  await termination of C and L.all (but not X.all)
   ...
end;  --  await termination of A, B, and G.all

5-J. ANTLR

ANTLR
set
{ Vector ids=null; }  // init-action
    :  "(" ids=idList ")"
    ;
idList returns [Vector strs]
{ strs = new Vector(); }   // init-action
    :  id:ID
       { strs.appendElement(id.getText()); }
       (
          "," id2:ID
          { strs.appendElement(id2.getText()); }
       )*
    ;

5-K. Apache conf

Apache conf
#
# ServerRoot: The top of the directory tree under which the server's
# configuration, error, and log files are kept.
#
# Do not add a slash at the end of the directory path.  If you point
# ServerRoot at a non-local disk, be sure to point the LockFile directive
# at a local disk.  If you wish to share the same ServerRoot for multiple
# httpd daemons, you will need to change at least LockFile and PidFile.
#
ServerRoot "/opt/lampp"

#
# Listen: Allows you to bind Apache to specific IP addresses and/or
# ports, instead of the default. See also the <VirtualHost>
# directive.
#
# Change this to Listen on specific IP addresses as shown below to 
# prevent Apache from glomming onto all bound IP addresses.
#
#Listen 12.34.56.78:80
Listen 80

#
# Dynamic Shared Object (DSO) Support
#
# To be able to use the functionality of a module which was built as a DSO you
# have to place corresponding `LoadModule' lines at this location so the
# directives contained in it are actually available _before_ they are used.
# Statically compiled modules (those listed by `httpd -l') do not need
# to be loaded here.
#
# Example:
# LoadModule foo_module modules/mod_foo.so
#
LoadModule authn_file_module modules/mod_authn_file.so
LoadModule disk_cache_module modules/mod_disk_cache.so
LoadModule mem_cache_module modules/mod_mem_cache.so
#LoadModule dbd_module modules/mod_dbd.so
LoadModule bucketeer_module modules/mod_bucketeer.so

<IfDefine JUSTTOMAKEAPXSHAPPY>
LoadModule php4_module        modules/libphp4.so
LoadModule php5_module        modules/libphp5.so
</IfDefine>

<IfModule !mpm_winnt_module>
<IfModule !mpm_netware_module>
#
# If you wish httpd to run as a different user or group, you must run
# httpd as root initially and it will switch.  
#
# User/Group: The name (or #number) of the user/group to run httpd as.
# It is usually good practice to create a dedicated user and group for
# running httpd, as with most system services.
#
User nobody
Group nogroup
</IfModule>
</IfModule>

# 'Main' server configuration
#
# The directives in this section set up the values used by the 'main'
# server, which responds to any requests that aren't handled by a
# <VirtualHost> definition.  These values also provide defaults for
# any <VirtualHost> containers you may define later in the file.
#
# All of these directives may appear inside <VirtualHost> containers,
# in which case these default settings will be overridden for the
# virtual host being defined.
#

#
# ServerAdmin: Your address, where problems with the server should be
# e-mailed.  This address appears on some server-generated pages, such
# as error documents.  e.g. admin@your-domain.com
#
ServerAdmin you@example.com

#
# ServerName gives the name and port that the server uses to identify itself.
# This can often be determined automatically, but we recommend you specify
# it explicitly to prevent problems during startup.
#
# If your host doesn't have a registered DNS name, enter its IP address here.
#
#ServerName www.example.com:80
# XAMPP
ServerName localhost

#
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
DocumentRoot "/opt/lampp/htdocs"

#
# Each directory to which Apache has access can be configured with respect
# to which services and features are allowed and/or disabled in that
# directory (and its subdirectories). 
#
# First, we configure the "default" to be a very restrictive set of 
# features.  
#
<Directory />
    Options FollowSymLinks
    AllowOverride None
    #XAMPP
    #Order deny,allow
    #Deny from all
</Directory>

#
# Note that from this point forward you must specifically allow
# particular features to be enabled - so if something's not working as
# you might expect, make sure that you have specifically enabled it
# below.
#

#
# This should be changed to whatever you set DocumentRoot to.
#
<Directory "/opt/lampp/htdocs">
    #
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    #
    # The Options directive is both complicated and important.  Please see
    # http://httpd.apache.org/docs/2.2/mod/core.html#options
    # for more information.
    #
    #Options Indexes FollowSymLinks
    # XAMPP
    Options Indexes FollowSymLinks ExecCGI Includes


    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   Options FileInfo AuthConfig Limit
    #
    #AllowOverride None
    # since XAMPP 1.4:
    AllowOverride All


    #
    # Controls who can get stuff from this server.
    #
    Order allow,deny
    Allow from all

</Directory>

#
# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
#
<IfModule dir_module>
    #DirectoryIndex index.html
    # XAMPP
    DirectoryIndex index.html index.html.var index.php index.php3 index.php4
</IfModule>

#
# The following lines prevent .htaccess and .htpasswd files from being 
# viewed by Web clients. 
#
<FilesMatch "^\.ht">
    Order allow,deny
    Deny from all
</FilesMatch>

#
# ErrorLog: The location of the error log file.
# If you do not specify an ErrorLog directive within a <VirtualHost>
# container, error messages relating to that virtual host will be
# logged here.  If you *do* define an error logfile for a <VirtualHost>
# container, that host's errors will be logged there and not here.
#
ErrorLog logs/error_log

#
# LogLevel: Control the number of messages logged to the error_log.
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
#
LogLevel warn

<IfModule log_config_module>
    #
    # The following directives define some format nicknames for use with
    # a CustomLog directive (see below).
    #
    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
    LogFormat "%h %l %u %t \"%r\" %>s %b" common

    <IfModule logio_module>
      # You need to enable mod_logio.c to use %I and %O
      LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
    </IfModule>

    #
    # The location and format of the access logfile (Common Logfile Format).
    # If you do not define any access logfiles within a <VirtualHost>
    # container, they will be logged here.  Contrariwise, if you *do*
    # define per-<VirtualHost> access logfiles, transactions will be
    # logged therein and *not* in this file.
    #
    CustomLog logs/access_log common

    #
    # If you prefer a logfile with access, agent, and referer information
    # (Combined Logfile Format) you can use the following directive.
    #
    #CustomLog logs/access_log combined
</IfModule>

# XAMPP
<IfDefine SSL>
Include etc/extra/httpd-ssl.conf
</IfDefine>
</IfModule>
#
# Note: The following must must be present to support
#       starting without SSL on platforms with no /dev/random equivalent
#       but a statically compiled-in mod_ssl.
#
<IfModule ssl_module>
SSLRandomSeed startup builtin
SSLRandomSeed connect builtin
</IfModule>

# XAMPP
Include etc/extra/httpd-xampp.conf

5-L. Aspect J

Aspect J
aspect SetsInRotateCounting {
    int rotateCount = 0;
    int setCount = 0;

    before(): call(void Line.rotate(double)) {
        rotateCount++;
    }

    before(): call(void Point.set*(int))
              && cflow(call(void Line.rotate(double))) {
        setCount++;
    }
}

5-M. Eiffel

Eiffel
indexing
   description: "[
                  Counters that you can increment by one,
                  decrement, and reset
                  ]"
class
   COUNTER

feature -- Access   

item: INTEGER
         -- Counter's value.

feature -- Element change

increment is
         -- Increase counter by one.
      do
         item := item + 1
      end

decrement is
          -- Decrease counter by one.
      do
         item := item - 1
      end 

reset is
         -- Reset counter to zero.
      do
         item := 0
      end

end -- class COUNTER

5-N. Cobol

Cobol
000001 IDENTIFICATION D5ISION.
       program-id. progtele.
       author. M. Billaud.
       date-written. 8/02/1998.
000005
      *
      * consultation du programme tele de la semaine.
      *
      * - realise avec Personal Cobol (Microfocus)
000010

       ENVIRONMENT D5ISION.
       INPUT-OUTPUT SECTION.
       file-control.
000015     select F-FILMS assign to "semaine.txt"
               organization line sequential.


       DATA D5ISION.
000020 FILE SECTION.

       fd F-FILMS.
       01 F-ENR.
           02 JOUR       pic XXX.
000025     02 CHAINE     pic XXXX.
      *    heure de debut et duree en minutes
           02 HHMM       pic 9999.
           02 DUREE      pic 999.
      *    titre
000030     02 TITRE      pic X(60).

       WORKING-STORAGE SECTION.

      * constantes definies par commodite.
000035 77  VRAI          pic X   value "V".
       77  FAUX          pic X   value "F".

       77  FIN-MENU      pic X.
       77  FIN-FICHIER   pic X.
000040
       77  CHOIX-MENU    pic X.

       01  LIGNE-AFFICHAGE.
           02            pic XX  value "* ".
000045     02 JOUR       pic XXX.
           02            pic X   value " ".
           02 CHAINE     pic X(4).
           02            pic XXX value " | ".
           02 HHMM       pic Z9B99.
000050     02            pic X   value " ".
           02 TITRE      pic X(30).
           02            pic XX  value " |".

       01  LIGNE-ETOILES pic X(50) value all "*".
000055
       77  JOUR-CHOISI   pic X(3).
       77  NB-FILMS      pic 999.


000060 PROCEDURE D5ISION.
       PRINCIPALE SECTION.
       DEBUT.
           display "hello".
           move FAUX to FIN-MENU.
000065     perform MENU until FIN-MENU = VRAI.
           stop run.

       MENU.
             display "Films de la semaine"
000070       display " ".
             display "T. Tous les films"
             display "J. Films d'un jour"
             display "C. Films d'une chaine"
             display "H. Recherche par heure de debut"
000075       display "Q. Quitter".
             display " "
             display "Votre choix ?"
             accept CHOIX-MENU
             evaluate CHOIX-MENU
000080       when "T"
             when "t"
                   perform EDITER-TOUS-FILMS
             when "J"
             when "j"
000085             perform EDITER-JOUR
             when "C"
             when "c"
                   perform EDITER-CHAINE
             when "H"
000090       when "h"
                   perform RECHERCHER-HORAIRE
             when "Q"
             when "q"
                   move VRAI to FIN-MENU
000095       when other
                   display "Choix invalide"
             end-evaluate.

       EDITER-TOUS-FILMS.
000100     move FAUX to FIN-FICHIER.
           open input F-FILMS.
           display LIGNE-ETOILES.
           move 0 to NB-FILMS.
           perform until FIN-FICHIER = VRAI
000105        move SPACES to F-ENR
              read F-FILMS
              at end
                 move VRAI to FIN-FICHIER
              not at end
000110           add 1 to NB-FILMS
                 perform AFFICHER-ENREGISTREMENT
              end-read
           end-perform.
           close F-FILMS.
000115     display LIGNE-ETOILES.
           display NB-FILMS " films trouves.".
           display " ".

       AFFICHER-ENREGISTREMENT.
000120     move CHAINE of F-ENR to CHAINE of LIGNE-AFFICHAGE.
           move JOUR   of F-ENR to JOUR   of LIGNE-AFFICHAGE.
           move HHMM   of F-ENR to HHMM   of LIGNE-AFFICHAGE.
           move TITRE  of F-ENR to TITRE  of LIGNE-AFFICHAGE.

000125     display LIGNE-AFFICHAGE.

       EDITER-JOUR.
           display "Quel Jour ? (3 premieres lettres majuscules)".
           accept JOUR-CHOISI.
000130
           move FAUX to FIN-FICHIER.
           open input F-FILMS.
           move 0 to NB-FILMS.
           display LIGNE-ETOILES.
000135     perform until FIN-FICHIER = VRAI
              move SPACES to F-ENR
              read F-FILMS
              at end
                 move VRAI to FIN-FICHIER
000140        not at end
                 if JOUR-CHOISI = JOUR of F-ENR
                 then
                   add 1 to NB-FILMS
                   perform AFFICHER-ENREGISTREMENT
000145           end-if
              end-read
           end-perform.
           close F-FILMS.
           display LIGNE-ETOILES.
000150     display NB-FILMS " films trouves pour le jour "
                   JOUR-CHOISI.
           display " ".

        EDITER-CHAINE.
000155           display "* EDITER-CHAINE : A completer".

        RECHERCHER-HORAIRE.
           display "* RECHERCHER-HORAIRE : A completer".

5-O. Fortran

Fortran
PROGRAM DEGRAD 
!                                                                       
! Imprime une table de conversion degrés -> radians                     
! =================================================                     
!                                                                       
! Déclaration des variables                                             
      INTEGER DEG 
      REAL RAD, COEFF 
!                                                                       
! En-tête de programme                                                  
      WRITE ( *, 10) 
   10 FORMAT      (' ',20('*') /                                        &
     &             ' * Degres * Radians *' /                            &
     &             ' ', 20('*') )                                       
!                                                                       
! Corps de programme                                                    
      COEFF = (2.0 * 3.1416) / 360.0 
      DO DEG = 0, 90 
         RAD = DEG * COEFF 
         WRITE ( *, 20) DEG, RAD 
   20 FORMAT         (' *  ',I4,'  * ',F7.5,' *') 
      END DO 
!                                                                       
! Fin du tableau                                                        
      WRITE ( *, 30) 
   30 FORMAT      (' ',20('*') ) 
!                                                                       
! Fin de programme                                                      
      STOP 
      END PROGRAM DEGRAD

5-P. Frremarker

Freemarker
<html>
<head>
  <title>Welcome!</title>
</head>
<body>
  <h1>Welcome ${user}!</h1>
  <p>Our latest product:
  <a href="${latestProduct.url}">${latestProduct.name}</a>!
</body>
</html>

5-Q. Erlang

Erlang
-module(ball).

%% to run this program 
%% redefine the OTHERNODE macro
%%  > c(ball).
%%  > ball:install_code().
%%  > ball:run().

%% redefine this macro to your nodename
-define(OTHERNODE, x@yuck).

-export([install_code/0, run/0, internal/1]).

%% install_code() sends the code over the network
%% to my windows machine
install_code() -> 
    install_code(?MODULE).

install_code(Mod) ->
    ObjectPath = code:which(Mod),
    {ok, Bin} = file:read_file(ObjectPath),
    rpc:call(?OTHERNODE, code, load_binary,  [Mod, ObjectPath, Bin]).

run() ->
    Me    = spawn(?MODULE, internal, [true]),
    Other = spawn(?OTHERNODE, ?MODULE, internal, [false]),
    Me    ! Other,
    Other ! Me.

internal(Tag) ->
    etk:start(),
    Top = etk:toplevel([]),
    etk:wm([geometry, Top, "155x125+100+100"]),  
    Canvas = etk:canvas(Top, []),
    etk:pack([Canvas, {fill,both},{expand,yes}]),
    Self = self(),
    B = etk:button(Canvas, [{text, "Click to kill"},
                            {command, fun() -> Self ! quit end}]),
    etk:cmd(Canvas, [create,window,75,25,{window, B}]),
    receive
        Pid -> 
            link(Pid),
            loop(Tag, Canvas, Pid)
    end.

loop(true, Canvas, Pid) ->
    %% I got the tag create the ball
    etk:cmd(Canvas,[create, oval, 50,50,100,100,
                   {fill,red},{tag,x}]),
    receive
        quit -> exit(die);
        Other -> io:format("uugh:~p~n",[Other])
    after 2000 ->
            %% on timeout kill the ball
            etk:cmd(Canvas, [delete, x]),
            %% send a message to the other guy to create the ball
            Pid ! show,
            loop(false, Canvas, Pid)
    end;
loop(false, Canvas, Pid) ->
    receive
	quit ->
	    exit(die);
        show ->
            loop(true, Canvas, Pid)
    end.

5-R. Groovy

Groovy
class Greet {
  def name
  Greet(who) { name = who[0].toUpperCase() + who[1..-1] }
  def salute() { println "Hello $name!" }
}

g = new Greet('world') // create object
g.salute() // Output "Hello World!"

5-S. JSP

jsp
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%--
The taglib directive below imports the JSTL library. If you uncomment it,
you must also add the JSTL library to the project. The Add Library... action
on Libraries node in Projects view can be used to add the JSTL 1.1 library.
--%>
<%--
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> 
--%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>

    <h1>JSP Page</h1>
    <br/>
    <a href="./faces/purchaseOrder/List.jsp">List of PurchaseOrder</a>
    <br/>
    <a href="./faces/productCode/List.jsp">List of ProductCode</a>
    <br/>
    <a href="./faces/product/List.jsp">List of Product</a>
    <br/>
    <a href="./faces/microMarket/List.jsp">List of MicroMarket</a>
    <br/>
    <a href="./faces/manufacturer/List.jsp">List of Manufacturer</a>
    <br/>
    <a href="./faces/discountCode/List.jsp">List of DiscountCode</a>
    <br/>
    <a href="./faces/customer/List.jsp">List of Customer</a>
    <br/>
    <a href="./faces/welcomeJSF.jsp">JavaServer Faces Welcome Page</a>
    
    <%--
    This example uses JSTL, uncomment the taglib directive above.
    To test, display the page like this: index.jsp?sayHello=true&name=Murphy
    --%>
    <%--
    <c:if test="${param.sayHello}">
        <!-- Let's welcome the user ${param.name} -->
        Hello ${param.name}!
    </c:if>
    --%>
    
    </body>
</html>

5-T. Lisp

assembly-x86
(defun reverse (l &optional (acc '()))
  « renverse la liste l »
  (if (null l)
    acc
    (reverse (cdr l) (cons (car l) acc))))

5-U. Objective C

Objective C
@interface Worker : NSObject
    {
	char *name;
    @private
	int age;
	char *evaluation;
    @protected
	id job;
	float wage;
    @public
	id boss;
    }

5-V. Postscript

Postscript
%!PS
%% Une étoile
2 setlinewidth
%%
%% pour un angle d  (en degrés) trace un trait entre  (300,400)
%%      et (300 + 200 cos(d) , 400 + 300 sin(d))
/tracerayon {
      300 400 moveto
      dup dup cos 200 mul exch sin 200 mul rlineto
      stroke
      } def
%%
%% Boucle (variation de la variable de boucle de 0 à 360 par pas de 10)
0 10 360 { 
    tracerayon 
} for
%%
showpage

5-W. Propriétés

Props
hibernate.connection.driver_class = org.postgresql.Driver
hibernate.connection.url = jdbc:postgresql://localhost/mydatabase
hibernate.connection.username = myuser
hibernate.connection.password = secret
hibernate.c3p0.min_size=5
hibernate.c3p0.max_size=20
hibernate.c3p0.timeout=1800
hibernate.c3p0.max_statements=50
hibernate.dialect = net.sf.hibernate.dialect.PostgreSQLDialect

5-X. Relax NG

Relax NG
# A RELAX NG compact syntax pattern
# for an address book.
element addressBook {
  # an entry in the address book
  element card {
    element name { text },
    element email { text }  # an email address
  }*
}

5-Y. Smalltalk

smalltalk
| rectangles aPoint|
rectangles := OrderedCollection 
  with: (Rectangle left: 0 right: 10 top: 100 bottom: 200)
  with: (Rectangle left: 10 right: 10 top: 110 bottom: 210).
aPoint := Point x: 20 y: 20.
collisions := rectangles select: [:aRect | aRect containsPoint: aPoint].

5-Z. XSL

XSL
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

	<xsl:output method="xml" omit-xml-declaration="yes" indent="no" encoding="ISO-8859-1"/>
  <xsl:template match="code" mode="code">
  	
	<xsl:choose>
		<xsl:when test="count(./ligne)>0">
			<ol style="overflow: auto;" id="contenuCode{generate-id(.)}">
				<xsl:call-template name="create-empty-lines">
					<xsl:with-param name="nbLignes" select="./ligne/@num"/>
				</xsl:call-template>
				<xsl:apply-templates select="./ligne" mode="code"/>
			</ol>
		</xsl:when>
		<xsl:otherwise>
			<pre id="contenuCode{generate-id(.)}"><xsl:apply-templates select="./* | text()" mode="code"/></pre>
		</xsl:otherwise>
	</xsl:choose>
  </xsl:template>
  
  <xsl:template match="*" mode="code">
  	<xsl:if test="not(name(.) = 'code') and not(name(.) = 'ligne')">
		<xsl:element name="span">
			<xsl:attribute name="class"><xsl:value-of select="name(.)"/></xsl:attribute>
			<xsl:value-of select="."/>
		</xsl:element>
	</xsl:if>
  </xsl:template>
  
  <xsl:template match="ligne" mode="code">
  	<li class="ligne_code"><pre><xsl:apply-templates select="./* | text()" mode="code"/><xsl:value-of select="' '"/></pre></li>
  </xsl:template>
  
  <xsl:template name="create-empty-lines">
  	<xsl:param name="nbLignes"/>
	<xsl:if test="$nbLignes>1">
		<li class="ligne_code_vide"></li>
		<xsl:call-template name="create-empty-lines">
			<xsl:with-param name="nbLignes" select="$nbLignes - 1"/>
		</xsl:call-template>
	</xsl:if>
  </xsl:template>
</xsl:stylesheet>

 

Valid XHTML 1.1!Valid CSS!

Ce document ment ment est issu de http://www.developpez.com et reste la propriété exclusive de son auteur. La copie, modification et/ou distribution par quelque moyen que ce soit est soumise à l'obtention préalable de l'autorisation de l'auteur.