~efargaspro/+junk/codeblocks-16.01-release

« back to all changes in this revision

Viewing changes to src/sdk/resources/lexers/lexer_d.sample

  • Committer: damienlmoore at gmail
  • Date: 2016-02-02 02:43:22 UTC
  • Revision ID: damienlmoore@gmail.com-20160202024322-yql5qmtbwdyamdwd
Code::BlocksĀ 16.01

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**
 
2
 * This is a Ddoc block comment
 
3
 * Authors: Melvin D. Nerd, melvin@mailinator.com
 
4
 * Bugs:    Doesn't work for negative values.
 
5
 * Date:    March 14, 2003
 
6
 */
 
7
 
 
8
module hello;
 
9
import std.stdio;
 
10
 
 
11
/**
 
12
  * This is a documentation comment block
 
13
  * @param xxx does this (this is the documentation keyword)
 
14
  * @authr some user (this is the documentation keyword error)
 
15
  */
 
16
 
 
17
void main(string[] args)
 
18
{
 
19
    /*
 
20
     * Sample preview code
 
21
     * This is a block comment
 
22
     */
 
23
 
 
24
    /// Deprecated: superseded by function bar().
 
25
    void foo() {  }
 
26
 
 
27
    int numbers[20];
 
28
        int average = 0;
 
29
        char ch = '\n';
 
30
    int a =     /+ Nested Comment +/ 1;
 
31
    int b = 2;  // Line Comment
 
32
 
 
33
    writefln("Hello World, Reloaded");
 
34
 
 
35
    // auto type inference and built-in foreach
 
36
    foreach (argc, argv; args)
 
37
    {
 
38
        // Improved typesafe printf
 
39
        writeln("argc: ", argc, " arg: ", argv);
 
40
    }
 
41
 
 
42
    // Nested structs and classes
 
43
    struct specs
 
44
    {
 
45
        // all members automatically initialized
 
46
        int count, allocated;
 
47
    }
 
48
 
 
49
    // Nested functions can refer to outer
 
50
    // variables like args
 
51
    specs argspecs()
 
52
    {
 
53
        specs* s = new specs;
 
54
        // no need for '->'
 
55
        s.count = args.length;                 // get length of array with .length
 
56
        s.allocated = typeof(args).sizeof; // built-in native type properties
 
57
        foreach (argv; args)
 
58
            s.allocated += argv.length * typeof(argv[0]).sizeof;
 
59
        return *s;
 
60
    }
 
61
 
 
62
    // built-in string and common string operations
 
63
    writefln("argc = %d, " ~ "allocated = %d",
 
64
        argspecs().count, argspecs().allocated);
 
65
}