möglichst verschachtelter C++-Code



  • Mach ich.



  • Such doch hier im Forum mal danach ... afaik hat Hume da mal was gepostet

    Richtig. Allerdings im Mod-Forum im Syntaxcoloring-Beta-Test-Thread 😃

    Das sah in etwa so aus:

    // comments:
    // two comments
    /** Wie
    geht's
    */
    // a valid yet questionable comment
    //\
    H\
    a\
    l\
    l\
    o\
     Welt
    
    // A multiline comment containing lots of tabs and blanks.
    // The descriptions should be nicely aligned
    // You should not see a multiline comment if IGNORE_DOXY_COMMENT is set to YES
    /**
     * Konstruktor der Klasse.
     * @param	Name 	logischer Name der Menge
     * @param	Poa		POA für die Menge
     * @param	ItPoa	POA für Iteratoren
     **/
    
    //* Ein gemeiner Test
    if/* First we will test the comments */if
    if/* There should be no if that is commented */if
    if// End of line comment
    if/** Documentation comment */if
    if/* multiple
     line
              comment
       */if
    if/**
     multiple
     line
        doc comment
       */if
    if/*
     * nice
     * looking
     * comment
     */if
    if// /* end of line comment */ more comment
    if// /* end of line comment
    if// end of line comment */ more comment
    if/*back to*//*back*/if
    if/*back to*///back
    if/**/if
    if/***/if
    if/****/if
    if/*****/if
    if/******/if
    if/* */if
    if/* **/if
    if/* ***/if
    if/* ****/if
    if/** */if
    if/** **/if
    if/** ***/if
    if/** ****/if
    if/*** */if
    if/**** */if
    if/* * */if
    if/* ** */if
    if/** * */if
    if/** ** */if
    if/*  * */if
    if/*  ** */if
    if/**  * */if
    if/**  ** */if
    if/* * ** *** **** / // /// //// */if
    if/** * ** *** **** / // /// //// */if
    
    if/*/**/if
    if/*/***/if
    if/*/****/if
    if/*//*/if
    if/*//**/if
    if/*//***/if
    if/*//****/if
    if/*\*/if
    if/*\\*/if
    if/* *??/*/if
    if// the next line should be a comment \
    if
    
    // now for some functions
    // parameter lists and comments should be placed one below the other
    void MeinFunc	(int i)		/* ein Kommentar */
    void SeineFunc	(int j)		/* ein Kommentar */
    template <class T>
    T Foo           ();         /* ein Kommentar */
    
    // and now three function calls.
    MeinFunc        (2);
    SeineFunc       (7);
    Foo<int>        ();
    
    struct Foo
    {
    	explicit Foo();
    	virtual void Func();
    	virtual void Func() const;
    	template <class T>
    	T* create(T p, int i);
    };
    static void Func();
    
    void Foo::Func()
    {}
    void Foo::Func() const
    {}
    
    template <class T>
    T* Foo::create(T p, int)
    {
    	return 0;
    }
    
    auto
    break
    case
    const
    continue
    default
    do
    else
    enum
    extern
    for
    goto
    if
    register
    return
    sizeof
    static
    struct
    switch
    typedef
    union
    volatile
    while
    
    catch
    class
    const_cast
    delete
    dynamic_cast
    friend
    inline
    mutable
    namespace
    new
    operator
    overload
    private
    protected
    public
    reinterpret_cast
    static_cast
    template
    this
    try
    virtual
    
    bool
    char
    double
    float
    int
    long
    short
    signed
    unsigned
    void
    
    // testing the preprocessor
    // pp test (no if should be in a pp or comment)
    #include
    #include_next
    #define
    #undef
    #if
    #ifdef
    #ifndef
    #else
    #elif
    #endif
    #line
    #pragma
    #error
    if
    #define 1 //comment
    if
    #define//comment
    if
    #define/*comment*/
    if
    #define /*comment*/ 1
    if
    #define/*comment*/1
    if
    # define 1// a space after the hash
    if
     #define 1 // a space before the hash
    if
    #define something /*multiple line */ \
         4
    if
    #define aString "A string with escape sequences\n\r\t\\\""
    if
    #defineNo space after keyword
    if
    
    // Characters
    'a','b','c','d','x','y','z','1','2','9','0','A','B','C','D','X','Y','Z',' ','	',
    '!','@','#','$','%','^','&','*','(',')','{','}','?','=','+','|','~','`','"',
    // escape sequences
    '\a','\b','\f','\n','\r','\t','\v','\'','\"','\?','\\','\0',
    '\1','\2','\03','\12','\012','\111','\222','\333',
    '\xFF','\x12','\x00','\xDB','\X00','\XFF','\XDB'
    
    /* Strings */
    "hello","","abcxyz123890ABCXYZ, 	!@#$%^&*(){}?+=|~`'",
    "\a\b\f\n\r\t\v\'\"\?\\\0",
    // if you are wondering about why some of the following are valid, consider
    // "\xFFF" = '\xFF' + 'F'
    // "\29" = '\2' + '9'
    "\1\2\03\12\012\111\222\333\x000\xFFF\08\29\444",
    "a string that \
    spans \
    multiple \
    lines"
    
    ++operand;
    --operand;
    expression1=expression2;
    expression1*=expression2;
    expression1/=expression2;
    expression1%=expression2;
    expression1+=expression2;
    expression1-=expression2;
    expression1<<=shift_value;
    expression1>>=shift_value;
    expression1&=expression2;
    expression1^=expression2;
    expression1|=expression2;
    !operand
    ~operand
    expression1+expression2
    expression1-expression2
    expression1*expression2
    expression1/expression2
    expression1%expression2
    expression1&expression2
    expression1|expression2
    expression1^expression2
    expression1>>shift_value
    expression1<<shift_value
    expression1&&expression2
    expression1||expression2
    expression1<expression2
    expression1>expression2
    expression1<=expression2
    expression1>=expression2
    expression1==expression2
    expression1!=expression2
    expression?expression1:expression2
    
    ++ operand;
    -- operand;
    expression1 = expression2;
    expression1 *= expression2;
    expression1 /= expression2;
    expression1 %= expression2;
    expression1 += expression2;
    expression1 -= expression2;
    expression1 <<= shift_value;
    expression1 >>= shift_value;
    expression1 &= expression2;
    expression1 ^= expression2;
    
    expression1 |= expression2;
    
    ! operand
    ~ operand
    
    expression1 + expression2
    expression1 - expression2
    expression1 * expression2
    expression1 / expression2
    expression1 % expression2
    expression1 & expression2
    expression1 | expression2
    expression1 ^ expression2
    expression1 >> shift_value
    expression1 << shift_value
    expression1 && expression2
    expression1 || expression2
    expression1 < expression2
    expression1 > expression2
    expression1 <= expression2
    expression1 >= expression2
    expression1 == expression2
    expression1 != expression2
    expression ? expression1 : expression2
    
    /* Integer Literals */
    1 2 3 4 99 1370000
    2l 2L 2u 2U 2ul 2Ul 2UL 2uL 2lu 2Lu 2lU 2LU
    0x0 0x1 0x2 0xA 0xa 0xf 0xF 0x100 0xdeadbeef
    0x4l 0x4L 0x4u 0x4U 0x4ul 0x4Ul 0x4UL 0x4uL 0x4lu 0x4Lu 0x4lU 0x4LU
    01 02 03 04 0453222 032
    07l 07L 07u 07U 07ul 07Ul 07UL 07uL 07lu 07Lu 07lU 07LU
    
    /* Float Literals */
    0e0 .0 0. 0.0 0.0e0 0.e0 .0e0 0.0e-0 0.0e88
    1e1 .1 1. 1.1 1.1e1 1.e1 .1e1 1.1e-1 3.141592654 6.022e-22
    1.79769313486231570e+308 4.94065645841246544e-324
    1.0 0.1 1.1 2. .3 4e10 4.e23 8.3e88 2.1e-3 2E2
    0e0f 0.0e0F 0.0e-0f 1.1e1f 3.141592654f 6.022e-22f 3.40282347e+38f 1.40239846e-45f
    0e0l 0.0e0L 0.0e-0L 1.1e1L 3.141592654L 6.022e-22L 3.40282347e+38L 1.40239846e-45L
    
    /* Errors
     *
     * Anything after this has some sort of error associated with it.
     * Since there is no standard definition of what an error is or how
     * recovery after errors should be done, there is no standard way to
     * display errors.  However, if one of the errors gets reported as
     * valid that is a problem.
     */
    /* pp errors (no if should be in a pp or comment) */
    if
    #notdefined This should be an error /* with a */ comment in the middle of it \
          extending to multiple lines. // heck a comment here too.
    if
    #net
    if
    #something // comment
    if
    #frog /* comment */
    if
    #bugs// comment
    if
    #logs/* comment */
    if
    identifier #define A pp statement cannot go here
    if
    
    /* Character Errors */
    /**/'string'/**/
    /**/'\A'/**/
    /**/'\N'/**/
    /**/'unclosed/**/
    /**/'''unclosed/**/
    /**/'\'closed'/**/
    /**/'\'unclosed/**/
    /**/'\8'/**/
    /**/'\29'/**/
    /**/'\444'/**/
    /**/'\1111'/**/
    /**/'\xFFF'/**/
    /**/'\xGG'/**/
    /**/'\x000'/**/
    /**/'\x111'/**/
    /**/'\uFFF'/**/
    /**/'\uFFFFF'/**/
    /**/'\uu'/**/
    /**/'\u0'/**/
    /**/'\uFFFF'/**/
    /**/'\u1234'/**/
    /**/'\u0000'/**/
    
    /* String Errors */
    /**/"\A"/**/
    /**/"\N"/**/
    /**/"unclosed/**/
    /**/"\"unclosed/**/
    /**/"\8"/**/
    /**/"\xGG"/**/
    
    /* Identifier Errors */
    /**/1cannot_start_with_number/**/
    /**/$cannot_start_with_dollar/**/
    /**/weird`character/**/
    /**/weird#character/**/
    /**/weird@character/**/
    
    /* Integer Literal Errors */
    /**/08/**/
    /**/09/**/
    /**/0xg/**/
    /**/0xG/**/
    
    /* Float Literal Errors */
    /**/0f/**/
    /**/0F/**/
    /**/1f/**/
    /**/0e/**/
    /**/88.8e/**/
    /**/1.3d/**/
    /**/1.3D/**/
    
    // some illegal characters:
    cout <<§üüüßöö<< Foo << "John";
    
    // comments within an if statement:
    if (a == "Hallo"&&b="Fred" && c=Foo/*&& d = "jeff"*/ /* || q == 2 */)
    
    // an illegal multiline include statement
    #include \
    	\
        \
    
        <stringstream>
    
    // a valid multiline include statement
    #include \
    	\
        \
        \
        <stringstream>
    
    // a comment within an include statement is not allowed and therefore should
    // be ignored.
    #include <iostream/*.k*/>
    
    // include-Statements containing Whitespaces.
    // delimiters should be placed one below the other
    #include    <  vector.h            >
    #include    "      Foo.h           "
    
    // another include statement
    #include <iostream>
    
    // string literals containing comments
    cout << "Blockkommentare gehen in C++ /* so */";
    cout << "Zeilenkommentare aber // so";
    
    // this tool does not highlight multiline preprocessor statements
    #	i\
    n\
    c\
    l\
    u\
    d\
    e <iostream>
    
    // A multiline string literal. "Hallo" and "Wie geht's" should be placed one below the other
    const char* ch = "	Hallo \
    					Wie geht's";
    
    // an invalid identifier
    char 2cv = /*7*/6;
    
    // an illegal character within an identifier
    int Foo§Bar = 200;
    
    // some string literals
    if (a == '\\' || a == '\'' || a == '\"' || a == "\'hallo\'")
    
    // some numbers
    2, 4, 8, 16, 32, 64, 127, 255UL, 20E+5
    
    // some more numbers
    0x02, 0x04, 0X08, 0x10, 0x20, 0x40, 0x7F, 0xfFL
    
    // and now for some floating point numbers
    3.141592654, 2.3E+20   7.9E-2, 3.12f, 3.12L
    
    // hm, are you valid numbers? I don't think so.
    1x22, 00x20, 0x0g
    


  • Hier ist ein Fehler:

    // some string literals 
    if (a == '\\' || a == '\'' || a == '\"' || a == "\'hallo\'")
    


  • da sind ein paar Fehler drin 😞

    test:

    #i\
    n\
    c\
    l\
    u\
    d\
    e <iostream>
    


  • Dann begannen Dennis und Brian an einer wirklich verzerrten Version von Pascal zu arbeiten, genannt 'A'. Als wir merkten, daß andere tatsächlich vorhatten, Programme mit 'A' zu entwerfen, fügten wir rasch zusätzliche kryptische Eigenschaften hinzu, und entwickelten daraufhin B, BCPL und schließlich C. Wir hörten auf, als es uns gelang, den Ausdruck

    for(;P("\n"),R--;P("|"))for(e=C;e--;P("_"+(*u++/8)%2))P("| "+(*u/4)%2);

    fehlerfrei zu compilieren.

    Zu denken, daß moderne Programmierer versuchen würden, eine Sprache zu benutzen, die derartige Ausdrücke zuläßt, lag weit außerhalb unseres Verständnisses.



  • 😕 😕





  • i know, aber was hat das (ohne codetags) hier zu suchen?



  • Uuppsss - sorry!

    Dann begannen Dennis und Brian an einer wirklich verzerrten Version von Pascal zu arbeiten, genannt 'A'.
    Als wir merkten, daß andere tatsächlich vorhatten, Programme mit 'A' zu entwerfen,
    fügten wir rasch zusätzliche kryptische Eigenschaften hinzu,
    und entwickelten daraufhin B, BCPL und schließlich C.
    Wir hörten auf, als es uns gelang, den Ausdruck 
    
    for(;P("\n"),R--;P("|"))for(e=C;e--;P("_"+(*u++/8)%2))P("| "+(*u/4)%2); 
    
    fehlerfrei zu compilieren. 
    
    Zu denken, daß moderne Programmierer versuchen würden, eine Sprache zu
    benutzen, die derartige Ausdrücke zuläßt,
    lag weit außerhalb unseres Verständnisses.
    

    Besser??? 😃 😉



  • jepp 😃 🤡


Anmelden zum Antworten