diff options
| -rw-r--r-- | nimterop/grammar.nim | 26 | ||||
| -rw-r--r-- | toast.nim | 4 |
2 files changed, 26 insertions, 4 deletions
diff --git a/nimterop/grammar.nim b/nimterop/grammar.nim index a8d8eed..c72e29b 100644 --- a/nimterop/grammar.nim +++ b/nimterop/grammar.nim @@ -87,8 +87,14 @@ proc initGrammar() = let ftyp = gStateRT.data[i].val.getIdentifier() fname = gStateRT.data[i+1].val.getIdentifier() - gStateRT.typeStr &= &" {fname}*: {ftyp}\n" - i += 2 + if i+2 < gStateRT.data.len-fend and gStateRT.data[i+2].name == "identifier": + let + flen = gStateRT.data[i+2].val.getIdentifier() + gStateRT.typeStr &= &" {fname}*: array[{flen}, {ftyp}]\n" + i += 3 + else: + gStateRT.typeStr &= &" {fname}*: {ftyp}\n" + i += 2 # struct X {} gStateRT.grammar.add((""" @@ -105,7 +111,15 @@ proc initGrammar() = ) (field_identifier?) (pointer_declarator? + (field_identifier?) + (array_declarator? + (field_identifier) + (identifier) + ) + ) + (array_declarator? (field_identifier) + (identifier) ) ) ) @@ -131,7 +145,15 @@ proc initGrammar() = ) (field_identifier?) (pointer_declarator? + (field_identifier?) + (array_declarator? + (field_identifier) + (identifier) + ) + ) + (array_declarator? (field_identifier) + (identifier) ) ) ) @@ -134,10 +134,10 @@ when isMainModule: dispatch(main, help = { "past": "print AST output", "mode": "language; see CompileMode", # TODO: auto-generate valid choices - "pnim": "run preprocessor on header", + "pnim": "print Nim output", "defines": "definitions to pass to preprocessor", "includeDirs": "include directory to pass to preprocessor", - "preprocess": "print Nim output", + "preprocess": "run preprocessor on header", "source" : "C/C++ source/header", }, short = { "past": 'a', |
