Post Reply 
Social Buttons
 
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Hello Ed -2!
12-18-2018, 03:54 PM
Post: #11
RE: Hello Ed -2!
Quote:What is best is what you understand, and can implement.

Yes I agree with you.
Why I asking - in general is :
if some of them 2x faster then such a parser execute faster
especialy in loops.
Find all posts by this user
Quote this message in a reply
12-18-2018, 10:08 PM
Post: #12
RE: Hello Ed -2!
(12-18-2018 03:54 PM)Aurel Wrote:  
Quote:What is best is what you understand, and can implement.

Yes I agree with you.
Why I asking - in general is :
if some of them 2x faster then such a parser execute faster
especialy in loops.

From my reading and testing, recursive descent is as fast as anything else.
I've already talked about switching to something else for parsing expressions, but really, recursive descent is fast enough.

The main bottle neck can be tokenizing. If you're writing an interpreter that does not generate an AST or byte code, then by far the fastest way is to tokenize the entire input file before interpreting.

Efficient scanning can definitely make a difference too. Remember Herb Schildt's "Little C" interpreter? It is a pure interpreter. Its scanner is about as inefficient as you can get. By rewriting that scanner, one can make that interpreter twice as fast. And that doesn't even account for tokenizing the entire input. Doing that would also greatly improve the speed.
Find all posts by this user
Quote this message in a reply
12-19-2018, 03:45 AM
Post: #13
RE: Hello Ed -2!
Yes Ed ..you have a right.
My plan is to tokenize complete program code
then execute this tokens,
expression parser -> RD
statements execution inside runtime loop.
Tokenizer I already wrote need more token types and as such
in current state work properly.
I will use o2 for start..it is somehow zippy.
Find all posts by this user
Quote this message in a reply
01-06-2019, 08:19 PM
Post: #14
RE: Hello Ed -2!
Hi Ed

I decide to try Falcon C++ IDE with MingW compiler
and i made new GUI app project then code is in editor
then i try to print TEXT with textOut() but it seems that stupid
C refuse to print ..
here is the code :

Code:
#include <windows.h>
/* ~~~~ global intialization bcause C++ is grr...~~~~~~~~~~~~~~~~~~~~~~~~~*/
HWND hwnd;
HDC hdc ;

/* window procedure */
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);

int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR cmdParam, int cmdShow)
{
    MSG messages;        /* for messages queue manipulation */
    WNDCLASSEX WndClass; /* data struct for window class */
    HWND hWnd;           /* handle for window */
    

    /* define window class */
    WndClass.cbSize = sizeof(WNDCLASSEX);
    WndClass.style = CS_DBLCLKS;
    WndClass.hInstance = hInst;
    WndClass.lpszClassName = "WindowClassName";
    WndClass.lpfnWndProc = WndProc;

    /* icons, cursor and menu */
    WndClass.hIcon = LoadIcon(hInst, "MAINICON"); /* default icon */
    WndClass.hIconSm = LoadIcon(hInst, "MAINICON"); /* default icon */
    WndClass.hCursor = LoadCursor(NULL, IDC_ARROW); /* cursor */
    WndClass.lpszMenuName = NULL; /* no menu */
    WndClass.cbClsExtra = 0;
    WndClass.cbWndExtra = 0;

    /* window background color */
    WndClass.hbrBackground = GetSysColorBrush(COLOR_BTNFACE);
    RegisterClassEx(&WndClass);
    hWnd = CreateWindowEx(0,                     /* extended window style */
                          "WindowClassName",     /* registered class */
                          "FalconC++ Test1",     /* window title */
                          WS_OVERLAPPEDWINDOW,   /* default window style */
                          CW_USEDEFAULT,         /* x position */
                          CW_USEDEFAULT,         /* y position */
                          640,                   /* width of window */
                          480,                   /* heigth of window */
                          NULL,          /* The window is a child-window to desktop */
                          NULL,                  /* no menu */
                          hInst,                 /* Program Instance handler */
                          NULL);                 /* No Window Creation data */
                          
    ShowWindow(hWnd, SW_SHOW);
    UpdateWindow(hWnd);
    
    /*intit some things before message loop -------------------------------*/
    hdc = GetDC(hwnd);
    TextOut(hdc, 100, 100, "TEST", 4);

    //ReleaseDC(hwnd, hdc); // don't forget to release the HDC


    /* loop messages. run until GetMessage return 0*/  
    while (GetMessage(&messages, NULL, 0, 0))
    {
        TranslateMessage(&messages); /* translate virtual keys into character messages*/
        DispatchMessage(&messages);  /* Send message to WndProc */
    }
    /* return value to system */
    return messages.wParam;
}

