Commit b71b0af7 authored by Pascal J. Bourguignon's avatar Pascal J. Bourguignon

Cleaned up building of syntactic tree.

parent 6ac0a84f
This diff is collapsed.
......@@ -96,6 +96,12 @@
#-(and) (progn
(ql:quickload :com.informatimago.rdp)
(ql:quickload :com.informatimago.languages.c11)
(gen-p)
(pprint (remove-unary (test/parse-stream :source-file "tests/expressions.c")))
(untrace compute-token-kind)
(untrace typedef-name-p function-name-p enumeration-constant-name-p
......@@ -104,26 +110,6 @@
scan-next-token)
(external-declaration (seq ((alt ((seq (static-assert-declaration) ($0))
(seq ((seq (declaration-specifiers) ((push-declaration-specifiers $1)))
(alt ((seq (\;) (:specifier))
(seq (declarator (alt ((seq ((opt ((seq (= initializer) ($2)))) (rep ((seq (\, init-declarator) ($2)))) \;)
((if $1 '(:initializer $1 $2) '(:simple $2))))
(seq ((opt ((seq (declaration-list) ($0)))) compound-statement)
((list :function-declarator $1 $2))))))
((ecase (first $2)
(:simple (declarator $1 (second $2)))
(:initializer (cons (declarator $1 (second $2)) (third $2)))
(:function-declarator (list :declarator $1 $2))))))))
((progn (print (list* 'declaration-specifiers (list $1)))
(print (list* 'declarator (list $2)))
(pop-declaration-specifiers)
(if (eql $2 :specifier) $1 $2)))))))
((print (list* 'external-declaration (list $1))))))
(progn
(print-typedefs) (terpri)
......
int f(int argument)
// invalid: int a,fa(int x){ return a+x; }
void f_void();
_Bool f_bool();
char f_char();
short f_short();
short int f_short_int();
long f_long();
long int f_long_int();
long long f_long_long();
signed char f_signed_char();
signed short f_signed_short();
signed short int f_signed_short_int();
signed long f_signed_long();
signed long int f_signed_long_int();
signed long long f_signed_long_long();
unsigned char f_unsigned_char();
unsigned short f_unsigned_short();
unsigned short int f_unsigned_short_int();
unsigned long f_unsigned_long();
unsigned long int f_unsigned_long_int();
unsigned long long f_unsigned_long_long();
float f_float();
double f_double();
_Complex f_complex();
_Imaginary f_imaginary();
inline _Noreturn void f_in_void();
inline _Noreturn _Bool f_in_bool();
inline _Noreturn char f_in_char();
inline _Noreturn short f_in_short();
short int inline _Noreturn f_in_short_int();
long inline _Noreturn f_in_long();
long int inline _Noreturn f_in_long_int();
long long inline _Noreturn f_in_long_long();
inline _Noreturn signed char f_in_signed_char();
inline _Noreturn signed short f_in_signed_short();
inline _Noreturn signed short int f_in_signed_short_int();
inline _Noreturn signed long f_in_signed_long();
inline _Noreturn signed long int f_in_signed_long_int();
inline _Noreturn signed long long f_in_signed_long_long();
unsigned char inline _Noreturn f_in_unsigned_char();
unsigned short inline _Noreturn f_in_unsigned_short();
unsigned short int inline _Noreturn f_in_unsigned_short_int();
inline _Noreturn unsigned long f_in_unsigned_long();
inline _Noreturn unsigned long int f_in_unsigned_long_int();
inline _Noreturn unsigned long long f_in_unsigned_long_long();
inline _Noreturn float f_in_float();
inline _Noreturn double f_in_double();
inline _Noreturn _Complex f_in_complex();
inline _Noreturn _Imaginary f_in_imaginary();
extern static void v_es_void;
extern static _Bool v_es_bool;
extern static char v_es_char;
extern static short v_es_short;
extern static short int v_es_short_int;
extern static long v_es_long;
extern static long int v_es_long_int;
extern static long long v_es_long_long;
extern static signed char v_es_signed_char;
extern static signed short v_es_signed_short;
extern static signed short int v_es_signed_short_int;
extern static signed long v_es_signed_long;
extern static signed long int v_es_signed_long_int;
extern static signed long long v_es_signed_long_long;
extern static unsigned char v_es_unsigned_char;
extern static unsigned short v_es_unsigned_short;
extern static unsigned short int v_es_unsigned_short_int;
extern static unsigned long v_es_unsigned_long;
extern static unsigned long int v_es_unsigned_long_int;
extern static unsigned long long v_es_unsigned_long_long;
extern static float v_es_float;
extern static double v_es_double;
extern static _Complex v_es_complex;
extern static _Imaginary v_es_imaginary;
void f_register(){
register void v_r_void;
register _Bool v_r_bool;
register char v_r_char;
register short v_r_short;
register short int v_r_short_int;
register long v_r_long;
register long int v_r_long_int;
register long long v_r_long_long;
register signed char v_r_signed_char;
register signed short v_r_signed_short;
register signed short int v_r_signed_short_int;
register signed long v_r_signed_long;
register signed long int v_r_signed_long_int;
register signed long long v_r_signed_long_long;
register unsigned char v_r_unsigned_char;
register unsigned short v_r_unsigned_short;
register unsigned short int v_r_unsigned_short_int;
register unsigned long v_r_unsigned_long;
register unsigned long int v_r_unsigned_long_int;
register unsigned long long v_r_unsigned_long_long;
register float v_r_float;
register double v_r_double;
register _Complex v_r_complex;
register _Imaginary v_r_imaginary;
}
int f(int argument,char ch,long lg)
{
int aa,bb=2,cc=3,*dd=&aa,(*g)(int x,char c);
int vector[3]={1,2,3};
struct point {
int x;
......@@ -61,7 +169,7 @@ int f(int argument)
ivar=(int)sliteral[0];
ivar=(int)a;
ivar=(int)(a);
ivar=(int)f(0);
ivar=(int)f(0,'a',1L);
int multiplicative_expressions;
ivar=a*x;
......@@ -157,7 +265,7 @@ int f(int argument)
ivar=a,b,c;
ivar=((a++),
f(b),
f(b,'c',42L),
a*x*x+b*x+c),
(a*x+b)*x+c;
......
This diff is collapsed.
......@@ -34,8 +34,6 @@
(in-package "COM.INFORMATIMAGO.LANGUAGES.CPP")
;;; --------------------
(declaim (inline trigraph-character))
......@@ -754,7 +752,8 @@ RETURN: the token text; the end position."
include-directories)))))))
(defgeneric token-string (token)
(:method ((token token)) (token-text token))
(:method ((token token))
(token-text token))
(:method ((token string-literal-token))
(with-input-from-string (in (token-text token))
(read-c-string in (read-char in))))
......
......@@ -49,7 +49,7 @@
"CPP-TOKEN" "TOKEN-LINE" "TOKEN-COLUMN" "TOKEN-FILE"
"TOKEN-TEXT" "IDENTIFIER-TOKEN" "NUMBER-TOKEN" "PUNCTUATION-TOKEN"
"OTHER-TOKEN"
"TOKEN-STRING" "TOKEN-SYMBOL"
"TOKEN-STRING" "TOKEN-SYMBOL" "TOKEN-VALUE"
"*IDENTIFIER-PACKAGE*"
"IDENTIFIER" "NUMBER" "STRING-LITERAL" "CHARACTER-LITERAL" "PUNCTUATION"
"ENVIRONMENT-MACRO-DEFINITION"
......
......@@ -14,5 +14,7 @@ extern builtin_va_copy(d,s);
#define __builtin_va_arg(v,l) builtin_va_arg(v,l)
#define __builtin_va_copy(d,s) builtin_va_copy(d,s)
#define __builtin_offsetof(TYPE, MEMBER) ((size_t)(&((TYPE*)0)->MEMBER))
#include <config.h>
#include <lisp.h>
......@@ -94,6 +94,12 @@
(define-token-class punctuation)
(define-token-class other)
(defgeneric token-value (token)
(:method ((token token)) (token-symbol token))
(:method ((token number-token)) (integer-value token))
(:method ((token character-literal-token)) (character-value token))
(:method ((token string-literal-token)) (string-value token)))
(defvar *identifier-package* (load-time-value (find-package #.(package-name *package*)))
"Package where to intern token-symbol of identifiers.")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment