Java-Gaming.org Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (767)
Games in Android Showcase (230)
games submitted by our members
Games in WIP (854)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: 1 [2]
  ignore  |  Print  
  TreeML markup language  (Read 37714 times)
0 Members and 1 Guest are viewing this topic.
Offline ags1

JGO Kernel


Medals: 367
Projects: 7


Make code not war!


« Reply #30 - Posted 2016-05-30 11:06:53 »

Cleaned up the syntax for recursive definitions slightly. I hope to add support for enums and recursive definitions shortly to the parser.

The parser does now read data types from the schema if available, which is important as I do not have an explicit list syntax. A single item list is parsed by default as a non-list. I probably need to change the syntax from:

1  
2  
-    oldListField : singleValue
+    newSyntaxListField : [singleValue]

Offline KaiHH

JGO Kernel


Medals: 595



« Reply #31 - Posted 2016-05-30 13:00:16 »

I have also been thinking about adding an abstract parser/DOM interface to keep the parser DOM/datatype-agnostic and therefore to let the client decide how it wants to parse the syntax elements into a document object model.

Something like this:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
interface ParserInterface {
  /**
   * Called whenever a new object is parsed.
   *
   * The client returns an arbitrary Object identifying the newly parsed object.
   * This will then be used as the 'owner' for a parsed value for {@link #onValue}, a parsed property
   * with {@link onProperty} or as the 'parent' in a subsequent invocation of {@link #onNewObject}.
   */

  Object onNewObject(Object parent);

  /**
   * Called whenever a new value in the value list of 'owner' was parsed.
   */

  void onValue(Object owner, Object value);

  /**
   * Called whenever a property was parsed belonging to 'owner'.
   */

  void onProperty(Object owner, String name, Object value);
}


The 'owner' and 'parent' Objects could be anything the client wants them to be. They just need to have identity for the client to associate properties/values with them. It could be a simple java.util.Map or something different. But the thing being: The parser need not care what it is concretely as it only communicates with the client via that interface methods.
Offline Riven
Administrator

« JGO Overlord »


Medals: 1356
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #32 - Posted 2016-05-30 16:03:52 »

Yes, parsers using callbacks are a nice way to separate parsing logic from your data-model, even if you only have 1 interface implementation.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings!
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline ags1

JGO Kernel


Medals: 367
Projects: 7


Make code not war!


« Reply #33 - Posted 2016-05-30 20:31:44 »

This is kind of like SAX for TreeML... Smiley

However, I need to curb my enthusiasm and not implement more features than I strictly need right now.

