Wednesday, January 26, 2011

Lying Down Makes You More Sick When Throwing Up

is extinguished? Cahuita

Today it rains, there is no money to go for a walk so we have to stay locked and use your imagination to have some fun. There is no doubt going to be late for movies ... we love to stay dormant in front of the screen as we tell stories. Eat rich food we prepare both, cuddles and caresses between and is even more tasty. The weather is cold but the warmth your company comforts me, I adore.

Today was sunny, the sky is beautifully blue, almost cloudless. In the evening you arrive, today is a day to go but neither walks in the mood to do anything. I spent the whole day at the computer doing work and reading for the U, my eyes are tired and sleepy. You come to school, going through the bustle of the city, walking in the sun, to stand in the bus and just want to sleep. The sun will stay there ... outside, together with the beautiful afternoon, today we are not in the mood .




Every other one not, are so
vulnerable.

The happy times are depleted because tiredness
the scares.

is as if a light breeze off
try our sailing slowly.

How Do You Remove Mucus From Babys Throat

Working with branchs in mercurial


One way to work in parallel, several developers are using branchs. In mercurial, other than each have their own clone, it is also possible to have one or more independent branches. The working is as follows:
branch is created:


$ hg branch new_branch
new_branch Where is the name you want to give. To find out which branch we are working, we use the same command without arguments:


$ hg branch

New_branch
Now, the line of work is as shown in the figure below:



The way to work in the branch as if we were in default, with the difference that made the commit and push without affecting the main branch (default). So how we can merge those changes?. We merge from the branch to the new_branch $ hg merge new_branch
default.



down one branch switch between them

If we want to make us a clone

when branches are created, by default we'll leave the default branch. To switch to another branch do the following: -f $ hg branch new_branch


This puts us on the branch you want. Now we need to update to bring us the latest changes:

$ hg update

Similarly, we can switch from one branch to another by these two steps.
Then the normal work:



$ hg ci-m "..."
$ hg pull $ hg push


If we want to bring changes to any branch, we merge with the branch you want:

$ hg branch
new_branch
default $ hg merge

When we want to close down the branch, run the commit of the following:


hg commit $ - close-branch
-m 'Branch closed new_branch'


References A very good tutorial on different ways to work with branchs in mercurial, (one branch is to "physical").
A guide to Branching in Mercurial
http://mercurial.selenic.com/wiki/NamedBranches

Monday, January 17, 2011

What A Mri Is Looking For

Add Django style sheet

To add stylesheets, the directory of images and javascript files so that Django knows where is everything and directions. One way to solve this is: suppose we have the following hierarchy of directories within the main project.


$ tree templates /
templates /

, , :
settings.STATIC_ROOT +' templates / images'
}),
( r'js / (? P \u0026lt;path> .*)$' , 'django.views.static.serve' also we have to include at the beginning of the file urls.py
,
{'DOCUMENT_ROOT'
:
settings.STATIC_ROOT + 'templates / js'
}) _______________________________________________________
the amount needed to use the variable STATIC_ROOT: _______________________________________________________


 
import settings _______________________________________________________
Now we have to define this variable in settings.py . What we do is put as the path to the application: _______________________________________________________
STATIC_ROOT = '/ path / to / app /'
_______________________________________________________ And finally, we need to update the list TEMPLATE_DIRS with the url to the directory template: _______________________________________________________
STATIC_ROOT + 'templates /' , _______________________________________________________
With this, we have all you need to use CSS in your application. When reference is made to pick what style sheet in html, it should point to the root of the template, which would read:
\u0026lt; link
href = " / css / style.css "rel
=" stylesheet "type

=" text / css "

   

/
>

   



References
   
Django-doc



Friday, January 7, 2011

All Black Small Gages

mini-C Parser in Python

I've been learning for some time a module to make the lexer and parser of a compiler in Python. This is a relatively easy tool to use (compared to others like antlr) and very similar in syntax to LEX and YACC. In fact, the name comes from
  Python PLY-Lex-Yacc.      There are many tutorials and examples of this module, so my intention here is not to explain how to use and little else.     install    What We   ply to install the module for Python. This can be done from the Ubuntu repositories or through the tar.gz of the project page.        $ sudo apt-get install python-ply 


lexical analyzer import
as  lex

# list of tokens
tokens = (
    
# Reserverd words
     'ELSE' ,
    
'IF'
,
    
'INT' ,      'RETURN' ,      'WHILE'
,      'VOID'
,
         # Symbols

    
'PLUS'
,      'MINUS'
,
    
'TIMES'
,
       'DIVIDE'  ,        'LESS'  ,       
'LESSEQUAL'
,      'GREATER'
,
     'GREATEREQUAL' ,
     'EQUAL' ,
     'DEQUAL' ,
     'DISTINT' ,
     'SEMICOLON' ,
     'COMMA' ,
     'LPAR' ,

'RPAREN' ,
'LBRACKET' ,
'RBRACKET' ,
'LBLOCK' ,
'RBLOCK' ,
# Others
; 'ID' ,
'NUMBER' ,
)
What's done is make an array of all tokens of the language. In this case has taken a subset of C, which we called cminus.

