entendendo player.h. falta mudar para string e começar a concatenar.
authorsilveira.kaue <[email protected]>
Tue, 13 Apr 2010 19:43:19 +0000 (13 16:43 -0300)
committersilveira.kaue <[email protected]>
Tue, 13 Apr 2010 19:43:19 +0000 (13 16:43 -0300)
Session.vim
cpptolua
cpptolua.l
cpptolua.y
makefile
player.h [new file with mode: 0644]

index 5b13f4f..fd258d0 100644 (file)
@@ -40,18 +40,26 @@ if expand('%') == '' && !&modified && line('$') <= 1 && getline(1) == ''
   let s:wipebuf = bufnr('%')
 endif
 set shortmess=aoO
-badd +0 cpptolua
-badd +0 cpptolua.l
-badd +0 cpptolua.y
-badd +0 in.cpp
-badd +0 makefile
+badd +1 cpptolua
+badd +44 cpptolua.l
+badd +49 cpptolua.y
+badd +1 in.cpp
+badd +1 makefile
+badd +1 player.h
+badd +1428 y.tab.c
 args cpptolua cpptolua.l cpptolua.y in.cpp makefile
 edit cpptolua.l
 set splitbelow splitright
+wincmd _ | wincmd |
+split
+1wincmd k
+wincmd w
 set nosplitbelow
 set nosplitright
 wincmd t
 set winheight=1 winwidth=1
+exe '1resize ' . ((&lines * 38 + 26) / 52)
+exe '2resize ' . ((&lines * 10 + 26) / 52)
 argglobal
 2argu
 setlocal keymap=
@@ -148,12 +156,113 @@ setlocal nowinfixwidth
 setlocal wrap
 setlocal wrapmargin=0
 silent! normal! zE
-let s:l = 1 - ((0 * winheight(0) + 11) / 22)
+let s:l = 6 - ((5 * winheight(0) + 19) / 38)
 if s:l < 1 | let s:l = 1 | endif
 exe s:l
 normal! zt
-1
+6
 normal! 0
+wincmd w
+argglobal
+2argu
+enew
+setlocal keymap=
+setlocal noarabic
+setlocal autoindent
+setlocal nobinary
+setlocal bufhidden=wipe
+setlocal buflisted
+setlocal buftype=quickfix
+setlocal nocindent
+setlocal cinkeys=0{,0},0),:,0#,!^F,o,O,e
+setlocal cinoptions=
+setlocal cinwords=if,else,while,do,for,switch
+setlocal comments=s1:/*,mb:*,ex:*/,://,b:#,:%,:XCOMM,n:>,fb:-
+setlocal commentstring=/*%s*/
+setlocal complete=.,w,b,u,t,i
+setlocal completefunc=
+setlocal nocopyindent
+setlocal nocursorcolumn
+setlocal nocursorline
+setlocal define=
+setlocal dictionary=
+setlocal nodiff
+setlocal equalprg=
+setlocal errorformat=
+setlocal noexpandtab
+if &filetype != 'qf'
+setlocal filetype=qf
+endif
+setlocal foldcolumn=0
+setlocal foldenable
+setlocal foldexpr=0
+setlocal foldignore=#
+setlocal foldlevel=0
+setlocal foldmarker={{{,}}}
+setlocal foldmethod=manual
+setlocal foldminlines=1
+setlocal foldnestmax=20
+setlocal foldtext=foldtext()
+setlocal formatexpr=
+setlocal formatoptions=tcq
+setlocal formatlistpat=^\\s*\\d\\+[\\]:.)}\\t\ ]\\s*
+setlocal grepprg=
+setlocal iminsert=0
+setlocal imsearch=0
+setlocal include=
+setlocal includeexpr=
+setlocal indentexpr=
+setlocal indentkeys=0{,0},:,0#,!^F,o,O,e
+setlocal noinfercase
+setlocal iskeyword=@,48-57,_,192-255
+setlocal keywordprg=
+setlocal nolinebreak
+setlocal nolisp
+setlocal nolist
+setlocal makeprg=
+setlocal matchpairs=(:),{:},[:]
+setlocal modeline
+setlocal nomodifiable
+setlocal nrformats=octal,hex
+set number
+setlocal number
+setlocal numberwidth=4
+setlocal omnifunc=
+setlocal path=
+setlocal nopreserveindent
+setlocal nopreviewwindow
+setlocal quoteescape=\\
+setlocal noreadonly
+setlocal norightleft
+setlocal rightleftcmd=search
+setlocal noscrollbind
+setlocal shiftwidth=2
+setlocal noshortname
+setlocal smartindent
+setlocal softtabstop=0
+setlocal nospell
+setlocal spellcapcheck=[.?!]\\_[\\])'\"\       \ ]\\+
+setlocal spellfile=
+setlocal spelllang=en
+setlocal statusline=
+setlocal suffixesadd=
+setlocal noswapfile
+setlocal synmaxcol=3000
+if &syntax != 'qf'
+setlocal syntax=qf
+endif
+setlocal tabstop=2
+setlocal tags=
+setlocal textwidth=0
+setlocal thesaurus=
+setlocal winfixheight
+setlocal nowinfixwidth
+setlocal wrap
+setlocal wrapmargin=0
+wincmd w
+2wincmd w
+exe '1resize ' . ((&lines * 38 + 26) / 52)
+exe '2resize ' . ((&lines * 10 + 26) / 52)
 tabedit cpptolua.y
 set splitbelow splitright
 set nosplitbelow
