Moved const and extern identifiers to the left
This commit is contained in:
@ -2,12 +2,10 @@ package errors
|
||||
|
||||
var (
|
||||
EmptySwitch = &Base{"Empty switch"}
|
||||
ExpectedConstName = &Base{"Expected a name for the const group"}
|
||||
InvalidDefinition = &Base{"Invalid definition"}
|
||||
ExpectedFunctionDefinition = &Base{"Expected function definition"}
|
||||
ExpectedIfBeforeElse = &Base{"Expected an 'if' block before 'else'"}
|
||||
ExpectedPackageName = &Base{"Expected package name"}
|
||||
ExpectedDLLName = &Base{"Expected DLL name"}
|
||||
InvalidNumber = &Base{"Invalid number"}
|
||||
InvalidCondition = &Base{"Invalid condition"}
|
||||
InvalidExpression = &Base{"Invalid expression"}
|
||||
|
@ -9,14 +9,8 @@ import (
|
||||
|
||||
// scanConst scans a block of constants.
|
||||
func (s *Scanner) scanConst(file *fs.File, tokens token.List, i int) (int, error) {
|
||||
i++
|
||||
|
||||
if tokens[i].Kind != token.Identifier {
|
||||
return i, errors.New(errors.ExpectedConstName, file, tokens[i].Position)
|
||||
}
|
||||
|
||||
groupName := tokens[i].Text(file.Bytes)
|
||||
i++
|
||||
i += 2
|
||||
|
||||
if tokens[i].Kind != token.BlockStart {
|
||||
return i, errors.New(errors.MissingBlockStart, file, tokens[i].Position)
|
||||
|
@ -8,14 +8,8 @@ import (
|
||||
|
||||
// scanExtern scans a block of external function declarations.
|
||||
func (s *Scanner) scanExtern(file *fs.File, tokens token.List, i int) (int, error) {
|
||||
i++
|
||||
|
||||
if tokens[i].Kind != token.Identifier {
|
||||
return i, errors.New(errors.ExpectedDLLName, file, tokens[i].Position)
|
||||
}
|
||||
|
||||
dllName := tokens[i].Text(file.Bytes)
|
||||
i++
|
||||
i += 2
|
||||
|
||||
if tokens[i].Kind != token.BlockStart {
|
||||
return i, errors.New(errors.MissingBlockStart, file, tokens[i].Position)
|
||||
|
@ -43,6 +43,10 @@ func (s *Scanner) scanFile(path string, pkg string) error {
|
||||
i, err = s.scanFunction(file, tokens, i)
|
||||
case token.BlockStart:
|
||||
i, err = s.scanStruct(file, tokens, i)
|
||||
case token.Extern:
|
||||
i, err = s.scanExtern(file, tokens, i)
|
||||
case token.Const:
|
||||
i, err = s.scanConst(file, tokens, i)
|
||||
case token.GroupEnd:
|
||||
return errors.New(errors.MissingGroupStart, file, next.Position)
|
||||
case token.BlockEnd:
|
||||
@ -54,10 +58,6 @@ func (s *Scanner) scanFile(path string, pkg string) error {
|
||||
}
|
||||
case token.Import:
|
||||
i, err = s.scanImport(file, tokens, i)
|
||||
case token.Extern:
|
||||
i, err = s.scanExtern(file, tokens, i)
|
||||
case token.Const:
|
||||
i, err = s.scanConst(file, tokens, i)
|
||||
case token.EOF:
|
||||
return nil
|
||||
case token.Invalid:
|
||||
|
Reference in New Issue
Block a user