Now, as expected, there should be regular expressions for all these tokens. One way to do this (this is new from version 3 PLY) take all those tokens only be a sentence and do it directly in the form:
# Regular expressions rules for a simple tokens
t_PLUS = r '\\ +'

t_MINUS = r'-'
t_TIMES = r' \\ * '
t_DIVIDE = r' / '
t_EQUAL =
r '='

t_LESS = r '\u0026lt;'
t_GREATER = r '>'
t_SEMICOLON = ','


t_COMMA = r ' , '

t_LPAREN = r' \\ ('
t_RPAREN =
r '\\)'
   
t_LBRACKET = r '\\ ['
   
t_RBRACKET = r '\\]'
   
t_LBLOCK = r '{'
   
t_RBLOCK = r '}'
   
 For all other tokens, what we do is a function. Note that all the rules begin with t, this is because the module takes everything that contains that t_TOKEN creates the corresponding transition diagram. Some of them are:   
  def  
 t_ELSE  (t):   
r'else'
          
return
    t   
   def   
 
 t_IF  (t):       
r'if'
          
return
    t   
   def   
 
 t_NUMBER  (t):       
r'\d+'
    t.value =
int
(t.value)
    
   return     t       
def  
t_ID (t):      r'\w+(_\d\w)*'
    
return  t
def  
t_newline (t):      r'\n+'
    t.lexer.lineno +=
len (t.value) t_ignore = ' \t
'

def   t_comments (t):
    
r'/*(. t.lexer.lineno + = 1 def
t_error
(t): print " Lexical error: "+

str (t.value [ 0 ]) t.lexer.skip ( 1 )



Parsing Now we give an order to all these tokens that we are coming. This is achieved using a grammar. Specify PLY grammars is very similar to that used in YACC. '''not_terminal: list_of_terminals not_terminals'''
For example,
"" "program: PROGRAM ID SEMICOLON EOF block" "" PLY What does is take the first string in each production analyze and create the parser. For example, some of the production of C-minus are: ______________________________________________________ import
ply.yacc
as yacc from cminus_lexer

import token import  cminus_lexer def
  p_program
(p):     'program : declaration_list'

    pass
def   p_declaration_list_1 (p):     'declaration_list : declaration_list declaration'  

pass


def

 
p_declaration_list_2
(p):
   
'declaration_list : declaration'

   

pass



   def       p_declaration  (p):       
'''declaration : var_declaration                  
pass

def   p_var_declaration_1 (p):
    'var_declaration : type_specifier ID SEMICOLON'
    pass

def   p_var_declaration_2 (p):
    'var_declaration : type_specifier ID LBRACKET NUMBER RBRACKET SEMICOLON'
   
   pass       
   def        p_type_specifier_1  (p):       
'type_specifier : INT'    
pass

def   p_type_specifier_2 (p):    
'type_specifier : VOID'    
pass
def

  p_fun_declaration (p):     'fun_declaration : LPAR ID arRP type_specifier compount_stmt params' pass



def p_empty (p): 'empty' pass



______________________________________________________ Note that nonterminals are in lower case and the terminals are in upper case. This is by convention. In addition, tokens are created above in the lexical analyzer. In the PLY production is necessary to place a fool to do the role of epsilon . (P → epsilon ). This does nothing. This is a parser that simply checks that the syntax is correct, but if it is incorrect, we need to sing the error. We do this by producing p_error ()
. ______________________________________________________
def

p_error (p): if p is

Not  
None
:         print   "Syntax error at line "  + str
(p.lexer.lineno) +  
" Unexpected token  "  + str
(p.value)
      
 else    :            print     "Syntax error at line: " Str + 
(cminus_lexer.lexer.lineno) ______________________________________________________

Once we have all written rules, we call the parser. The first time you run, will build a py file with the parser, called
parsetab.py
and another with the lexical and syntactic information call
parser.out
. ______________________________________________________ parser = yacc.yacc ()
if
  __name__ == '__main__' :   data =   '''     
        // Comment C99 style         int gcd (int u, int v) {             if (v == 0)                 return u  
            else                 return gcd(v, v-u);         }
    '''
   parser.parse (data, tracking = True  ) ______________________________________________________  
To run the program, invoke the parser and it will take the sample code above and you will pass the parser.
cminus_parser.py $ python Syntax error at line 6
 Unexpected token else 


 complete Code 


can see the entire code in the repository: Http://bitbucket.org/jjfumero/cminus The next step is to build the AST. The strategy here is to build as it makes the parser.

References

PLY
Tutorial for a mini-lisp
    

Tuesday, January 4, 2011

Green Green Episode 13 Stream



Glide infinitely
one after another.

play chase,
to break into a whisper of foam
and vanish
between the coral shore.


The sea is like a naughty child,
hug awkwardly trying
and drags me into a gentle sway.

out!
not going to be that the child is besotted
and take you to live with him.