Skip to content

Syntax variation "alpha" #2

Description

@chrivers

(This is an attempt at finalizing the syntax. Going to pull this out of issue #1, so it's easier to follow)

I've made an attempt at cleaning up the syntax for the STF files. Take a look here:

https://github.com/chrivers/isolinear-chips/tree/syntax-varation-alpha

(the compiler doesn't handle it yet.. I don't want to spend time updating it, until we agree somewhat on the syntax)

Here are the changes:

  1. Namespaces are a thing now! Every field in an STF project can now be references with a unique name.
  2. File names are used now! Everything from "enums.stf" will be in the "enums::" namespace.
  3. Equals -> Colon. There's only colon now
  4. Any node in the tree can be references. To make the parser simpler, only absolute references are allow for now.
  5. The reference rules are simple: Any identifier that contains "::" is an absolute reference, and will be validated at compile-time. Everything else is a primitive type name.
  6. Types are also fairly simple. A type (the right-hand side of any section), can be either A) a literal value (ints, typically), B) an identifier (reference or not), or C) type with parameter (sizedarray<foo, 8>)
  7. Sections should be able to have named values associated with them. Here's a couple of ideas for syntax:
A:
object Creature(bitmask=3)
    ....
B:
!bitmask=3
object Creature
    ....
C:
object Creature
    !bitmask = 3

What do you think? This, or something else?

Here are some concrete changes for isolinear chips:

  1. "ClientPacket" and "ServerPacket" no longer exist - every packet type is now a struct.
  2. The enum<MainScreenView, u32> syntax is gone! Because we can make references, we now have the simpler form: enums::MainScreenView<u32>. "enums" in this context means the enums file. This can be checked for validity by the compiler.
  3. This change also helps the other types: ships: sizedarray<structs::Ship, 8>. This, of course, referes to the "structs" file.

In general, I think the code is quite a lot easier to read now. It should also be significantly easier to parse and run templates on, since there are many, many fewer special cases. Death to non-generic sections!

ping @NoseyNick @mrfishie - thoughts? ;-)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions