OpenStreetCode
OpenStreetCode is an esolang by User:PythonshellDebugwindow based on JOSM, an editor for OpenStreetMap.
Syntax
OpenStreetCode files are .OSM files (generatable using JOSM). All valid .OSM files are valid OpenStreetCode files, syntax-wise at least.
Memory
OpenStreetCode uses an unbounded signed integer cell index, an unbounded array of unbounded signed float cells, and an unbounded signed incrementation register.
Use of elements
Note: all elements can have other, unnecessary tags (name=*
, landuse=*
, shop=clothes
, etc.); these do not affect the program in any way.
Nodes
Nodes represent the instructions in a program. All nodes must be connected to ways.
Instruction table
Tag | Instruction |
---|---|
amenity=bank |
Add 0.1 to the incrementation register |
amenity=bureau_de_change |
Subtract 0.1 from the incrementation register |
amenity=atm |
Add the incrementation register to the cell at the current cell index |
craft=beekeeper |
Increase the current cell index by 1 |
craft=plumber |
Decrease the current cell index by 1 |
shop=wine |
Print the cell at the current cell index as a character |
shop=copyshop |
Print the cell at the current cell index as a float followed by a newline |
craft=photographer |
Input a character to the cell at the current cell index |
shop=painter |
Input a float to the cell at the current cell index (invalid floats are treated as zero, valid floats match the regex [+-]?[0-9]+(\.[0-9]+)? )
|
Ways
Ways are used to connect nodes. Ways must have the highway=residential
tag.
Relations
Relations are used for loops. type=multipolygon
relations represent while loops, with role=outer
ways being "inside" the while loop, role=label
nodes representing the entry points of loops, and role=admin_centre
nodes representing the exit points of loops (these loop relations should contain have exactly 1 label
and admin_centre
and at least one outer
); these should be closed, and their label
s and admin_centre
s should each be a part of at least one outer
way. These loops start at the label
, jump to the admin_centre
if the cell at the current cell index is equal to zero; otherwise they follow the outer
way(s) to the admin_centre
, jump back to the label
if the cell at the current cell is not equal to zero, follow the outer
way(s) to the admin_centre
, conditionally jump back again, and so on; basically, your traditional while loop.
Examples
Print the letter A
Image
Text
To view this code in JOSM, simply copy it into a .OSM file on your computer, launch JOSM, and open the file you created.
<?xml version='1.0' encoding='UTF-8'?> <osm version='0.6' generator='JOSM'> <node id='-103396' action='modify' visible='true' lat='1.71372409748' lon='25.58273693242'> <tag k='amenity' v='atm' /> </node> <node id='-103404' action='modify' visible='true' lat='1.71391000537' lon='25.58273786705'> <tag k='amenity' v='atm' /> </node> <node id='-103832' action='modify' visible='true' lat='1.71558126012' lon='25.58272485226'> <tag k='entrance' v='main' /> </node> <node id='-103833' action='modify' visible='true' lat='1.71557397262' lon='25.58417570942'> <tag k='amenity' v='bank' /> </node> <node id='-103834' action='modify' visible='true' lat='1.7155726798' lon='25.58443309356'> <tag k='amenity' v='bank' /> </node> <node id='-103835' action='modify' visible='true' lat='1.71557150675' lon='25.58466663369'> <tag k='amenity' v='bank' /> </node> <node id='-103836' action='modify' visible='true' lat='1.71557033307' lon='25.5849003'> <tag k='amenity' v='bank' /> </node> <node id='-103837' action='modify' visible='true' lat='1.7155688967' lon='25.58518626561'> <tag k='amenity' v='bank' /> </node> <node id='-103838' action='modify' visible='true' lat='1.71538937999' lon='25.58518536311'> <tag k='amenity' v='bank' /> </node> <node id='-103839' action='modify' visible='true' lat='1.71539065875' lon='25.58493077572'> <tag k='amenity' v='bank' /> </node> <node id='-103840' action='modify' visible='true' lat='1.71539185924' lon='25.58469177239'> <tag k='amenity' v='bank' /> </node> <node id='-103841' action='modify' visible='true' lat='1.71539299441' lon='25.58446577383'> <tag k='amenity' v='bank' /> </node> <node id='-103842' action='modify' visible='true' lat='1.71539434691' lon='25.58419650702'> <tag k='amenity' v='bank' /> </node> <node id='-103843' action='modify' visible='true' lat='1.71519185833' lon='25.58419548902'> <tag k='amenity' v='bank' /> </node> <node id='-103844' action='modify' visible='true' lat='1.71519044624' lon='25.58447661955'> <tag k='amenity' v='bank' /> </node> <node id='-103845' action='modify' visible='true' lat='1.71518933285' lon='25.58469828264'> <tag k='amenity' v='bank' /> </node> <node id='-103846' action='modify' visible='true' lat='1.7151878611' lon='25.58499128975'> <tag k='amenity' v='bank' /> </node> <node id='-103847' action='modify' visible='true' lat='1.71518681764' lon='25.58519903042'> <tag k='amenity' v='bank' /> </node> <node id='-103848' action='modify' visible='true' lat='1.71495597544' lon='25.58519786989'> <tag k='amenity' v='bank' /> </node> <node id='-103849' action='modify' visible='true' lat='1.71495690957' lon='25.58501189662'> <tag k='amenity' v='bank' /> </node> <node id='-103850' action='modify' visible='true' lat='1.71495815902' lon='25.58476314543'> <tag k='amenity' v='bank' /> </node> <node id='-103851' action='modify' visible='true' lat='1.71495948958' lon='25.58449824701'> <tag k='amenity' v='bank' /> </node> <node id='-103852' action='modify' visible='true' lat='1.71496097807' lon='25.58420190482'> <tag k='amenity' v='bank' /> </node> <node id='-103853' action='modify' visible='true' lat='1.714725499' lon='25.58420072097'> <tag k='amenity' v='bank' /> </node> <node id='-103854' action='modify' visible='true' lat='1.71472401058' lon='25.58449704793'> <tag k='amenity' v='bank' /> </node> <node id='-103855' action='modify' visible='true' lat='1.71472270722' lon='25.58475653214'> <tag k='amenity' v='bank' /> </node> <node id='-103856' action='modify' visible='true' lat='1.71472145231' lon='25.58500636974'> <tag k='amenity' v='bank' /> </node> <node id='-103857' action='modify' visible='true' lat='1.71472050572' lon='25.58519482522'> <tag k='amenity' v='bank' /> </node> <node id='-103858' action='modify' visible='true' lat='1.71449429028' lon='25.58519368794'> <tag k='amenity' v='bank' /> </node> <node id='-103859' action='modify' visible='true' lat='1.71449535319' lon='25.58498207449'> <tag k='amenity' v='bank' /> </node> <node id='-103860' action='modify' visible='true' lat='1.71449678681' lon='25.58469665924'> <tag k='amenity' v='bank' /> </node> <node id='-103861' action='modify' visible='true' lat='1.71449791582' lon='25.58447188574'> <tag k='amenity' v='bank' /> </node> <node id='-103862' action='modify' visible='true' lat='1.71449930991' lon='25.58419433872'> <tag k='amenity' v='bank' /> </node> <node id='-103863' action='modify' visible='true' lat='1.71426410786' lon='25.58419315627'> <tag k='amenity' v='bank' /> </node> <node id='-103864' action='modify' visible='true' lat='1.71426286065' lon='25.58444146126'> <tag k='amenity' v='bank' /> </node> <node id='-103865' action='modify' visible='true' lat='1.71426155738' lon='25.5847009256'> <tag k='amenity' v='bank' /> </node> <node id='-103866' action='modify' visible='true' lat='1.71426029689' lon='25.58495187407'> <tag k='amenity' v='bank' /> </node> <node id='-103867' action='modify' visible='true' lat='1.7142590397' lon='25.58520216635'> <tag k='amenity' v='bank' /> </node> <node id='-103868' action='modify' visible='true' lat='1.71397755468' lon='25.58520075121'> <tag k='amenity' v='bank' /> </node> <node id='-103869' action='modify' visible='true' lat='1.71397864853' lon='25.58498297835'> <tag k='amenity' v='bank' /> </node> <node id='-103870' action='modify' visible='true' lat='1.71398008215' lon='25.5846975631'> <tag k='amenity' v='bank' /> </node> <node id='-103871' action='modify' visible='true' lat='1.71398121116' lon='25.5844727896'> <tag k='amenity' v='bank' /> </node> <node id='-103872' action='modify' visible='true' lat='1.71398260525' lon='25.58419524259'> <tag k='amenity' v='bank' /> </node> <node id='-103873' action='modify' visible='true' lat='1.71374738957' lon='25.58419406006'> <tag k='amenity' v='bank' /> </node> <node id='-103874' action='modify' visible='true' lat='1.71374614236' lon='25.58444236507'> <tag k='amenity' v='bank' /> </node> <node id='-103875' action='modify' visible='true' lat='1.7137448391' lon='25.58470182941'> <tag k='amenity' v='bank' /> </node> <node id='-103876' action='modify' visible='true' lat='1.71374357861' lon='25.58495277788'> <tag k='amenity' v='bank' /> </node> <node id='-103877' action='modify' visible='true' lat='1.71374234539' lon='25.58519829753'> <tag k='amenity' v='bank' /> </node> <node id='-103878' action='modify' visible='true' lat='1.71343184236' lon='25.58519673651'> <tag k='amenity' v='bank' /> </node> <node id='-103879' action='modify' visible='true' lat='1.7134331773' lon='25.58493096547'> <tag k='amenity' v='bank' /> </node> <node id='-103880' action='modify' visible='true' lat='1.71343443779' lon='25.584680017'> <tag k='amenity' v='bank' /> </node> <node id='-103881' action='modify' visible='true' lat='1.71343574105' lon='25.58442055266'> <tag k='amenity' v='bank' /> </node> <node id='-103882' action='modify' visible='true' lat='1.71343699739' lon='25.58417043175'> <tag k='amenity' v='bank' /> </node> <node id='-103886' action='modify' visible='true' lat='1.7128751362' lon='25.58416760705'> <tag k='amenity' v='atm' /> </node> <node id='-103887' action='modify' visible='true' lat='1.71287625696' lon='25.58394447633'> <tag k='amenity' v='atm' /> </node> <node id='-103888' action='modify' visible='true' lat='1.71287723466' lon='25.58374982861'> <tag k='amenity' v='atm' /> </node> <node id='-103889' action='modify' visible='true' lat='1.71287827741' lon='25.5835422299'> <tag k='amenity' v='atm' /> </node> <node id='-103890' action='modify' visible='true' lat='1.71287951568' lon='25.58329570411'> <tag k='amenity' v='atm' /> </node> <node id='-103891' action='modify' visible='true' lat='1.71288053689' lon='25.58309239358'> <tag k='amenity' v='atm' /> </node> <node id='-103892' action='modify' visible='true' lat='1.71288134054' lon='25.58293239711'> <tag k='amenity' v='atm' /> </node> <node id='-103893' action='modify' visible='true' lat='1.7128823436' lon='25.58273270059'> <tag k='amenity' v='atm' /> </node> <node id='-103894' action='modify' visible='true' lat='1.71309721948' lon='25.58273378086'> <tag k='amenity' v='atm' /> </node> <node id='-103895' action='modify' visible='true' lat='1.71333931177' lon='25.58273499795'> <tag k='amenity' v='atm' /> </node> <node id='-103896' action='modify' visible='true' lat='1.71353815871' lon='25.58273599763'> <tag k='amenity' v='atm' /> </node> <node id='-103899' action='modify' visible='true' lat='1.7144763594' lon='25.58274071434'> <tag k='shop' v='copyshop' /> </node> <way id='-102203' action='modify' visible='true'> <nd ref='-103832' /> <nd ref='-103833' /> <nd ref='-103834' /> <nd ref='-103835' /> <nd ref='-103836' /> <nd ref='-103837' /> <nd ref='-103838' /> <nd ref='-103839' /> <nd ref='-103840' /> <nd ref='-103841' /> <nd ref='-103842' /> <nd ref='-103843' /> <nd ref='-103844' /> <nd ref='-103845' /> <nd ref='-103846' /> <nd ref='-103847' /> <nd ref='-103848' /> <nd ref='-103849' /> <nd ref='-103850' /> <nd ref='-103851' /> <nd ref='-103852' /> <nd ref='-103853' /> <nd ref='-103854' /> <nd ref='-103855' /> <nd ref='-103856' /> <nd ref='-103857' /> <nd ref='-103858' /> <nd ref='-103859' /> <nd ref='-103860' /> <nd ref='-103861' /> <nd ref='-103862' /> <nd ref='-103863' /> <nd ref='-103864' /> <nd ref='-103865' /> <nd ref='-103866' /> <nd ref='-103867' /> <nd ref='-103868' /> <nd ref='-103869' /> <nd ref='-103870' /> <nd ref='-103871' /> <nd ref='-103872' /> <nd ref='-103873' /> <nd ref='-103874' /> <nd ref='-103875' /> <nd ref='-103876' /> <nd ref='-103877' /> <nd ref='-103878' /> <nd ref='-103879' /> <nd ref='-103880' /> <nd ref='-103881' /> <nd ref='-103882' /> <nd ref='-103886' /> <nd ref='-103887' /> <nd ref='-103888' /> <nd ref='-103889' /> <nd ref='-103890' /> <nd ref='-103891' /> <nd ref='-103892' /> <nd ref='-103893' /> <nd ref='-103894' /> <nd ref='-103895' /> <nd ref='-103896' /> <nd ref='-103396' /> <nd ref='-103404' /> <nd ref='-103899' /> <tag k='highway' v='residential' /> <tag k='name' v='Main Street' /> </way> </osm>