Skip to content

Commit

Permalink
Remove unused function createThin()
Browse files Browse the repository at this point in the history
Remove unused function createThin() from common_token_factory.go, CommonTokenFactory.py, CommonTokenFactory.js.

The unexported function 'antlr.createThin' is never used but has a potential bug. Using nil constant at common_token_factory.go:52, it is passed as 1st parameter in call to function 'antlr.NewCommonToken' at common_token_factory.go:52, where it is dereferenced at token.go:140.

---------

Signed-off-by: alexeyerm <63284266+alexeyerm@users.noreply.github.com>
  • Loading branch information
alexeyerm authored Sep 5, 2024
1 parent 811b7fd commit 6e93975
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 18 deletions.
7 changes: 0 additions & 7 deletions runtime/Go/antlr/v4/common_token_factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,3 @@ func (c *CommonTokenFactory) Create(source *TokenSourceCharStreamPair, ttype int

return t
}

func (c *CommonTokenFactory) createThin(ttype int, text string) Token {
t := NewCommonToken(nil, ttype, TokenDefaultChannel, -1, -1)
t.SetText(text)

return t
}
6 changes: 0 additions & 6 deletions runtime/JavaScript/src/antlr4/CommonTokenFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,6 @@ export default class CommonTokenFactory extends TokenFactory {
}
return t;
}

createThin(type, text) {
const t = new CommonToken(null, type);
t.text = text;
return t;
}
}

/**
Expand Down
5 changes: 0 additions & 5 deletions runtime/Python3/src/antlr4/CommonTokenFactory.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,4 @@ def create(self, source, type:int, text:str, channel:int, start:int, stop:int, l
t.text = source[1].getText(start,stop)
return t

def createThin(self, type:int, text:str):
t = CommonToken(type=type)
t.text = text
return t

CommonTokenFactory.DEFAULT = CommonTokenFactory()

0 comments on commit 6e93975

Please sign in to comment.