-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: generate supported languages (#1544)
Signed-off-by: Ian Lewis <[email protected]>
- Loading branch information
Ian Lewis
authored
Aug 24, 2024
1 parent
3473c73
commit a7c4472
Showing
10 changed files
with
837 additions
and
667 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// Copyright 2024 Google LLC | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package scanner | ||
|
||
// EscapeFunc is function that checks for escaped string characters. | ||
type EscapeFunc func(s *CommentScanner, stringEnd []rune) ([]rune, error) | ||
|
||
// NoEscape is a no-op. | ||
func NoEscape(_ *CommentScanner, _ []rune) ([]rune, error) { | ||
return nil, nil | ||
} | ||
|
||
// CharEscape checks for the given escape character in the scanner. | ||
func CharEscape(c rune) EscapeFunc { | ||
return func(s *CommentScanner, stringEnd []rune) ([]rune, error) { | ||
b := append([]rune{c}, stringEnd...) | ||
eq, err := s.peekEqual(b) | ||
if err != nil { | ||
return nil, err | ||
} | ||
if eq { | ||
return b, nil | ||
} | ||
return nil, nil | ||
} | ||
} | ||
|
||
// DoubleEscape checks for a repeated string ending character in the string. | ||
func DoubleEscape(s *CommentScanner, stringEnd []rune) ([]rune, error) { | ||
b := append([]rune{}, stringEnd...) | ||
b = append(b, stringEnd...) | ||
eq, err := s.peekEqual(b) | ||
if err != nil { | ||
return nil, err | ||
} | ||
if eq { | ||
return b, nil | ||
} | ||
return nil, nil | ||
} |
Oops, something went wrong.