THIS IS A BEST EXAMPLE OF A UNIVERSAL PARSER
http://codeworker.free.fr
I work on programming a program in C or Pascal
that can transform the string "y=2*x+cos(x)" into
a tree or a graph. The multiplication must be
evaluated before the addition and the keyword COS
must be recognized. It's writing a PARSER in C
and ORCA/C with GNO can do that. Try to program
a graphical calculator that can plot equations
given an equation like y=x*x.
Here is a sample code I made using codeworker for recognizing
patterns of text or for example HTML tags.
You can use the JASON file format to exchange data
between two different databases or you can do your
own PARSER as follow. This example shows that text
files can be used to transfer data between two different
databases without using API that can't be debugged.
With the text files you have a trace.
You have database servers that can scan folders for text
files to be imported and first exported.
Things become more complex when having docx, pdf, jpg
files included with records to transfer with text files
between two different databases.
SHELL SCRIPT :
cp fiche_ticket_amerana_blob3.txt fiche_ticket_amerana_blob3.tml
./codeworker -translate moulinette_2_003.cwp fiche_ticket_amerana_blob3.tml fiche_ticket_glpi_blob3.out
SOURCE FILE :
AMERANA_NOM="DUPONT";
AMERANA_PRENOM="Henri";
AMERANA_AGE=25;
Premiere ligne
Deuxieme ligne
Troisieme ligne
DESTINATION FILE :
GLPI_NOM="DUPONT";
GLPI_PRENOM="Henri";
GLPI_AGE=25;
Premiere ligne
Deuxieme ligne
Troisieme ligne;
SOURCE CODE FOR/FROM CODEWORKER
source ::=
#continue
#ignore(C++)
[
balise_nom #continue
=>{traceLine("j'ai reconnu balise_nom");}
|
balise_prenom #continue
=>{traceLine("j'ai reconnu balise_prenom");}
|
balise_age #continue
=>{traceLine("j'ai reconnu balise_age");}
|
valeur_champ #continue
=>{traceLine("j'ai reconnu la valeur du champ");}
|
balise_texte_ouverte #continue
[
valeur_champ #continue
|
balise_texte_fermee #continue
| ';' #empty
]*
|
balise_texte_fermee #continue
| ';' #continue
]*
#empty
;
nombre ::= ['0'..'9']+:sNombre
=> { @ Un nombre = @sNombre@
@ };
mot ::= #!ignore ['a'..'z'|'A'..'Z']+:sMot
=> { @ Un mot = @sMot@
@ };
balise_texte_ouverte ::= ""
=> { @
@ };
balise_texte_fermee ::= ""
=> { @
@ };
balise_nom ::= "AMERANA_NOM="
=>{ @GLPI_NOM=@};
balise_prenom ::= "AMERANA_PRENOM="
=>{ @
GLPI_PRENOM=@ };
balise_age ::= "AMERANA_AGE="
=>{ @
GLPI_AGE=@ };
valeur_champ ::= ['"'|'a'..'z'|'A'..'Z'|'0'..'9']+:sValeur
=>{ @@sValeur@;@};