From 2f9d0881c9ec44eefdd9b1173c7f0555cff4e2f1 Mon Sep 17 00:00:00 2001 From: FerroO2000 <30318301+FerroO2000@users.noreply.github.com> Date: Tue, 16 Apr 2024 18:21:16 +0200 Subject: [PATCH] removed some tests --- adapters_test.go | 19 ++++++------------- dbc/ast.go | 10 ++-------- dbc/parser.go | 30 ++++-------------------------- 3 files changed, 12 insertions(+), 47 deletions(-) diff --git a/adapters_test.go b/adapters_test.go index fb93694..3fc6f90 100644 --- a/adapters_test.go +++ b/adapters_test.go @@ -1,17 +1,10 @@ package acmelib -import ( - "os" - "testing" +// func Test_LoadDBC(t *testing.T) { +// assert := assert.New(t) - "github.com/stretchr/testify/assert" -) +// net, err := LoadDBC("test_network", "./testdata/mcb.dbc") +// assert.NoError(err) -func Test_LoadDBC(t *testing.T) { - assert := assert.New(t) - - net, err := LoadDBC("test_network", "./testdata/mcb.dbc") - assert.NoError(err) - - assert.NoError(os.WriteFile("./testdata_res/mcb.txt", []byte(net.String()), 0644)) -} +// assert.NoError(os.WriteFile("./testdata_res/mcb.txt", []byte(net.String()), 0644)) +// } diff --git a/dbc/ast.go b/dbc/ast.go index d419855..91154f9 100644 --- a/dbc/ast.go +++ b/dbc/ast.go @@ -13,17 +13,11 @@ func GetNewSymbols() []string { return newSymbolsValues } -// LocationPos specifies the line and the column in the file. -type LocationPos struct { - Line int - Col int -} - // Location is the position in the DBC file of an AST entity. type Location struct { Filename string - StartPos *LocationPos - EndPos *LocationPos + Line int + Col int } // File definition: diff --git a/dbc/parser.go b/dbc/parser.go index 7789b0e..dd3d931 100644 --- a/dbc/parser.go +++ b/dbc/parser.go @@ -15,8 +15,7 @@ type Parser struct { usePrev bool currToken *token - filename string - locPosStack []*LocationPos + filename string foundVer bool foundNewSym bool @@ -31,8 +30,7 @@ func NewParser(filename string, file []byte) *Parser { usePrev: false, - filename: filename, - locPosStack: []*LocationPos{}, + filename: filename, foundVer: false, foundNewSym: false, @@ -91,30 +89,11 @@ func (p *Parser) unscan() { p.usePrev = true } -func (p *Parser) pushLocationPos() { - p.locPosStack = append(p.locPosStack, &LocationPos{ - Line: p.currToken.line, - Col: p.currToken.col, - }) -} - -func (p *Parser) popLocationPos() *LocationPos { - if len(p.locPosStack) == 0 { - return nil - } - pos := p.locPosStack[len(p.locPosStack)-1] - p.locPosStack = p.locPosStack[:len(p.locPosStack)-1] - return pos -} - func (p *Parser) getLocation() *Location { return &Location{ Filename: p.filename, - StartPos: p.popLocationPos(), - EndPos: &LocationPos{ - Line: p.currToken.line, - Col: p.currToken.col, - }, + Line: p.currToken.line, + Col: p.currToken.col, } } @@ -143,7 +122,6 @@ func (p *Parser) Parse() (*File, error) { } t := p.scan() - for !t.isEOF() { switch t.kind { case tokenError: