diff options
Diffstat (limited to 'compiler/parser.nim')
-rw-r--r-- | compiler/parser.nim | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/compiler/parser.nim b/compiler/parser.nim index c4681a5cd..f22177ac1 100644 --- a/compiler/parser.nim +++ b/compiler/parser.nim @@ -804,20 +804,24 @@ proc parsePragma(p: var TParser): PNode = else: parMessage(p, errTokenExpected, ".}") dec p.inPragma -proc identVis(p: var TParser): PNode = +proc identVis(p: var TParser; allowDot=false): PNode = #| identVis = symbol opr? # postfix position + #| identVisDot = symbol '.' optInd symbol opr? var a = parseSymbol(p) if p.tok.tokType == tkOpr: result = newNodeP(nkPostfix, p) addSon(result, newIdentNodeP(p.tok.ident, p)) addSon(result, a) getTok(p) + elif p.tok.tokType == tkDot and allowDot: + result = dotExpr(p, a) else: result = a -proc identWithPragma(p: var TParser): PNode = +proc identWithPragma(p: var TParser; allowDot=false): PNode = #| identWithPragma = identVis pragma? - var a = identVis(p) + #| identWithPragmaDot = identVisDot pragma? + var a = identVis(p, allowDot) if p.tok.tokType == tkCurlyDotLe: result = newNodeP(nkPragmaExpr, p) addSon(result, a) @@ -1803,10 +1807,11 @@ proc parseTypeClass(p: var TParser): PNode = addSon(result, parseStmt(p)) proc parseTypeDef(p: var TParser): PNode = - #| typeDef = identWithPragma genericParamList? '=' optInd typeDefAux + #| + #| typeDef = identWithPragmaDot genericParamList? '=' optInd typeDefAux #| indAndComment? result = newNodeP(nkTypeDef, p) - addSon(result, identWithPragma(p)) + addSon(result, identWithPragma(p, allowDot=true)) if p.tok.tokType == tkBracketLe and p.validInd: addSon(result, parseGenericParamList(p)) else: @@ -1903,7 +1908,7 @@ proc complexOrSimpleStmt(p: var TParser): PNode = #| | 'converter' routine #| | 'type' section(typeDef) #| | 'const' section(constant) - #| | ('let' | 'var') section(variable) + #| | ('let' | 'var' | 'using') section(variable) #| | bindStmt | mixinStmt) #| / simpleStmt case p.tok.tokType @@ -1940,7 +1945,7 @@ proc complexOrSimpleStmt(p: var TParser): PNode = of tkVar: result = parseSection(p, nkVarSection, parseVariable) of tkBind: result = parseBind(p, nkBindStmt) of tkMixin: result = parseBind(p, nkMixinStmt) - of tkUsing: result = parseBind(p, nkUsingStmt) + of tkUsing: result = parseSection(p, nkUsingStmt, parseVariable) else: result = simpleStmt(p) proc parseStmt(p: var TParser): PNode = |