Last active
April 30, 2018 05:19
yang tutorial data
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<!-- | |
binary increment | |
Turing machine visualization http://turingmachine.io/ | |
--> | |
<config xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"> | |
<turing-machine xmlns="http://example.net/turing-machine"> | |
<transition-function> | |
<delta> | |
<label>right/1</label> | |
<input> | |
<state>0</state> | |
<symbol>1</symbol> | |
</input> | |
<output> | |
<state>0</state> | |
<symbol/> | |
<head-move>right</head-move> | |
</output> | |
</delta> | |
<delta> | |
<label>right/0</label> | |
<input> | |
<state>0</state> | |
<symbol>0</symbol> | |
</input> | |
<output> | |
<state>0</state> | |
<symbol/> | |
<head-move>right</head-move> | |
</output> | |
</delta> | |
<delta> | |
<label>right/null</label> | |
<input> | |
<state>0</state> | |
<symbol/> | |
</input> | |
<output> | |
<state>1</state> | |
<symbol/> | |
<head-move>left</head-move> | |
</output> | |
</delta> | |
<delta> | |
<label>carry/1</label> | |
<input> | |
<state>1</state> | |
<symbol>1</symbol> | |
</input> | |
<output> | |
<state>1</state> | |
<symbol>0</symbol> | |
<head-move>left</head-move> | |
</output> | |
</delta> | |
<delta> | |
<label>carry/0</label> | |
<input> | |
<state>1</state> | |
<symbol>0</symbol> | |
</input> | |
<output> | |
<state>2</state> | |
<symbol>1</symbol> | |
<head-move>left</head-move> | |
</output> | |
</delta> | |
<delta> | |
<label>carry/null (overflow)</label> | |
<input> | |
<state>1</state> | |
<symbol/> | |
</input> | |
<output> | |
<state>2</state> | |
<symbol>1</symbol> | |
<head-move>left</head-move> | |
</output> | |
</delta> | |
</transition-function> | |
</turing-machine> | |
</config> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="1"> | |
<initialize xmlns="http://example.net/turing-machine"> | |
<tape-content>1011</tape-content> | |
</initialize> | |
</rpc> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- /usr/local/share/yang/xslt/jsonxsl-templates.xsl 2018-04-27 19:26:28.944275856 +0900 | |
+++ jsonxsl-templates.xsl 2018-04-28 14:45:25.737498775 +0900 | |
@@ -368,7 +368,7 @@ | |
<xsl:with-param name="level" select="$level"/> | |
</xsl:call-template> | |
<xsl:value-of | |
- select="concat('"', $nsid, local-name(.), '": {')"/> | |
+ select="concat('"', translate(local-name(.),'-','_'), '": {')"/> | |
<xsl:if test="@*"> | |
<xsl:call-template name="metadata-object"> | |
<xsl:with-param name="name">"@": </xsl:with-param> | |
@@ -389,7 +389,7 @@ | |
<xsl:with-param name="level" select="1"/> | |
</xsl:call-template> | |
<xsl:value-of | |
- select="concat('"', $nsid, 'input', '": {')"/> | |
+ select="concat('"', local-name(.), '": {')"/> | |
<xsl:apply-templates/> | |
<xsl:call-template name="nl-indent"> | |
<xsl:with-param name="level" select="1"/> | |
@@ -407,7 +407,7 @@ | |
<xsl:with-param name="level" select="$level"/> | |
</xsl:call-template> | |
<xsl:value-of | |
- select="concat('"', $nsid, local-name(.), '": ')"/> | |
+ select="concat('"', translate(local-name(.), '-', '_'), '": ')"/> | |
<xsl:call-template name="json-value"> | |
<xsl:with-param name="type" select="$type"/> | |
<xsl:with-param name="options" select="$options"/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- tm-json.orig.xsl 2018-04-28 13:02:25.093498775 +0900 | |
+++ tm-json.xsl 2018-04-28 14:47:05.069498775 +0900 | |
@@ -1,7 +1,7 @@ | |
<?xml version="1.0" encoding="UTF-8"?> | |
<stylesheet xmlns="http://www.w3.org/1999/XSL/Transform" xmlns:en="urn:ietf:params:xml:ns:netconf:notification:1.0" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:tm="http://example.net/turing-machine" version="1.0"> | |
<output method="text"/> | |
- <include href="/usr/local/share/yang/xslt/jsonxsl-templates.xsl"/> | |
+ <include href="./jsonxsl-templates.xsl"/> | |
<strip-space elements="*"/> | |
<template name="nsuri-to-module"> | |
<param name="uri"/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- turing-machine-config.orig.json 2018-04-28 11:49:49.617498775 +0900 | |
+++ turing-machine-config.json 2018-04-28 14:47:17.801498775 +0900 | |
@@ -1,6 +1,6 @@ | |
{ | |
- "turing-machine:turing-machine": { | |
- "transition-function": { | |
+ "turing_machine": { | |
+ "transition_function": { | |
"delta": [ | |
{ | |
"label": "initial/search separator", | |
@@ -11,7 +11,7 @@ | |
"output": { | |
"state": 0, | |
"symbol": "", | |
- "head-move": "right" | |
+ "head_move": "right" | |
} | |
}, | |
{ | |
@@ -34,7 +34,7 @@ | |
"output": { | |
"state": 1, | |
"symbol": "", | |
- "head-move": "left" | |
+ "head_move": "left" | |
} | |
}, | |
{ | |
@@ -46,7 +46,7 @@ | |
"output": { | |
"state": 2, | |
"symbol": "", | |
- "head-move": "right" | |
+ "head_move": "right" | |
} | |
}, | |
{ | |
@@ -69,7 +69,7 @@ | |
"output": { | |
"state": 3, | |
"symbol": "", | |
- "head-move": "right" | |
+ "head_move": "right" | |
} | |
}, | |
{ | |
@@ -92,7 +92,7 @@ | |
"output": { | |
"state": 4, | |
"symbol": "", | |
- "head-move": "right" | |
+ "head_move": "right" | |
} | |
} | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- turing-machine-rpc.orig.json 2018-04-30 03:48:06.020381899 +0000 | |
+++ turing-machine-rpc.json 2018-04-30 04:20:55.820902794 +0000 | |
@@ -1,5 +1,5 @@ | |
{ | |
- "turing-machine:input": { | |
- "tape-content": "110111" | |
+ "initialize": { | |
+ "tape_content": "110111" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- turing-machine.orig.proto 2018-04-29 21:10:01.227068211 +0900 | |
+++ turing-machine.proto 2018-04-29 21:49:25.741239767 +0900 | |
@@ -9,12 +9,16 @@ | |
// Data model for the Turing Machine. | |
package turing_machine; | |
-service TuringMachine { | |
+service TuringMachineRpc { | |
+ rpc Configure (TuringMachine) returns (Empty); | |
rpc Initialize (InitializeRequest) returns (Empty); | |
+ rpc Run (Empty) returns (Notification); | |
+ rpc GetState (Empty) returns (TuringMachine); | |
} | |
message InitializeRequest { | |
// The string with which the tape shall be initialized. The | |
// leftmost symbol will be at tape coordinate 0. | |
+ // @inject_tag: xml:"tape-content" | |
string tape_content = 1; | |
} | |
@@ -25,77 +29,113 @@ | |
message Halted { | |
// The state of the control unit in which the machine has | |
// halted. | |
+ // @inject_tag: xml:"state" | |
uint32 state = 1; | |
} | |
+// Notification | |
+message Notification { | |
+ // @inject_tag: xml:"xmlns,attr" | |
+ string xmlns = 1; | |
+ // @inject_tag: xml:"eventTime" | |
+ string event_time = 2; | |
+ // @inject_tag: xml:"halted" | |
+ Halted halted = 3; | |
+} | |
+ | |
// Start the Turing Machine operation. | |
message Run { | |
} | |
+// Config data | |
+message Config { | |
+ // @inject_tag: xml:"xmlns,attr" | |
+ string xmlns = 1; | |
+ // @inject_tag: xml:"turing-machine" | |
+ TuringMachine turing_machine = 2; | |
+} | |
+ | |
+// Initialize Request RPC | |
+message Rpc { | |
+ // @inject_tag: xml:"message-id,attr" | |
+ uint32 message_id = 1; | |
+ // @inject_tag: xml:"initialize" | |
+ InitializeRequest initialize = 2; | |
+} | |
+ | |
+// Move the head one cell to the left or right | |
+enum HeadMove { | |
+ LEFT = 0; | |
+ RIGHT = 1; | |
+}; | |
+ | |
// State data and configuration of a Turing Machine. | |
message TuringMachine { | |
// Position of tape read/write head. | |
+ // @inject_tag: xml:"head-position" | |
int64 head_position = 1; | |
// Current state of the control unit. | |
- // | |
// The initial state is 0. | |
+ // @inject_tag: xml:"state" | |
uint32 state = 2; | |
// The contents of the tape. | |
- // The contents of the tape. | |
message Tape { | |
// List of non-blank cells. | |
- // List of non-blank cells. | |
message Cell { | |
// Coordinate (index) of the tape cell. | |
+ // @inject_tag: xml:"coord" | |
int64 coord = 1; | |
// Symbol appearing in the tape cell. | |
- // | |
// Blank (empty string) is not allowed here because the | |
// 'cell' list only contains non-blank cells. | |
+ // @inject_tag: xml:"symbol" | |
string symbol = 2; | |
} | |
+ // @inject_tag: xml:"cell" | |
repeated Cell cell = 1; | |
} | |
+ // @inject_tag: xml:"tape" | |
Tape tape = 3; | |
// The Turing Machine is configured by specifying the | |
// transition function. | |
- // The Turing Machine is configured by specifying the | |
- // transition function. | |
message TransitionFunction { | |
// The list of transition rules. | |
- // The list of transition rules. | |
message Delta { | |
// Input parameters (arguments) of the transition rule. | |
- // Input parameters (arguments) of the transition rule. | |
message Input { | |
// Current state of the control unit. | |
+ // @inject_tag: xml:"state" | |
uint32 state = 1; | |
// Symbol read from the tape cell. | |
+ // @inject_tag: xml:"symbol" | |
string symbol = 2; | |
} | |
+ // @inject_tag: xml:"input" | |
Input input = 1; | |
// An arbitrary label of the transition rule. | |
+ // @inject_tag: xml:"label" | |
string label = 2; | |
// Output values of the transition rule. | |
- // Output values of the transition rule. | |
message Output { | |
- // Move the head one cell to the left or right | |
- enum HeadMove { | |
- HeadMove_LEFT = 0; | |
- HeadMove_RIGHT = 1; | |
- }; | |
- HeadMove head_move = 1; | |
+ // HeadMove head_move = 1; | |
+ // @inject_tag: xml:"head-move" | |
+ string head_move = 1; | |
// New state of the control unit. If this leaf is not | |
// present, the state doesn't change. | |
+ // @inject_tag: xml:"state" | |
uint32 state = 2; | |
// Symbol to be written to the tape cell. If this leaf is | |
// not present, the symbol doesn't change. | |
+ // @inject_tag: xml:"symbol" | |
string symbol = 3; | |
} | |
+ // @inject_tag: xml:"output" | |
Output output = 3; | |
} | |
+ // @inject_tag: xml:"delta" | |
repeated Delta delta = 1; | |
} | |
+ // @inject_tag: xml:"transition-function" | |
TransitionFunction transition_function = 4; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment