瀏覽代碼

Add hexadecimal, binary and unsigned integer literals

pull/1/head
Max Brunsfeld 10 年之前
父節點
當前提交
8190b6ea7f
共有 3 個文件被更改,包括 3173 次插入2966 次删除
  1. +6
    -1
      grammar.coffee
  2. +15
    -0
      grammar_test/expressions.txt
  3. +3152
    -2965
      src/parser.c

+ 6
- 1
grammar.coffee 查看文件

@ -435,7 +435,12 @@ module.exports = grammar
@_expression,
@initializer_list)
number_literal: -> /\d+(\.\d+)?/
number_literal: -> token(choice(
/\d+(\.\d+)?/,
/\d+u/,
seq("0x", /[0-9a-fA-f]+/),
seq("0b", /[01]+/),
))
char_literal: -> token(seq(
"'",

+ 15
- 0
grammar_test/expressions.txt 查看文件

@ -1,3 +1,18 @@
============================================
Number literals
============================================
int a = 0xAC00;
int b = 0.123;
int c = 0b1010001;
---
(translation_unit
(declaration (identifier) (init_declarator (identifier) (number_literal)))
(declaration (identifier) (init_declarator (identifier) (number_literal)))
(declaration (identifier) (init_declarator (identifier) (number_literal))))
============================================
Identifiers
============================================

+ 3152
- 2965
src/parser.c
文件差異過大導致無法顯示
查看文件


Loading…
取消
儲存