@@ -256,12 +365,13 @@ setlocal nowinfixwidth
 setlocal wrap
 setlocal wrapmargin=0
 silent! normal! zE
-let s:l = 1 - ((0 * winheight(0) + 11) / 22)
+let s:l = 36 - ((35 * winheight(0) + 25) / 50)
 if s:l < 1 | let s:l = 1 | endif
 exe s:l
 normal! zt
-1
-normal! 0
+36
+normal! 07l
+2wincmd w
 tabedit in.cpp
 set splitbelow splitright
 set nosplitbelow
@@ -364,12 +474,122 @@ setlocal nowinfixwidth
 setlocal wrap
 setlocal wrapmargin=0
 silent! normal! zE
-let s:l = 1 - ((0 * winheight(0) + 11) / 22)
+let s:l = 1 - ((0 * winheight(0) + 25) / 50)
 if s:l < 1 | let s:l = 1 | endif
 exe s:l
 normal! zt
 1
 normal! 0
+2wincmd w
+tabedit player.h
+set splitbelow splitright
+set nosplitbelow
+set nosplitright
+wincmd t
+set winheight=1 winwidth=1
+argglobal
+edit player.h
+setlocal keymap=
+setlocal noarabic
+setlocal autoindent
+setlocal nobinary
+setlocal bufhidden=
+setlocal buflisted
+setlocal buftype=
+setlocal cindent
+setlocal cinkeys=0{,0},0),:,0#,!^F,o,O,e
+setlocal cinoptions=
+setlocal cinwords=if,else,while,do,for,switch
+setlocal comments=sO:*\ -,mO:*\ \ ,exO:*/,s1:/*,mb:*,ex:*/,://
+setlocal commentstring=/*%s*/
+setlocal complete=.,w,b,u,t,i
+setlocal completefunc=
+setlocal nocopyindent
+setlocal nocursorcolumn
+setlocal nocursorline
+setlocal define=
+setlocal dictionary=
+setlocal nodiff
+setlocal equalprg=
+setlocal errorformat=
+setlocal noexpandtab
+if &filetype != 'cpp'
+setlocal filetype=cpp
+endif
+setlocal foldcolumn=0
+setlocal foldenable
+setlocal foldexpr=0
+setlocal foldignore=#
+setlocal foldlevel=0
+setlocal foldmarker={{{,}}}
+setlocal foldmethod=manual
+setlocal foldminlines=1
+setlocal foldnestmax=20
+setlocal foldtext=foldtext()
+setlocal formatexpr=
+setlocal formatoptions=croql
+setlocal formatlistpat=^\\s*\\d\\+[\\]:.)}\\t\ ]\\s*
+setlocal grepprg=
+setlocal iminsert=0
+setlocal imsearch=0
+setlocal include=
+setlocal includeexpr=
+setlocal indentexpr=
+setlocal indentkeys=0{,0},:,0#,!^F,o,O,e
+setlocal noinfercase
+setlocal iskeyword=@,48-57,_,192-255
+setlocal keywordprg=
+setlocal nolinebreak
+setlocal nolisp
+setlocal nolist
+setlocal makeprg=
+setlocal matchpairs=(:),{:},[:]
+setlocal modeline
+setlocal modifiable
+setlocal nrformats=octal,hex
+set number
+setlocal number
+setlocal numberwidth=4
+setlocal omnifunc=ccomplete#Complete
+setlocal path=
+setlocal nopreserveindent
+setlocal nopreviewwindow
+setlocal quoteescape=\\
+setlocal noreadonly
+setlocal norightleft
+setlocal rightleftcmd=search
+setlocal noscrollbind
+setlocal shiftwidth=2
+setlocal noshortname
+setlocal smartindent
+setlocal softtabstop=0
+setlocal nospell
+setlocal spellcapcheck=[.?!]\\_[\\])'\"\       \ ]\\+
+setlocal spellfile=
+setlocal spelllang=en
+setlocal statusline=
+setlocal suffixesadd=
+setlocal swapfile
+setlocal synmaxcol=3000
+if &syntax != 'cpp'
+setlocal syntax=cpp
+endif
+setlocal tabstop=2
+setlocal tags=
+setlocal textwidth=0
+setlocal thesaurus=
+setlocal nowinfixheight
+setlocal nowinfixwidth
+setlocal wrap
+setlocal wrapmargin=0
+silent! normal! zE
+let s:l = 54 - ((41 * winheight(0) + 25) / 50)
+if s:l < 1 | let s:l = 1 | endif
+exe s:l
+normal! zt
+54
+normal! 04l
+2wincmd w
 tabedit makefile
 set splitbelow splitright
 set nosplitbelow
