Skip to content
Snippets Groups Projects
Commit 5df7c665 authored by Suraj Malhotra's avatar Suraj Malhotra Committed by CQ bot account: commit-bot@chromium.org
Browse files

[banjo] Add support for string constants.

We were parsing string constants as identifiers instead of strings.

TODO: Add test with string constant.
Change-Id: Ia493c4afbbf87eebe2447e3dc0aa8783d6baa9f3
parent 0888ecc5
No related branches found
No related tags found
No related merge requests found
......@@ -787,7 +787,7 @@ impl BanjoAst {
Rule::ident => {
name = String::from(inner_pair.as_str());
}
Rule::identifier_type | Rule::primitive_type => {
Rule::identifier_type | Rule::string_type | Rule::primitive_type => {
ty = Ty::from_pair(ns, &inner_pair)?;
}
Rule::constant => {
......
......@@ -22,7 +22,7 @@ declaration_list = _{ ( declaration ~ ";" )* }
declaration = _{ const_declaration | enum_declaration | union_declaration | struct_declaration | interface_declaration }
const_declaration = { attributes ~ "const" ~ ( primitive_type | identifier_type ) ~ ident ~ "=" ~ constant }
const_declaration = { attributes ~ "const" ~ ( primitive_type | string_type | identifier_type ) ~ ident ~ "=" ~ constant }
doc_comment = ${ "///" ~ (" " | SYMBOL | PUNCTUATION | ASCII_ALPHANUMERIC)* ~ "\n"}
doc_comment_block = _{ (doc_comment)* }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment