NO

Recent Posts

Pages: 1 ... 4 5 [6] 7 8 ... 10
51
Work in progress / Re: Undelete files
« Last post by Vortex on February 14, 2024, 10:21:16 PM »
DOS used to provide the undelete command, why M$ decided to remove it?
52
Work in progress / Re: CLR Parser yaclrcc
« Last post by John Z on February 13, 2024, 11:09:01 PM »
Hi cosh,

Congratulations!  This is so far out of my wheelhouse it's like reading Greek to me!  But I'm sure others cognizant in this area will appreciate your efforts!

John Z
53
Work in progress / CLR Parser yaclrcc
« Last post by cosh on February 11, 2024, 04:23:19 PM »
Hi, everyone.
I finished writing a canonical LR(1) parser. https://github.com/coshcage/yaclrcc
I hope this parser could be useful to you guys who want a pure C style parsing program.
The technique behind this parser is in the book Compilers Principles, Techniques and Tools (Second Edition).
However you can also advance this parser by involve developing it.
I tested this parser by using Pelles C and MSVC.
This is the file that I used to launch the parser:
Code: [Select]
#include <stdio.h>
#include <wchar.h>
#include "yaclrcc.h"

#define STR L"A : S;\nS : C C;\nC : 1 C;\nC : 2;\n"

size_t i, j;

const wchar_t * wc = L"ccccdddd";

P_QUEUE_L pq;

ptrdiff_t GetSymbol(void)
{
if (i < j)
{
return Lexer(pq, wc[i++]);
}
return 0;
}

int Reduce(ptrdiff_t n)
{
printf("REDUCE! %ld\n", n);
return CBF_TERMINATE;
}

void Error(void)
{
printf("ERROR!\n");
return CBF_TERMINATE;
}

int main()
{

P_MATRIX ptbl;
P_ARRAY_Z parrG = NULL;
pq = LexCompile(L"c\nd\n");

ptbl = ConstructCLRTable(STR, &parrG);

PrintCLRTable(ptbl);

j = wcslen(wc);

CLRParse(ptbl, parrG, GetSymbol, Reduce, Error);

LexDestroy(pq);

DestroyParrList(parrG);

DestroyCLRTable(ptbl);

return 0;
}
The parser reads this:
A : S;
S : C C;
C : 1 C;
C : 2;
grammar in and parse it to generate a parsing table like:
(-3)    (-2)    (1)     (2)     (2147483647)
 3       2       4       5       0
 0       0       0       0       2147483647
 6       0       7       8       0
 9       0       4       5       0
 0       0      r3      r3       0
 0       0       0       0      r1
 10      0       7       8       0
 0       0       0       0      r3
 0       0      r2      r2       0
 0       0       0       0      r2
REDUCE! 3
In the above grammar A,B and C instead of none-terminator and 1,2 means terminator from the lexical analyzer.
In the table, 2147483647 means ACC status.
I hope you enjoy this parser.
Regards.
54
Bug reports / Re: Incorrect parameter assignment
« Last post by Vortex on February 10, 2024, 08:28:12 PM »
Same result after this attempt :

Code: [Select]
enum MACRO p1,p2,p3,p4,p5,p6,p7,p8

LOCAL val__

val__=0
   
    FOR arg,<p1,p2,p3,p4,p5,p6,p7,p8>
   
        IFNB <arg>

            arg EQU val__
                 
            val__ = val__ +1
           
        ENDIF

    ENDM
   
ENDM

Code: [Select]
test1 = 3
sample = 3
experiment = 3
55
Bug reports / Incorrect parameter assignment
« Last post by Vortex on February 10, 2024, 10:01:20 AM »
Trying to implement an enum macro :

Code: [Select]
include enumMacro.inc

; enum macro by mabdelouahab

; https://masm32.com/board/index.php?msg=126825

enum MACRO __vargs:VARARG

LOCAL val__

    val__=0
   
    FOR __varg,<__vargs>
   
           __varg EQU val__
       
        val__ = val__ +1
       
    ENDM
   
ENDM

.data

format  db 'test1 = %u',13,10
        db 'sample = %u',13,10
        db 'experiment = %u',0

.data?

buffer  db 64 dup(?)

.code

start:

    enum    test1,sample,experiment

    invoke  wsprintf,ADDR buffer,\
            ADDR format,test1,sample,experiment

    invoke  StdOut,ADDR buffer

    invoke  ExitProcess,0

END start

Running the executable, I receive the following results :

Code: [Select]
test1 = 3
sample = 3
experiment = 3

The correct version should be :

Code: [Select]
test1 = 0
sample = 1
experiment = 2

Poasm does not correctly assign the parameters.
56
User contributions / Re: Enable Dark Mode for Title bar
« Last post by John Z on February 09, 2024, 10:27:39 PM »
Custom Caret for Dark Mode (sorry a little long...)

Turns out it is not too difficult.  There are a few point to clear up however.

The color of the caret is not going to be the color of the bitmap replacement.
It is some combination of the background and bitmap colors.  Somewhere I read only
white bits are inverted. For example with a certain gray background a brown bitmap
gives a green caret change background the caret is red with same bitmap...See attachments

The bitmap caret is not automatically scaled with the font height. To look best
this would require building the caret bitmap in code on the fly after a font change
rather then using a predefined bit map.  Still considering if worth it...

