DGL
https://delphigl.com/forum/

@BTCC | ehemals: Spass mit F#
https://delphigl.com/forum/viewtopic.php?f=14&t=11383
Seite 2 von 2

Autor:  yunharla [ Di Apr 19, 2016 22:05 ]
Betreff des Beitrags:  Re: @BTCC | ehemals: Spass mit F#

Hallo Zusammen,

Ich habe jetzt mal die ganzen Statements und Declarationen ordentlich aufgeräumt, sowie ein paar Bugfixes am Parser vorgenommen (Git Update gibts morgen). Brauche aber mal euren Input zum neuen Syntax:
Code:
  1.  
  2. //includes mit guard
  3. import "cglue.bl";
  4.  
  5. //variablen
  6. variable1 : int;
  7. variable2 : int = 2;
  8. variable3 := "hallo world";
  9.  
  10. //Storage Klassen
  11. import someExtern : int();
  12. static someStatic : int = 0;
  13. thread someThreadLocal : int = 0;
  14.  
  15. //Type Qualifier (können wie wild gemischt werden)
  16. constantVariable : const = "hallo world";
  17. volatileVariable : volatile = "hallo world";
  18. referenzVariable : ref = "hallo world";
  19. referenzVariable2 : ref ref = "hallo world"; //ist das gleiche wie ein einfaches ref
  20.  
  21. //Funktionen sind Variablen mit Parameter und CompoundStatement
  22. function2(x:int,y : float, z : string) : bool {
  23.     return x > 5;
  24. }
  25. //oder Expression :-)
  26. function1(x:int) : const volatile bool = x > 5;
  27.  
  28. //TypeAlias
  29. type vec2_f = float[2];
  30. //Struct
  31. type point = {
  32.     x: float;
  33.     y: float;
  34.     str := "hallo world";
  35.     toVec() : vec2_f = [x,y];
  36. }
  37.  
  38. //Bindings
  39. bind FileOut(name: const char[]) : const ref FILE {
  40.     this = fopen(name,"wb");
  41.     if(this) {
  42.         yield; //führt das Statement aus
  43.         fclose(this);
  44.     }
  45. }
  46.  
  47. testBang() : void {
  48.     FileOut("log.txt") as src {
  49.         fprintf(src,"hallo world\n");
  50.     }
  51. }
  52.  

Seite 2 von 2 Alle Zeiten sind UTC + 1 Stunde
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/