One thing I would like to have (that you don't find in schema languages generally) is the ability to define enums as a query on another document. For example, a career lists a number of skills, mapped to the maximum progression possible for that skill in that career. I could define an enum in the career-schema.treeml file defining the expected skills, but that is fragile, too much work, and beyond my mental ability to keep straight. Instead I would like to define the enum as a reference to the careers.treeml file:

1  
    enum : flow, skills, args, "skills.treeml", "skill/id"


Then my career schema is always in synch with the skills list! I'd apply the same thing to the list of career possessions, etc. The above example is not quite well formed as the last two arguments in the value list are not tokens. Also the "filename" should be considered a logical resource name and not a system dependent file name.

Offline KaiHH

JGO Kernel


Medals: 595



« Reply #34 - Posted 2016-05-30 20:34:25 »

I hear XPath for TreeML coming... Smiley
Offline ags1

JGO Kernel


Medals: 367
Projects: 7


Make code not war!


« Reply #35 - Posted 2016-05-30 20:39:20 »

All this effort just to avoid dem angle brackets.

Offline ags1

JGO Kernel


Medals: 367
Projects: 7


Make code not war!


« Reply #36 - Posted 2016-06-24 23:46:34 »

Too upset after the political turmoil in Europe to do anything heavy, so I just worked on adding schemas to all my TreeML resource files. I also came up with a neat way to specify dependencies between files - rather than baking it into the schema language, which was complicated enough, I will just define a separate simple format to specify the interdependencies. something like:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
dependency :
   id : itemsConsumedByRecipe
   referencesFrom :
      resource : "resource/encyclopedia/recipes.treeml"
      path : recipe, itemsToConsume, token, nodeName
   referencesTo :
      resource : "resource/encyclopedia/items.treeml"
      path : item, id, nodeValue
dependency :
   id : toolsForRecipe
   referencesFrom :
      resource : "resource/encyclopedia/recipes.treeml"
      path : recipe, tools, token, nodeName
   referencesTo :
      resource : "resource/encyclopedia/items.treeml"
      path : item, id, nodeValue
...


Tomorrow I will implement a little dependency checker that runs off this; it should be pretty simple to write. Once it is running I will have a lot of broken references to fix because I was less disciplined about adding references lately because I knew automated dependency checking was in the works Smiley

Offline ags1

JGO Kernel


Medals: 367
Projects: 7


Make code not war!


« Reply #37 - Posted 2016-07-03 22:26:57 »

The dependency checker is up and running and working a treat! I specify a path within a "from" schema and a path within a "to" schema and the links for all documents matching those schemas are validated during document load. It's a huge productivity boost as i can just define the dependencies one by one and then walk through the errors and add the missing items, creatures etc.

This is really starting to take shape Smiley

Checking dependency: adultForCreature
Checking dependency: partsOfCreature
Checking dependency: productsOfCreature
Checking dependency: skillsOfCreature
Checking dependency: attacksOfCreature
Checking dependency: skillsRequiredByItem
Checking dependency: itemsConsumedByRecipe
Checking dependency: toolsForRecipe
Checking dependency: productsForRecipe
Checking dependency: skillsForRecipe

Offline ags1

JGO Kernel


Medals: 367
Projects: 7


Make code not war!


« Reply #38 - Posted 2016-07-05 20:19:56 »

I'm sailing close to post-locking this thread, but anyway. I just realized today with the dependency definition format, I can simplify the schema language because I never need to define enums in schemas. For example, instead of defining an enum in a schema for wealth categories (impoverished, poor, prosperous...), I can define a dependency on file where I define the allowed values. This has advantages because I can now give numerical attributes to the enum values, add description texts etc.

Offline Hydroque

JGO Coder


Medals: 25
Exp: 5 years


I'm always inspiring a good time.


« Reply #39 - Posted 2016-07-06 04:25:09 »

To go on with the discussion about tabs, spaces, and indentation... nobody mentioned Python.

One pro to making tabs scope rather than {}'s can be found in a comparison between Python and JSON tab formatting. It is the same thing writing a string like...

"example" : {
   "example" : {
      
   }
}

and something like this

"example":
   "example":
      

So I think the way he has his scoping set up is really the best way. At least it isn't like a switch in java where in order to have a scope-per-case, you need to do

case ENUM: {

}
break;

You think I haven't been monitoring the chat? http://pastebin.java-gaming.org/c47d35366491fHere is a compilation <3
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline ags1

JGO Kernel


Medals: 367
Projects: 7


Make code not war!


« Reply #40 - Posted 2016-07-06 20:32:18 »

I'd rather not revisit the tabs v spaces v curlies war. Smiley It's an example of how people have a tendency to go to war over trivial things. To me it's a bit like arguing XML is broken because it uses angle brackets instead of square brackets, which are obviously better because you don't have to press shift for square brackets. What was the W3C thinking?

Offline Hydroque

JGO Coder


Medals: 25
Exp: 5 years


I'm always inspiring a good time.


« Reply #41 - Posted 2016-07-07 23:14:58 »

Well that example is a little off. Tabs verse Curlies is a scenario-specific thing imo.
Tabs work well here because its tightly packed and ordered.
Curlies don't work well here because the space the user uses doesn't need to be maleable, for example using enter to create constructors that stay on the page rather than scrolling.

There is no reason to start a debate.

I rather use square or curly brackets over <> any day, thats why I made a cute little html editor to do so.

You think I haven't been monitoring the chat? http://pastebin.java-gaming.org/c47d35366491fHere is a compilation <3
Offline Ecumene

JGO Kernel


Medals: 197
Projects: 4
Exp: 8 years


I did not hit her! I did not!


« Reply #42 - Posted 2016-07-08 05:36:33 »

I rather use square or curly brackets over <> any day, thats why I made a cute little html editor to do so.

Let's all reflect on how great nested braces are



So great.
(Don't do backend, kids)

Offline Hydroque

JGO Coder


Medals: 25
Exp: 5 years


I'm always inspiring a good time.


« Reply #43 - Posted 2016-07-08 07:04:20 »

Haha. Yeah. Thats a procedural approach. When I was coding in Lua for Roblox, I'd eventually find myself having these long lists of ifs and closures. Although, the way I work now is more "if not this occasion, break/return like it would" which quickly fixed that massive amount of text going on. It stays in line.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
public static final int returnsStuff() {

int result;

if(1 + 1 == 3)
return -1;

result = 5;

if(new Integer(2+2).hashCode() == 4)
return -1;

result++;

// etc..

return result;
}


Versus

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
public static final int returnsStuff() {

int result;

if(1 + 1 == 2) {
result = 5;
if(2 + 2 == 4) {
result++;
// etc..

}

}

return result;
}


(forgive my laziness of not doing this in notepad++ or anything)
They are two VERY different concepts and they both have their purpose. If you don't need the scope, don't retain it.

Oh and BTW I got hit up on for saying procedural a lot.
This is procedural programming

You think I haven't been monitoring the chat? http://pastebin.java-gaming.org/c47d35366491fHere is a compilation <3
Offline ags1

JGO Kernel


Medals: 367
Projects: 7


Make code not war!


« Reply #44 - Posted 2016-07-12 10:56:18 »

I can knock out a TreeML schema in 5 minutes, which is QUITE a lot faster than XSD or RelaxNG or DTD Smiley

Offline ags1

JGO Kernel


Medals: 367
Projects: 7


Make code not war!


« Reply #45 - Posted 2018-02-21 12:22:05 »

I updated the Gist with a hacky early version of support for curly-structured files. In the interests of being arbitrarily strict, the curly character must be the last non-whitespace character on a line in order to be evaluated.

Pages: 1 [2]
  ignore  |  Print  
 
 

 
EgonOlsen (1303 views)
2018-06-10 19:43:48

EgonOlsen (1161 views)
2018-06-10 19:43:44

EgonOlsen (900 views)
2018-06-10 19:43:20

DesertCoockie (1301 views)
2018-05-13 18:23:11

nelsongames (1106 views)
2018-04-24 18:15:36

nelsongames (1338 views)
2018-04-24 18:14:32

ivj94 (2079 views)
2018-03-24 14:47:39

ivj94 (1231 views)
2018-03-24 14:46:31

ivj94 (2213 views)
2018-03-24 14:43:53

Solater (798 views)
2018-03-17 05:04:08
Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08

Deployment and Packaging
by gouessej
2018-08-22 08:03:45

Deployment and Packaging
by philfrei
2018-08-20 02:33:38

Deployment and Packaging
by philfrei
2018-08-20 02:29:55

Deployment and Packaging
by philfrei
2018-08-19 23:56:20

Deployment and Packaging
by philfrei
2018-08-19 23:54:46
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!