I'm using accelerator keys in the program so my main windows is created with
hwndMain= CreateDialog(hInstance, MAKEINTRESOURCE(DLG_MAIN),....
so that I can have TranslateAccelerator in the actual msg loop

IN/On the main window are edit boxes.  for example
  CONTROL "Middle", Text2, "Edit", ES_AUTOHSCROLL|WS_TABSTOP, 188, 72, 104, 12, WS_EX_STATICEDGE, 202

These controls are the ones needing the custom caret when in DarkMode

In main MainDlgProc I check the msg for what has current focus if one of the edit controls has it and it was not also the last control to have focus then I set the caret to the control.  SO far so good everything appears to work as expected.  If not in Dark Mode skip unless 1st transition out of DarkMode then set caret back to system original.

My concern is that - 
MS says "The system provides one caret per queue. A window should create a caret only when it has the keyboard focus or is active. The window should destroy the caret before losing the keyboard focus or becoming inactive."
A new caret will always destroy the old one

If further says "the windows will be sent WM_KILLFOCUS before the actual focus is lost so that DestroyCaret(); can be used.  The edit box child windows never send this message when they lose focus.  It does appear that they automatically destroy my caret when leaving because the next time I go there I still need to set the caret to the new one even though I did it before.

I did add DestroyCaret to the CLOSE message routine for the main window just in case.
Did a lot of testing jumping to different programs and within my own everything appears to be ok but I'm not sure I'm not missing something....

Code: [Select]
/-----------------------------------------------------------------------
// Function : Set_one_Caret
// Task : Set the dark mode edit caret cursor to usable color
//              : and set it back to the std caret as required
// Note     :
// Input : context on state TRUE = Dark Mode caret, FALSE = Std
//-----------------------------------------------------------------------
void Set_one_Caret( BOOL context_on, HANDLE hwnd)
{ int ans;
  static HANDLE last_hwnd=NULL;
  static BOOL last_context=FALSE;
  DWORD err;
  RECT cwin;
  int h=0;

  if ((last_hwnd == hwnd) && (last_context == context_on))
{ return;}

    // NOT really needed just for testing
GetClientRect(text[0].hctl,&cwin);// sizes std caret to control window
    h = cwin.bottom-cwin.top-2;       // only useful for built in caret

    HBITMAP hCaret1=NULL;// caret bitmap handles
if (context_on)
  { hCaret1 = LoadBitmap(ghInstance,MAKEINTRESOURCE(CARET_W));
if (hCaret1 == NULL)
           MessageBoxA(NULL,"Failed load bitmap","Set_One_Caret",MB_OK);
     // no crash with NULL though just uses system caret - so ok fall through
        ans = CreateCaret(hwnd,hCaret1,0,h);   // new cursor, h ignored
err = GetLastError();
if (ans == 0)
{MessageBoxA(NULL,"Failed Create New","Set_one_Caret",MB_OK);
             Show_Error(err, L"Set_one_Caret- creating"); //error display
    }
ans = ShowCaret(hwnd);
err = GetLastError();
if (ans == 0)
  { MessageBoxA(NULL,"Failed Show New","Set_one_Caret",MB_OK);
            Show_Error(err, L"Set_one_Caret- show"); //error display
  }
      }

   else //revert to system caret
{ // test use edit box height (h) to the set system caret height - Works
ans = CreateCaret(hwnd,(HBITMAP) 1,2,h);   // std Caret
        err = GetLastError();
if (ans == FALSE)
   {MessageBoxA(NULL,"Failed Re-Create Old","Set_one_Caret",MB_OK);
            Show_Error(err, L"Set_one_Caret- Reset,Create"); //error display
   }
ans = ShowCaret(hwnd);
        err = GetLastError();
if (ans == FALSE)
  { MessageBoxA(NULL,"Failed Re-Show Old","Set_one_Caret",MB_OK);
            Show_Error(err, L"Set_one_Caret- Reset,Apply"); //error display
  }
}

last_hwnd = hwnd;
last_context = context_on;

return;

}/* end set_one_caret */





John Z
57
User contributions / Re: Enable Dark Mode for Title bar
« Last post by John Z on February 09, 2024, 08:34:50 PM »
Hi WiiLF23,

Yup, out-of-the-box thinking, sometimes neat results occur, sometimes disaster  ;)

Custom caret for 'manual' dark mode is working well I'll post a bit more about it later.
Nothing earthshaking relatively straightforward, certainly no OOB thinking.....


John Z
58
User contributions / Re: Enable Dark Mode for Title bar
« Last post by WiiLF23 on February 09, 2024, 04:37:34 AM »
Hi John Z,
That's interesting! I wonder how many editions that is supported on (notably Windows 10). I've never seen something like that before - very cool!

59
Chit-Chat / Re: zpaqfranz
« Last post by Vortex on February 06, 2024, 09:01:12 PM »
Hi John,

Thanks for the pdf document. You can try Bandzip, a GUI based tool capable of extracting .zpaq archives :

https://www.bandisoft.com/bandizip/
60
Assembly discussions / Re: Calling a C++ function from Poasm
« Last post by Vortex on February 06, 2024, 08:57:55 PM »
Another alternative is Agner Fog's objconv tool :

Code: [Select]
5 Modifying symbols

It is possible to modify the names of public and external symbols in object files and libraries
in order to prevent name clashes, to fix problems with different name mangling systems,
etc.

Note that symbol names must be specified in the way they are represented in object files,
possibly including underscores and name mangling information. All names are treated as
case sensitive. Use the dump or disassembly feature to see the mangled symbol names.
To change the symbol name name1 to name2 in object file file1.obj:

objconv -nr:name1:name2 file1.obj file2.obj

The modified object file will be file2.obj. Objconv will replace name1 with name2
wherever it occurs in public, external and local symbols, as well as section names and
library member names. All names are case sensitive.

https://www.agner.org/optimize/objconv-instructions.pdf
Pages: 1 ... 4 5 [6] 7 8 ... 10