Exemple de p-code LSD010

Code LSD010 analysé


Code c (P2_4.t) (13 lignes) :
  1. integer foo()
  2. {
  3.   {
  4.     integer a;
  5.   }
  6.   a = 7;
  7.   return(a);
  8. }
  9. void main()
  10. {
  11.   { }
  12.   write(foo());
  13. }

Contents Haut

Affichage console de l'analyse

steph@astate:/mnt/steph_docs/FUNDP/lsd010$ source/lsd10

;
;
; LSD010 Compiler [SSHD09]
;
;
;****************************************************************************************
; Creating Symbols Table
; Using Test file...true
; Parsing tests/P2_4.t file...
; Calling yyparse()
; End of yyparse execution;
;
; Warning : 'Print tree not requested (use DEB_I level minimum to print it)' On lsd10.y, Line 647
; -------------------------------------------------------------
;
; Warning : 'Print Symbols table not requested (use DEB_I level minimum to print it)' On lsd10.y, Line 618
; -------------------------------------------------------------
;
; 1st AST walk: filling symbols table...
; 2nd AST walk: checking types and constraints...
; Generating AST Graph from last compilation into astLSD10.dot file ... (graphVizHelper.c, col 202)
; ...OK Graph printed
; Generating image from dot file : dot -Tjpg -olsd10_Img201062034437.jpg astLSD10.dot
; Generating p-code...
;
; Open lsd10.pm p-code file...OK
; Start program
ssp 0
mst 0
cup 0 @fct_main_0
ujp @program_end
; Start of foo function
define @fct_foo_0
ssp 6
ujp @fct_body_foo_0
define @fct_body_foo_0
lda i 0 0
; ---Start affectation
; Generate address for a variable
lda i 0 5
; ---Generate value for 7 integer constant
ldc i 7
sto i
; End of affectation
; ---a id
; Generate address for a variable
lda i 0 5
ind i
; Return
sto i
retf
retf
; End of foo function
; Start of main function
define @fct_main_0
ssp 5
ujp @fct_body_main_0
define @fct_body_main_0
lda i 0 0
; ---Start write operation
; ---foo function call
mst 0
cup 0 @fct_foo_0
prin
; ---End of write operation
retf
; End of main function
define @program_end
stp
; End of program
;
; ...OK P-code generated;
; Cleaning memory...
; ...OK Memory cleaned
;
;
; Parsing started at Sun Jun 20 03:44:38 2010
; 13 lines 91 chars parsed in 0.1 seconds
; Verbose set on "Minimum excution messages" level
; That's All Folks!
OK

steph@astate:/mnt/steph_docs/FUNDP/lsd010$

Contents Haut

AST [“Abstract Syntaxic Tree”2] généré

AST pour le p-code demandé

Contents Haut

P-code LSD010


Code P-code (lsd10.pm) (44 lignes) :
  1. ; Start program
  2. ssp 0
  3. mst 0
  4. cup 0 @fct_main_0
  5. ujp @program_end
  6. ; Start of foo function
  7. define @fct_foo_0
  8. ssp 6
  9. ujp @fct_body_foo_0
  10. define @fct_body_foo_0
  11. lda i 0 0
  12. ; ---Start affectation
  13. ; Generate address for a variable
  14. lda i 0 5
  15. ; ---Generate value for 7 integer constant
  16. ; End of affectation
  17. ; ---a id
  18. ; Generate address for a variable
  19. lda i 0 5
  20. ind i
  21. ; Return
  22. ; End of foo function
  23. ; Start of main function
  24. define @fct_main_0
  25. ssp 5
  26. ujp @fct_body_main_0
  27. define @fct_body_main_0
  28. lda i 0 0
  29. ; ---Start write operation
  30. ; ---foo function call
  31. mst 0
  32. cup 0 @fct_foo_0
  33. ; ---End of write operation
  34. ; End of main function
  35. define @program_end
  36. ; End of program

Contents Haut

English translation

You have asked to visit this site in English. For now, only the interface is translated, but not all the content yet.

If you want to help me in translations, your contribution is welcome. All you need to do is register on the site, and send me a message asking me to add you to the group of translators, which will give you the opportunity to translate the pages you want. A link at the bottom of each translated page indicates that you are the translator, and has a link to your profile.

Thank you in advance.

Document created the 31/07/2010, last modified the 28/10/2018
Source of the printed document:https://www.gaudry.be/en/langages-pcode-lsd.html

The infobrol is a personal site whose content is my sole responsibility. The text is available under CreativeCommons license (BY-NC-SA). More info on the terms of use and the author.

Notes

  1. a,b,c LSD010 : Langage Simple et Didactique Il existe une un certain nombre d'interprétations de l'acronyme LSD (Langage Symbolique Didactique, Langage Sans Difficulté, Langage Simple et Didactique). LSD010 est la version 2010 de la suite LSD80, LSD_02, LSD03, LSD04, LSD05, LSD06, LSD07, LSD08, et LSD09.

  2. a,b Abstract Syntaxic Tree : corresponds to « arbre syntaxique abstrait » en français

  3.  AST : “Abstract Syntaxic Tree” (en français, « arbre syntaxique abstrait »)

Contents Haut

References

  1. book Language of the document:fr IHDCB332 - Théorie des langages : Syntaxe et sémantique : PY Schobbens, Syntaxe et sémantique (January 2010)

These references and links indicate documents consulted during the writing of this page, or which may provide additional information, but the authors of these sources can not be held responsible for the content of this page.
The author This site is solely responsible for the way in which the various concepts, and the freedoms that are taken with the reference works, are presented here. Remember that you must cross multiple source information to reduce the risk of errors.

Contents Haut