[Date Prev]
| [Thread Prev]
| [Thread Next]
| [Date Next]
--
[Date Index]
| [Thread Index]
RE: Create a special purpose programming language, in XML, usingstate transitions
- From: William Velasquez <wvelasquez@visiontecnologica.com>
- To: "Costello, Roger L." <costello@mitre.org>, "xml-dev@lists.xml.org"<xml-dev@lists.xml.org>
- Date: Fri, 18 Oct 2013 14:28:25 +0000
Hi Roger,
For some recent project I had to create my own special purpose language, based on the concept of State Transition Machines, but it wasn't XML or XSLT but an MS Excel Macro.
The purpose was to process some financial statements sent from subsidiaries to its mother company. The problem was that they don't use an standard format, and the requirement was to extract financials facts from the Excel worksheets, no matter the format they used.
The approach was this:
- Every row in the spreadsheet is considered a collection of unordered variables (the cells)
- The rows with the same structure (same columns, with (different values) are considered to be in the same State
- All the rows in the same State has the same variables with different values
- In order to discover the State of a row, a set of State Rules are feed to the State Machine
- Every State Rule contains the clues to identify the State, i.e. a column title, some text at the beginning, an special color.
- A set of Actions is programmed for every particular State i.e. Store in a DB Table, store variables in memory, set some flags.
The general algorithm is:
- Loop thru every row in the spreadsheet
- Detecting the applicable State Rule
- Executing the associated action
- Stop when no more rows are available
Well, all this logic is written in Excel VBA, but the configuration of the State Rules and associated Actions is stored in XML documents.
For the next year I'll be working in similar project but using text spools files instead of Excel spreadsheets, to convert them to structured XML files.
It's no XSLT and for sure it's not an State Transfer Machine in the whole sense of the word, but it hope these ideas can be useful for you, and I'd like to hear from your further developments.
Cheers,
- Bill
-----Mensaje original-----
De: Costello, Roger L. [mailto:costello@mitre.org]
Enviado el: jueves, 17 de octubre de 2013 16:39
Para: xml-dev@lists.xml.org
Asunto: Create a special purpose programming language, in XML, using state transitions
Hi Folks,
Occasionally I find that I need to create a special-purpose programming language, to be used to describe how to process XML documents.
In creating the language I would mimic other programming languages such as Java, e.g.,
<if>
<condition>...</condition>
<then>
<action>...</action>
and
<while>
<condition>...</condition>
<do>
<action>...</action>
Then I would write an interpreter (using XSLT) to interpret "programs" written in my new programming language.
However, I recently realized that there is another approach. This illustrates the approach:
<Machine>
<TransitionRules>
<Transition currentState="Number" read="0" write="0"
nextState=Number" />
<Transition currentState="Number" read="1" write="1"
nextState=Number" />
<Transition currentState="Number" read=" " write="0"
nextState=Halt" />
</TransitionRules>
</Machine>
Instructions and algorithms are expressed using state transition rules.
The neat thing about this approach is:
(1) It is very regular. I don't need to invent a bunch of new elements, such as <if> and <while>.
(2) It is very powerful - it can express any algorithm [1].
(3) No need to constantly extend the language to support new features.
I was inspired to this approach after reading this fantastic article [2], which represents Turing Machines in XML.
Have you created your own special purpose programming language, formatted as XML? If so, what approach did you take to create your language?
/Roger
[1] You may recognize that this is essentially a Turing machine. Turing machines are known to be capable of expressing any algorithm.
[2] See section 2 of:
http://citeseerx.ist.psu.edu/viewdoc/download;jsessionid=F9BABBA74FAEC3276C5DEBC8CC756775?doi=10.1.1.100.3032&rep=rep1&type=pdf
[Date Prev]
| [Thread Prev]
| [Thread Next]
| [Date Next]
--
[Date Index]
| [Thread Index]