/*  This function is called by the Windows function DispatchMessage()  */
LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    switch (message)
    {
        //case WM_PAINT
            
            
        case WM_DESTROY:
            PostQuitMessage(0); /* send a WM_QUIT to the message queue */
            break;
        default:                /* for messages that we don't deal with */
            return DefWindowProc(hwnd, message, wParam, lParam);
    }
    return 0;
}
Find all posts by this user
Quote this message in a reply
01-08-2019, 06:38 AM
Post: #15
RE: Hello Ed -2!
(01-06-2019 08:19 PM)Aurel Wrote:  Hi Ed

I decide to try Falcon C++ IDE with MingW compiler
and i made new GUI app project then code is in editor
then i try to print TEXT with textOut() but it seems that stupid
C refuse to print ..
here is the code :

Code:
#include <windows.h>
/* ~~~~ global intialization bcause C++ is grr...~~~~~~~~~~~~~~~~~~~~~~~~~*/
HWND hwnd;
HDC hdc ;

}

For this simple example, you don't need the two global variables.
Delete hwnd, and make hdc local.

And then use hWnd everywhere. Remember, C is case sensitive.

Here is a version that works:

Code:
#include <windows.h>

/* window procedure */
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);

int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR cmdParam, int cmdShow)
{
    MSG messages;        /* for messages queue manipulation */
    WNDCLASSEX WndClass; /* data struct for window class */
    HWND hWnd;           /* handle for window */
    HDC hdc ;


    /* define window class */
    WndClass.cbSize = sizeof(WNDCLASSEX);
    WndClass.style = CS_DBLCLKS;
    WndClass.hInstance = hInst;
    WndClass.lpszClassName = "WindowClassName";
    WndClass.lpfnWndProc = WndProc;

    /* icons, cursor and menu */
    WndClass.hIcon = LoadIcon(hInst, "MAINICON"); /* default icon */
    WndClass.hIconSm = LoadIcon(hInst, "MAINICON"); /* default icon */
    WndClass.hCursor = LoadCursor(NULL, IDC_ARROW); /* cursor */
    WndClass.lpszMenuName = NULL; /* no menu */
    WndClass.cbClsExtra = 0;
    WndClass.cbWndExtra = 0;

    /* window background color */
    WndClass.hbrBackground = GetSysColorBrush(COLOR_BTNFACE);
    RegisterClassEx(&WndClass);
    hWnd = CreateWindowEx(0,                     /* extended window style */
                          "WindowClassName",     /* registered class */
                          "FalconC++ Test1",     /* window title */
                          WS_OVERLAPPEDWINDOW,   /* default window style */
                          CW_USEDEFAULT,         /* x position */
                          CW_USEDEFAULT,         /* y position */
                          640,                   /* width of window */
                          480,                   /* heigth of window */
                          NULL,          /* The window is a child-window to desktop */
                          NULL,                  /* no menu */
                          hInst,                 /* Program Instance handler */
                          NULL);                 /* No Window Creation data */

    ShowWindow(hWnd, SW_SHOW);
    UpdateWindow(hWnd);

    /*intit some things before message loop -------------------------------*/
    hdc = GetDC(hWnd);
    TextOut(hdc, 100, 100, "TEST", 4);

    //ReleaseDC(hwnd, hdc); // don't forget to release the HDC


    /* loop messages. run until GetMessage return 0*/
    while (GetMessage(&messages, NULL, 0, 0))
    {
        TranslateMessage(&messages); /* translate virtual keys into character messages*/
        DispatchMessage(&messages);  /* Send message to WndProc */
    }
    /* return value to system */
    return messages.wParam;
}

