User:Clipka/Syntax
Random ideas for an overhauled way of representing syntax
This is what we currently have:
ARRAY_DECLARATION: #declare IDENTIFIER = array[ mixed ][ INT ][[ INT ]]..[ARRAY_INITIALIZER] | #local IDENTIFIER = array[ mixed ][ INT ][[ INT ]]..[ARRAY_INITIALIZER] ...
If we abandong pre-formatted text, we can use formatting to our advantage. For example, the following uses a definition list in a <div>
tag (using "Note" here but we should of course use a dedicated style class, so that we can fine-tune the style), and %&t;code>
to mark literal text:
- ARRAY_DECLARATION
#declare
IDENTIFIER= array
[mixed
][
INT]
[[
INT]
].. [ ARRAY_INITIALIZER ] |#local
IDENTIFIER= array
[mixed
][
INT]
[[
INT]
].. [ ARRAY_INITIALIZER ]- ...
Or, to make it easier to write, we could simply use bold to indicate literal text:
- ARRAY_DECLARATION
- #declare IDENTIFIER = array [ mixed ] [ INT ] [ [ INT ] ]... [ ARRAY_INITIALIZER ] |
- #local IDENTIFIER = array [ mixed ] [ INT ] [ [ INT ] ]... [ ARRAY_INITIALIZER ]
- ...
As a final example, here's using bold for literal text, italics for syntax non-terminals, and normal for everything else, while also using subscript "opt" instead of square brackets to indicate optional stuff, and subscript "opt..." to indicate optional stuff that can appear multiple times:
- ARRAY_DECLARATION
- #declare IDENTIFIER = array mixedopt [ INT ] [ INT ]opt... ARRAY_INITIALIZERopt |
- #local IDENTIFIER = array mixedopt [ INT ] [ INT ]opt... ARRAY_INITIALIZERopt
- ...
For simplicity of writing, we might use style sheets to "italicize" everything but the non-terminals, rather than use markup to explicitly italicize pretty much everything individually.