Skip to content

Commit

Permalink
Add support for byte type
Browse files Browse the repository at this point in the history
  • Loading branch information
ExcaliburZero committed Nov 5, 2023
1 parent 281c8c8 commit 0dd61f3
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/server/keyword_docs/byte.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
BYTE

8 bit, 0 to 0xff
4 changes: 4 additions & 0 deletions src/server/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,10 @@ pub fn get_keyword_docs() -> HashMap<String, String> {
"getvarchr".to_string(),
include_str!("keyword_docs/getvarchr.txt").to_string(),
),
(
"byte".to_string(),
include_str!("keyword_docs/byte.txt").to_string(),
),
]
.iter()
.cloned()
Expand Down
2 changes: 2 additions & 0 deletions tree-sitter-quickbms/grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ module.exports = grammar({
$.string,
$.binary,
$.unicode,
$.byte,
),
_endian_type: $ => choice(
$.little,
Expand Down Expand Up @@ -304,6 +305,7 @@ module.exports = grammar({
string: $ => /[Ss][Tt][Rr][Ii][Nn][Gg]/,
binary: $ => /[Bb][Ii][Nn][Aa][Rr][Yy]/,
unicode: $ => /[Uu][Nn][Ii][Cc][Oo][Dd][Ee]/,
byte: $ => /[Bb][Yy][Tt][Ee]/,
endian: $ => /[Ee][Nn][Dd][Ii][Aa][Nn]/,
little: $ => /[Ll][Ii][Tt][Tt][Ll][Ee]/,
intel: $ => /[Ii][Nn][Tt][Ee][Ll]/,
Expand Down
11 changes: 10 additions & 1 deletion tree-sitter-quickbms/test/corpus/getvarchr.bms
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ Next i
GetVarChr TMP MEMORY_FILE i # hello
string NAME - 4

GetVarChr BYTESWAP MEMORY_FILE x byte

--------------------------------------------------------------------------------

(source_file
Expand Down Expand Up @@ -47,4 +49,11 @@ string NAME - 4
(string)
(identifier)
(operation)
(integer_literal)))
(integer_literal))
(getvarchr_statement
(getvarchr)
(identifier)
(identifier)
(identifier)
(type
(byte))))

0 comments on commit 0dd61f3

Please sign in to comment.