/*  This function is called by the Windows function DispatchMessage()  */
LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    switch (message)
    {
        //case WM_PAINT


        case WM_DESTROY:
            PostQuitMessage(0); /* send a WM_QUIT to the message queue */
            break;
        default:                /* for messages that we don't deal with */
            return DefWindowProc(hwnd, message, wParam, lParam);
    }
    return 0;
}
Find all posts by this user
Quote this message in a reply
01-08-2019, 11:34 PM
Post: #16
RE: Hello Ed -2!
Thanks Ed

C is case sensitive.

what a hEck is that possible ..gee i cannot believe
oh my i get it authors are Really lazy
OK!
Find all posts by this user
Quote this message in a reply
01-08-2019, 11:58 PM
Post: #17
RE: Hello Ed -2!
(01-08-2019 11:34 PM)Aurel Wrote:  Thanks Ed

C is case sensitive.

what a hEck is that possible ..gee i cannot believe
oh my i get it authors are Really lazy
OK!

Just curious: How would you write the same program in Oxygen Basic?
Find all posts by this user
Quote this message in a reply
01-09-2019, 12:39 AM
Post: #18
RE: Hello Ed -2!
simple....
i will show you ...
Find all posts by this user
Quote this message in a reply
01-09-2019, 01:01 AM
Post: #19
RE: Hello Ed -2!
(01-09-2019 12:39 AM)Aurel Wrote:  simple....
i will show you ...

If your code has any included files, please attach those.
Find all posts by this user
Quote this message in a reply
01-09-2019, 01:03 AM
Post: #20
RE: Hello Ed -2!
Damn..
I forget that i must init HDC
I do that automaticly in my awinh.include file
then i draw on hdcMem backbuffer then Blit It on window.
oh such a crap
sorry ...
i must do that all before but also in C
I think I can try...

here is code in oxygen (+ awinh)

Code:
$ Filename "PrintText.exe" ' o2-043
include "RTL32.inc"
include "awinh037.inc"

#lookahead ' auto-declare procedures
INT win,wx=200,wy=200,ww=800,wh=620,wstyle = WS_MINMAXSIZE
INT button0, b0ID=100, lvControl, lvID = 1000 , static1, st1ID = 500
INT riched, ,richID=400
'create window =======================================================
win = SetWindow("GUI-Aurel-PrintText",wx,wy,ww,wh,0,wstyle)
'=====================================================================
InitDrawing() ' init HDC

TextOn (win,100,100,"_TEXT_")



'----------------------------------------------------------------------
Wait()  'message loop
'----------------------------------------------------------------------
'func main
Function WndProc (sys hwnd,wmsg,wparam,lparam) as sys callback
SELECT hwnd
    CASE win
        Select wmsg

            CASE WM_PAINT
            BitBlt(hDC, 0, 0, ww, wh, hdcMem, 0, 0, SRCCOPY)
            InvalidateRect(win, 0, 0)

            CASE WM_CLOSE
            CloseWindow(win)
            EndProgram
        End Select
END SELECT
RETURN Default
END FUNCTION
'---------------------------------------------------------
SUB TextOn(wID as INT,tx as INT,ty as INT,txt as string)

hdc = GetDC(wID)

'draw text to screen DC
TextOut hdc,tx,ty,txt,Len(txt)

'blit screen DC to memDC
BitBlt(hDCmem, 0, 0, ww, wh, hdc, 0, 0, SRCCOPY)

ReleaseDC( wID, hdc)

END SUB
'-----------------------------------------------------
SUB InitDrawing
''get current size of window
GetSize(win,0,0,ww,wh)
'get window DC
hdc=GetDC(win)
hdcMem = CreateCompatibleDC(0)
hbmMem = CreateCompatibleBitmap(hdc, ww, wh)
oldBmp = SelectObject( hdcMem, hbmMem )
oldBrush = SelectObject(hdcMem, CreateSolidBrush( RGB(231,223,231)) )
oldPen = SelectObject(hdcMem, CreatePen(PS_SOLID,1,RGB(231,223,231)))
'fill rectangle memDC with brush color
FillRect ( hdcMem,rc, oldBrush)
SetTextColor( hDC,RGB(0,0,0))
SetBkColor( hDC, RGB(231,223,231))
'blit to memDC
BitBlt(hDCmem, 0, 0, ww, wh, hdc, 0, 0, SRCCOPY)

ReleaseDC( win, hdc)
End SUB
Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: