2018년 6월 25일 월요일

[한이터백승기] AI준비단계 - 컴파일 단계 준비(5)

오늘은 출력을 구현하지만notepad.exc 안에 출력하게 만들것입니다.
당장은 노트패드 지만 MSWORD 나 한글 도 가능합니다.
물론 대상 SW는 아무것도 수정하지 않습니다.
수정할수도 없습니다 만 ^^

[소스 원본]gRTN.demo(""
"struct one1 begin;"
"int A=111,B=222,C=333;"    // 정수:초기화 -> to int array
"chr D:40,E:32;" // 문자열:길이 -> to 크기를 지정함 <- 추가
"int A=111,B=222,C=333;"    // 정수:초기화 -> to int array
"str D1='abcd',E1='';"      // 문자열:길이 -> to 가변 미구현
"num F,G;" // FLOAT NUMBER  -> to double
"end;"
"program main begin;"
"one1.A = 100;"
"one1.B = 2;"
"one1.C = one1.A + one1.B;"
"exec notepad.exe;"
"putln one1.F,one1.B,one1.G;" // like prinf
"put one1.A,one1.B,one1.C;" // like prinf
//"putln ';';"
//"putln 'RESULT=[one1.A,one1.B,one1.A]';"
"end;"
);

[실행결과화면]

[실행결과]변수를 값으로 변환하기 전에 출력대상을 프로그램 상이 아닌 외부 프로그램인
[ notepad.exe ]를 이용했습니다.
--------------------------------------------
Test Command List
--------------------------------------------
. help   - (h) show this message
. run    - (r) run script
. edit   - (e) call editor
. quit   - (q) quit program!
--------------------------------------------
r
Run scriper!
[source list begin]
[0000] struct one1 begin
[0001] int A=111,B=222,C=333
[0002] chr D:40,E:32
[0003] int A=111,B=222,C=333
[0004] str D1='abcd',E1=''
[0005] num F,G
[0006] end
[0007] program main begin
[0008] one1.A = 100
[0009] one1.B = 2
[0010] one1.C = one1.A + one1.B
[0011] exec notepad.exe
[0012] putln one1.F,one1.B,one1.G
[0013] put one1.A,one1.B,one1.C
[0014] end
[source list end]


 [struct] [one1] [begin]
 [int] [A=111] [B=222] [C=333]
 [chr] [D:40] [E:32]
 [int] [A=111] [B=222] [C=333]
 [str] [D1=] [abcd] [E1=]
 [num] [F] [G]
 [end]
 [program] [main] [begin]
 [one1.A] [=] [100]
 [one1.B] [=] [2]
 [one1.C] [=] [one1.A] [+] [one1.B]
 [exec] [notepad.exe]
 [putln] [one1.F,one1.B,one1.G]
 [put] [one1.A,one1.B,one1.C]
 [end]

VAR_TY_NONE: <struct>
<BEGIN STRUCT>
 [sStructName:one1][tag:begin]
-var-: <int>[L=10,'111' ][A=111][L=10,'222' ][B=222][L=10,'333' ][C=333]
-var-: <chr>[L=40,'40' ][D:40][L=32,'32' ][E:32]
-var-: <int>[L=10,'111' ][A=111][L=10,'222' ][B=222][L=10,'333' ][C=333]
-var-: <str>[L=128][D1=][L=128][abcd][L=128][E1=]
-var-: <num>[L=20][F][L=20][G]
<END STRUCT>

memory address![end][1]
VAR_TY_NONE: <program>
<BEGIN PROGRAM>
 [sStructName:main][tag:begin]
-prg-: <one1.A>
memory address![one1.A][3]<=><100>
-prg-: <one1.B>
memory address![one1.B][3]<=><2>
-prg-: <one1.C>
memory address![one1.C][5]<=><one1.A><+><one1.B>
-prg-: <exec>
memory address![exec][2]<notepad.exe>
-prg-: <putln>
memory address![putln][2]<one1.F,one1.B,one1.G>
-prg-: <put>
memory address![put][2]<one1.A,one1.B,one1.C>
<END PROGRAM>

memory address![end][1]
[:00]  VAR:one1
program_cnt=8
[program] top address:00  name:end [sub cnt:0]
[program] top address:01  name:one1.A [sub cnt:2]
[x][y] memory address:[01][00]  name:= [type:999]
[x][y] memory address:[01][01]  name:100 [type:999]
[program] top address:02  name:one1.B [sub cnt:2]
[x][y] memory address:[02][00]  name:= [type:999]
[x][y] memory address:[02][01]  name:2 [type:999]
[program] top address:03  name:one1.C [sub cnt:4]
[x][y] memory address:[03][00]  name:= [type:999]
[x][y] memory address:[03][01]  name:one1.A [type:999]
[x][y] memory address:[03][02]  name:+ [type:999]
[x][y] memory address:[03][03]  name:one1.B [type:999]
[program] top address:04  name:exec [sub cnt:1]
[x][y] memory address:[04][00]  name:notepad.exe [type:101]
[program] top address:05  name:putln [sub cnt:1]
[x][y] memory address:[05][00]  name:one1.F,one1.B,one1.G [type:103]
[program] top address:06  name:put [sub cnt:1]
[x][y] memory address:[06][00]  name:one1.A,one1.B,one1.C [type:102]
[program] top address:07  name:end [sub cnt:0]


[RUN]program_cnt=8
Run ...TY_ETC
TY_ETC
[EQQ] SET:[01]  name:100 [type:999]
[EQQ] [RESULT] data:100
TY_ETC
[EQQ] SET:[01]  name:2 [type:999]
[EQQ] [RESULT] data:2
TY_ETC
[EQQ] SET:[01]  name:one1.A [type:999]
[EQQ] SET:[02]  name:+ [type:999]
[EQQ] SET:[03]  name:one1.B [type:999]
[EQQ] [RESULT] data:one1.A+one1.B
TY_EXE
[RUN] WORD:[00]  name:notepad.exe [type:101]
TY_PUTLN
[RUN] PUTLN:[00]  name:one1.F,one1.B,one1.G [type:103]
TY_PUT
[RUN] PUT:[00]  name:one1.A,one1.B,one1.C [type:102]
TY_ETC 

댓글 없음:

댓글 쓰기