@@ -472,12 +692,13 @@ setlocal nowinfixwidth
 setlocal wrap
 setlocal wrapmargin=0
 silent! normal! zE
-let s:l = 20 - ((19 * winheight(0) + 11) / 22)
+let s:l = 1 - ((0 * winheight(0) + 25) / 50)
 if s:l < 1 | let s:l = 1 | endif
 exe s:l
 normal! zt
-20
-normal! 07l
+1
+normal! 0
+2wincmd w
 tabnext 1
 if exists('s:wipebuf')
   silent exe 'bwipe ' . s:wipebuf
dissimilarity index 60%
index 094fc38..c5fa7e9 100755 (executable)
Binary files a/cpptolua and b/cpptolua differ
index 7504935..4127492 100644 (file)
@@ -3,26 +3,27 @@
 #include <stdlib.h>
        void yyerror(char *);
        int idf(char *s);
+//#define DEBUG
 %}
 
 %%
 
-"class" { return CLASS; }
-[{};(),] { 
+"class" { printf("class\n"); return CLASS; }
+[{};(),:] { 
        yylval.name = strdup(yytext);
 #ifdef DEBUG
-       printf("read: %c\n", *yytext);
+       printf(": %c\n", *yytext);
 #endif
        return *yytext; 
 }
 
 
        /* identifiers */
-[a-zA-Z_0-9]+ {
+[a-zA-Z_0-9~>&=]+ {
        yylval.name = strdup(yytext);
 #ifdef DEBUG
-       printf("read: %s\n", yytext);
-       printf("idf: %i\n", idf(yytext));
+       printf(": %s\n", yytext);
+       //printf("idf: %i\n", idf(yytext));
 #endif
        return idf(yytext);
 }
        /* skip comments */
 \/\/.* ;
 \/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+\/ ;
+^#.*$ ;
+^using.*$ ;
 
        /* anything else is an error */
 . { 
-       printf("read: '%c'\n", *yytext);
+       printf(": '%c'\n", *yytext);
        yyerror((char *)"invalid character");
 }
 
@@ -48,11 +51,13 @@ int yywrap(void) {
 
 int idf(char *s)
 {
-       char types[][99] = {"int", "float", ""};
+       //printf("idf: %s\n", s);
+
+       char types[][99] = {"public", "private", "protected", ""};
        int i;
        for(i = 0; types[i][0]; i++) {
                if(!strcmp(types[i], s)) {
-                       return TYPE;
+                       return VISIBILITY;
                }
        }
        return IDF;
dissimilarity index 62%
index bdd451c..43fb507 100644 (file)
@@ -1,58 +1,89 @@
-%{
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdarg.h>
-
-int yylex(void);
-void yyerror(char *);
-
-%}
-
-/* yyval type */
-%union {
-                               char *name;
-};
-
-%token <name> IDF TYPE
-%token CLASS 
-%type <name> types
-
-%%
-
-program:
-                        CLASS IDF '{' functions '}' ';' { printf("ClassName: %s\n",$2); }
-       ;
-
-functions:
-                                functions types IDF '(' parameters ')' ';' { printf("MethodName: %s\n", $3); }
-                                | /* empty */
-                                ;
-
-types:
-                                TYPE types
-                                | /* empty */ { $$ = "NoType"; }
-                                ;
-
-parameters:
-                                       parameter
-                                       | parameter ',' parameters 
-                                       | /* empty */ { printf("NoParameter\n"); }
-                                       ;
-
-parameter:
-                                types IDF      { printf("ParameterType: %s\nParameterName: %s\n", $1, $2); }
-                                ;
-%%
-
-
-int main(int argc, char **argv) 
-{
-       yyparse();
-       return 0;
-}
-
-void yyerror(char *s) {
-       fprintf(stdout, "%s\n", s);
-}
-
+%{
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#define YY_(x) (char *) (x)
+
+int yylex(void);
+void yyerror(char *);
+
+%}
+
+/* yyval type */
+%union {
+                               char *name;
+};
+
+%token <name> IDF
+%token CLASS VISIBILITY
+
+%%
+
+program:
+                        CLASS IDF hierarchy_opt '{' class_body '}' ';' { printf("ClassName: %s\n",$2); }
+       ;
+
+class_body:
+                                       VISIBILITY ':' class_body 
+                                       | function class_body
+                                       | idf_comma_list ';' class_body
+                                       | /* empty */
+                                       ;
+
+hierarchy_opt:
+                                                ':' VISIBILITY idf_comma_list                                          { printf("idf_comma_list:\n"); }
+                                                | /* empty */
+                                                ;
+
+idf_comma_list_opt:
+                                                                       idf_comma_list
+                                                                       | /* empty */
+                                                                       ;
+
+idf_comma_list:
+                                                       idf_list
+                                                       | idf_comma_list ',' idf_list
+                                                       ;
+
+idf_list_opt:
+                                               idf_list
+                                               | /* empty */
+                                               ;
+
+idf_list:
+                               idf_list IDF
+                               | IDF
+                               ;
+
+function:
+                                idf_list '(' idf_comma_list_opt ')' idf_list_opt function_body { printf("Method\n"); }
+                                | idf_list '{' '}' ';'// for enum
+                                ;
+
+function_body:
+                                                ';'
+                                                | '{' block '}'
+                                                ;
+
+block:
+                idf_list ';'
+                | idf_comma_list ';'
+                | '{' block '}'
+                | ',' block
+                | /* empty */
+                ;
+%%
+
+
+int main(int argc, char **argv) 
+{
+       yyparse();
+       return 0;
+}
+
+void yyerror(char *s) {
+       fprintf(stdout, "%s\n", s);
+}
+
index 9c909ac..bd5e210 100644 (file)
--- a/makefile
+++ b/makefile
@@ -6,6 +6,7 @@ CC = g++
 
 all: $(PROG)
        ./$(PROG) < in.cpp
+       ./$(PROG) < player.h
 
 $(PROG): y.tab.c lex.yy.c
        $(CC) $^ -o $@
diff --git a/player.h b/player.h
new file mode 100644 (file)
index 0000000..91a0a44
--- /dev/null
+++ b/player.h
@@ -0,0 +1,62 @@
+#ifndef __ROBOPET_PLAYER_H__
+#define __ROBOPET_PLAYER_H__
+
+#include "movingObject.h"
+
+using RP::MovingObject;
+using RP::Player;
+
+class Player: public MovingObject
+{
+  public:
+    enum Role {  };
+
+    Player() {}
+    ~Player() {}
+
+    //----- Getters -----
+    inline double getCurrentAngle() const { return _current_angle; }
+    inline double getFutureAngle() const { return _future_angle; }
+    inline double getDeltaAngle() const { return _delta_angle; }
+
+    inline Role getRole() const { return _role; }
+
+    inline double getDisplacementWithBall() const { return  _displacement_with_ball; }
+
+    inline int getDriblerIntensity() { return _dribler; }
+    inline int getKickerIntensity() { return _kicker; }
+
+    inline int getId() { return _id; }
+
+    //----- Setters -----
+    void setCurrentAngle( double newCurrentAngle );
+    void setFutureAngle( double newFutureAngle );
+    void setDeltaAngle( double newDeltaAngle );
+
+    void setRole( Role newRole );
+
+    void setDisplacementWithBall( double newDisplacementWithBall ) ;
+
+    void setDriblerIntensity(int intensity);
+    void setKickerIntensity(int intensity);
+
+    void setId(int id);
+
+    //----- Others -----
+    double calcDeltaAngle();
+
+    inline bool isDribling() { return _dribler > 0; }
+    inline bool isKicking() { return _kicker > 0; }
+
+    Player& operator=(const Player& other);
+
+  private:
+    double _current_angle, _future_angle, _delta_angle;
+    Role _role;
+
+    int _kicker, _dribler, _id;
+
+    double _displacement_with_ball;
+};
+
+#endif //__ROBOPET_PLAYER_H__