суббота, 21 ноября 2009 г.

About syntax analizer in YAR Language

The YAR language syntax analizer supports for parsing methods:

-LL(1)
-CYK
-SLR,
-CLR(1)
-LARL(1)
-Simple precedence
-Operator precedence
-My extension for CLR method. I call it ECLR(1) method.

But YAR language now is being parsed by LARL(1) method.

Here is the semantic action sample

TTokenSequence.create(PNS_EXPR,[PTS_CONST_EXP_STRING],'',
function(LRAnalizer:TLRAnalizer):pointer
var value:TExprState;
begin
value.value:=LRAnalizer.StackValue[0].Lexeme;
value.ExprStateItem.TypeDesc:=StringTypeDesc;
PNS_EXPR.AttribitesList.Add(value);
result:=nil;
end
);

пятница, 13 ноября 2009 г.

YAR Language enhancement

Now Supports for
-Integer,Float,String,Char,Boolean types
-Type inference
-Operator and functions overloads

вторник, 3 ноября 2009 г.

понедельник, 26 октября 2009 г.

Program language name

I choose the language name. So I call it YAR.

Here is the code sample that was succesfully executed today.
program Helloworld;
var a,b,c:integer;
d,ec,fg:float;
j,z,i:integer;
begin
a:=123;
b:=a;
write b;
write a+2*b;
c:=a+2*(b+2);
write c;
b:=321;
a:=c+100*2-a/(b-100)*200/300-400;
write a;
end

понедельник, 20 июля 2009 г.

Still hard working on compiler

I am still hard working on compiler in my free time.
And more more with my son Yaroslav.

понедельник, 16 февраля 2009 г.

For russian fellow Maaacheba or getting method name dynamically

It is still a draft implementation,
but it can be extended for other x86 opcodes.
So it is a base idea.
And it can be extended to support dynamic methods invocation.

TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
Published
procedure StaticMethod;
procedure VirtualMethod(a,b,c,d:integer);virtual;
end;

THelper= class helper for Tobject
function GetMethodAddress:pointer;
end;


implementation

type
PPDWORD=^PDWORD;

function AnalizeCallMethod(Self:PPDWORD;ReturnAddress:pbyte;SomePlaceInTheMethodCode:pointer):DWORD;
var Operation:DWORD;
VMT:PDWORD;
Offset:Integer;
begin
{$POINTERMATH ON}
//Virtual Call
Operation:=DWORD((@ReturnAddress[-6])^) AND $FF;
case Operation of
$FF:
begin
VMT:=Self[0];
Offset:=DWORD((@ReturnAddress[-4])^);
result:=DWORD((@(Pbyte(VMT)[Offset]))^);
exit;
end;
end;
Operation:=DWORD((@ReturnAddress[-5])^) AND $E8;
//Static Call
case Operation of
$E8:
begin
result:=DWORD(ReturnAddress)+DWORD((@ReturnAddress[-4])^);
exit;
end;
end;
{$POINTERMATH OFF}
end;

{ THelper }

function THelper.GetMethodAddress: pointer;
asm
mov edx,[ebp+04];
mov ecx,[esp];
Call AnalizeCallMethod;
end;

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
StaticMethod;
VirtualMethod(1,2,3,4);
end;

procedure TForm1.StaticMethod;
begin
showmessage(MethodName(GetMethodAddress));
end;

procedure TForm1.VirtualMethod(a,b,c,d:integer);
begin
showmessage(MethodName(GetMethodAddress));
end;