Difference between revisions of "VM for transfer"
Jump to navigation
Jump to search
Darthxaher (talk | contribs) |
Darthxaher (talk | contribs) |
||
Line 78: | Line 78: | ||
pusht gen_chunk |
pusht gen_chunk |
||
pusht nbr_chunk |
pusht nbr_chunk |
||
⚫ | |||
; code for the first lexical unit |
; code for the first lexical unit |
||
Line 96: | Line 95: | ||
push [regex] ; nbr_sp |
push [regex] ; nbr_sp |
||
cliptl |
cliptl |
||
push 6 |
|||
lu |
lu ; pop 6 items, concat, create lexical unit ^...$ and push back in stack |
||
pushbl ; push a blank |
pushbl ; push a blank |
||
Line 104: | Line 104: | ||
push "<3>" |
push "<3>" |
||
push "<pl>" |
push "<pl>" |
||
push 4 |
|||
⚫ | |||
⚫ | |||
; push in the stack |
; push in the stack |
||
Line 126: | Line 127: | ||
push [regex] ; lemq |
push [regex] ; lemq |
||
cliptl |
cliptl |
||
push 7 |
|||
lu |
|||
pushbl |
pushbl |
||
Line 146: | Line 148: | ||
push [regex] ; lemq |
push [regex] ; lemq |
||
cliptl |
cliptl |
||
push 7 |
|||
lu |
|||
⚫ | |||
brace ; pop 7 items, concat, prepend and append {, } then push back |
|||
push 6 |
|||
chunk ; create the chunk, ^...{^...$}$, and push back in stack |
|||
</code> |
</code> |
Revision as of 05:36, 30 May 2010
Contents
Instruction Sets
Mnemonic | Opcode (in hex) |
Other operands | Stack [before]→[after] |
Description |
---|---|---|---|---|
push | - | value | [empty] → value | Pushes a value in the stack |
jmp | - | N/A | label → [empty] | Jumps to the label |
hlt | - | N/A | Halts the program | |
return | - | N/A | PC → [empty] | Returns from a subroutine |
Notes
- None of the macro and actions need to return anything (unlike conventional functions), so provision for returning a value (using stack) is unnecessary
Sample Translation from XML to byte-code
<out>
<chunk name="det_det_nom_adj" case="caseFirstWord">
<tags>
<tag><lit-tag v="SN"/></tag>
<tag></tag>
<tag></tag>
<tag></tag>
</tags>
<lu>
<clip pos="1" side="tl" part="lem"/>
<clip pos="1" side="tl" part="a_det"/>
<clip pos="1" side="tl" part="gen_sense_mf" link-to="3"/>
<clip pos="1" side="tl" part="gen_mf"/>
<clip pos="1" side="tl" part="nbr_sense_sp" link-to="4"/>
<clip pos="1" side="tl" part="nbr_sp"/>
</lu>
<lu>
<lit v="el"/>
<lit-tag v="det.def"/>
<clip pos="1" side="tl" part="gen_sense_mf" link-to="3"/>
<lit-tag v="pl"/>
</lu>
<lu>
<clip pos="3" side="tl" part="lemh"/>
<clip pos="3" side="tl" part="a_nom"/>
<clip pos="3" side="tl" part="gen_sense_mf" link-to="3"/>
<clip pos="3" side="tl" part="gen_mf"/>
<clip pos="3" side="tl" part="nbr_sense_sp" link-to="4"/>
<clip pos="3" side="tl" part="nbr_sp"/>
<clip pos="3" side="tl" part="lemq"/>
</lu>
<lu>
<clip pos="2" side="tl" part="lemh"/>
<clip pos="2" side="tl" part="a_adj"/>
<clip pos="2" side="tl" part="gen_sense_mf" link-to="3"/>
<clip pos="2" side="tl" part="gen_mf"/>
<clip pos="2" side="tl" part="nbr_sense_sp" link-to="4"/>
<clip pos="2" side="tl" part="nbr_sp" link-to="4"/>
<clip pos="2" side="tl" part="lemq"/>
</lu>
</chunk>
</out>
Corresponding byte-code
push "det_det_nom_adj"
pusht "SN" ; push tag: "SN" -> "<SN>", then push in the stack
pusht tipus_det ; if operand does not start/end with ", then it's a variable
; first evaluate the variable, then push in the stack
pusht gen_chunk
pusht nbr_chunk
; code for the first lexical unit
push 1
push "^\w+" ; lem
cliptl
push 1
push [regex] ; a_det
cliptl
push "<3>" ; since link-to overrides everything else, we do not need any dedicated instruction
; for that
push 1
push [regex] ; gen_mf
cliptl
push "<4>"
push 1
push [regex] ; nbr_sp
cliptl
push 6
lu ; pop 6 items, concat, create lexical unit ^...$ and push back in stack
pushbl ; push a blank
push "el"
push "<det><def>"
push "<3>"
push "<pl>"
push 4
lu ; pop 4 items from the stack, create a lexical unit ^...$ and then
; push in the stack
pushbl
push 3
push [regex] ; lemh
cliptl
push 3
push [regex] ; a_nom
cliptl
push "<3>"
push 3
push [regex] ; gen_mf
cliptl
push "<4>"
push 3
push [regex] ; nbr_sp
cliptl
push 3
push [regex] ; lemq
cliptl
push 7
lu
pushbl
push adjectiu1 ; no quotation, and starts with alpha, so its a var, eval and push
push 3
push [regex] ; lemh
cliptl
push 3
push [regex] ; a_adj
cliptl
push "<3>"
push 3
push [regex] ; gen_mf
cliptl
push "<4>"
push "<4>"
push 3
push [regex] ; lemq
cliptl
push 7
lu
push 7 ; no of blank + lexical unit = 7
brace ; pop 7 items, concat, prepend and append {, } then push back
push 6
chunk ; create the chunk, ^...{^...$}$, and push back in stack