Skip to content

Commit

Permalink
Merge pull request #50 from cydparser/num-literals
Browse files Browse the repository at this point in the history
Add binary, octal and hex number literals
  • Loading branch information
yannham authored Jun 24, 2024
2 parents 43433d8 + 24ad801 commit 3039ad9
Show file tree
Hide file tree
Showing 5 changed files with 1,566 additions and 1,368 deletions.
4 changes: 2 additions & 2 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ module.exports = grammar({
////////////////////////////
keyword: _ => token(/if|then|else|forall|in|let|rec|match|null|true|false|fun|import|merge|default|doc|force|optional|priority|not_exported/),

num_literal: _ => /[0-9]*\.?[0-9]+([eE][+\-]?[0-9]+)?/,
num_literal: _ => /([0-9]*\.?[0-9]+([eE][+\-]?[0-9]+)?)|0((b[01]+)|(o[0-7]+)|(x[0-9a-fA-F]+))/,

signed_num_literal: _ => /-?[0-9]*\.?[0-9]+([eE][+\-]?[0-9]+)?/,
signed_num_literal: _ => /-?(([0-9]*\.?[0-9]+([eE][+\-]?[0-9]+)?)|0((b[01]+)|(o[0-7]+)|(x[0-9a-fA-F]+)))/,

// **IMPORTANT**
// This regex should be kept in sync with the one for raw_enum_tag below.
Expand Down
4 changes: 2 additions & 2 deletions src/grammar.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
},
"num_literal": {
"type": "PATTERN",
"value": "[0-9]*\\.?[0-9]+([eE][+\\-]?[0-9]+)?"
"value": "([0-9]*\\.?[0-9]+([eE][+\\-]?[0-9]+)?)|0((b[01]+)|(o[0-7]+)|(x[0-9a-fA-F]+))"
},
"signed_num_literal": {
"type": "PATTERN",
"value": "-?[0-9]*\\.?[0-9]+([eE][+\\-]?[0-9]+)?"
"value": "-?(([0-9]*\\.?[0-9]+([eE][+\\-]?[0-9]+)?)|0((b[01]+)|(o[0-7]+)|(x[0-9a-fA-F]+)))"
},
"ident": {
"type": "PATTERN",
Expand Down
Loading

0 comments on commit 3039ad9

Please sign in to comment.