Skip to content

Commit

Permalink
Parsing docstrings.
Browse files Browse the repository at this point in the history
  • Loading branch information
emilyaherbert committed Sep 24, 2021
1 parent 9f7148c commit fddca66
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions core_lang/src/hll.pest
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ while_keyword = {"while"}
match_keyword = {"match"}
mut_keyword = {"mut"}
assign = _{"="}
docstring_open = {"///"}
line_comment_open = {"//"}
block_comment_open = {"/*"}
block_comment_close = {"*/"}
Expand Down Expand Up @@ -170,16 +171,18 @@ opcode = {ident}
control_flow = _{while_loop|return_statement}

// boilerplate
WHITESPACE = _{(" "|"\t"|"\r"|"\n")+}
COMMENT = _{block_comment|line_comment}
block_comment = @{block_comment_open ~ (!block_comment_close ~ ANY)* ~ block_comment_close}
line_comment = @{line_comment_open ~ (!("\r"|"\n") ~ ANY)*}
char = @{
WHITESPACE = _{(" "|"\t"|"\r"|"\n")+}
COMMENT = _{block_comment|line_comment}
DOCSTRING = _{docstring_comment}
docstring_comment = @{docstring_open ~ (!("\r"|"\n") ~ ANY)*}
block_comment = @{block_comment_open ~ (!block_comment_close ~ ANY)* ~ block_comment_close}
line_comment = @{line_comment_open ~ (!"/") ~ (!("\r"|"\n") ~ ANY)*}
char = @{
!("\""|"\\") ~ ANY
| "\\" ~ ("\""|"\\"|"/"|"b"|"f"|"n"|"r"|"t")
| "\\" ~ ("u" ~ ASCII_HEX_DIGIT{4})
}
unit = {"(" ~ ")"}
ident = @{ ASCII_ALPHA ~ (ASCII_ALPHANUMERIC|"_")* }
reserved_words = @{(true_keyword|false_keyword|asm_keyword|ref_keyword|deref_keyword|abi_keyword|while_keyword|struct_keyword|enum_keyword|match_keyword|use_keyword|var_decl_keyword|fn_decl_keyword|trait_decl_keyword|return_keyword|include_keyword) ~ !(ASCII_ALPHANUMERIC|"_")}
unit = {"(" ~ ")"}
ident = @{ ASCII_ALPHA ~ (ASCII_ALPHANUMERIC|"_")* }
reserved_words = @{(true_keyword|false_keyword|asm_keyword|ref_keyword|deref_keyword|abi_keyword|while_keyword|struct_keyword|enum_keyword|match_keyword|use_keyword|var_decl_keyword|fn_decl_keyword|trait_decl_keyword|return_keyword|include_keyword) ~ !(ASCII_ALPHANUMERIC|"_")}

0 comments on commit fddca66

Please sign in to comment.