Selaa lähdekoodia

Add hexadecimal, binary and unsigned integer literals

pull/1/head
Max Brunsfeld 10 vuotta sitten
vanhempi
commit
8190b6ea7f
3 muutettua tiedostoa jossa 3173 lisäystä ja 2966 poistoa
  1. +6
    -1
      grammar.coffee
  2. +15
    -0
      grammar_test/expressions.txt
  3. +3152
    -2965
      src/parser.c

+ 6
- 1
grammar.coffee Näytä tiedosto

@ -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 Näytä tiedosto

@ -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
File diff suppressed because it is too large
Näytä tiedosto


Ladataan…
Peruuta
Tallenna