Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ghostscope-compiler/src/script/grammar.pest
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ address_of = { "&" ~ ( "(" ~ expr ~ ")" | complex_variable | identifier ) }
add_op = { "+" | "-" }
mul_op = { "*" | "/" }

identifier = @{ ASCII_ALPHA ~ (ASCII_ALPHANUMERIC | "_")* }
identifier = @{ (ASCII_ALPHA | "_") ~ (ASCII_ALPHANUMERIC | "_")* }
// Integer literals
int = @{ ASCII_DIGIT+ }
hex_int = @{ "0x" ~ ASCII_HEX_DIGIT+ }
Expand Down
17 changes: 17 additions & 0 deletions ghostscope-compiler/src/script/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2058,6 +2058,23 @@ trace foo {
assert!(parse(s5).is_ok());
}

#[test]
fn parse_identifiers_can_start_with_underscore() {
let function = r#"trace __UpdateTicketInformation { print "OK"; }"#;
assert!(parse(function).is_ok());

let wildcard = r#"trace __builtin_* { print "W"; }"#;
assert!(parse(wildcard).is_ok());

let script = r#"
trace _start {
let _ticket = __dwarf_value;
print _ticket;
}
"#;
assert!(parse(script).is_ok());
}

#[test]
fn parse_module_hex_address_overflow_should_error() {
// Address exceeds u64 (17 hex digits) -> parse error, not 0 fallback
Expand Down
Loading