Ver código fonte

Add hexadecimal, binary and unsigned integer literals

pull/1/head
Max Brunsfeld 10 anos atrás
pai
commit
8190b6ea7f
3 arquivos alterados com 3173 adições e 2966 exclusões
  1. +6
    -1
      grammar.coffee
  2. +15
    -0
      grammar_test/expressions.txt
  3. +3152
    -2965
      src/parser.c

+ 6
- 1
grammar.coffee Ver arquivo

@ -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 Ver arquivo

@ -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
Diferenças do arquivo suprimidas por serem muito extensas
Ver arquivo


Carregando…
Cancelar
Salvar