Daily Archives: July 12, 2014

Mass Programming Language (5) Variables Scope

Previos Post

I finally started a new implementation of variables and their scope in programming language Mass. My idea is:

– Have local variables

– No need to explicitly declare

– Access available "outside" if necessary

The basic idea is:

– Any variable assignment involves the local level

That is, if I assign

a = 3

in a function, this refers to a local variable in the function. No matter if there is a variable external to the function

See for example


# file variable
a = 1

define foo()
    a = 2 # local variable


The first variable a is a variable of the file in process (the module). The variable assigned in the foo function is local to that function, and it is different from the outside variable.

But if we do not assign the variable, and only consulted it, its value is returned. example:


# file variable
a = 1

define foo()
   a # access file variable


In this case, the function foo returns the value to "outside", since this variable has not been assigned in the function when evaluating the return value.

How to edit an "external” variable, that is, a non-local variablel? Well, this is a topic for an upcoming post. The idea: to access the value of a non-local variable, it must be implied, without declaring anything extra. BUT modifying its value must should be explicit: we put something to explicitly declare "we are changing the value of a non-local variable".

Stay tuned!

Angel “Java” Lopez



Node.Js: Links, News And Resources (22)

Previous Post
Next Post

More links from my collection. More updated links at http://delicious.com/ajlopez/nodejs

javascript – Do you know any tutorial for mongoDB in nodeJS? – Stack Overflow

Sample application built with Backbone.js, Twitter Bootstrap, Node.js, Express, MongoDB

Node.js, Express, Stylus, MongoDB example

Node.js module for grafting a middleware pipeline over a target function

NodeJS html parser npm package using the parser library from the netsurf web browser — it’s fast and accurate

OData query string parser for node.js

theLIFT – A Digital Innovation Group

Express.js by Dan Zajdband – Comunidad Nodejs Argentina – YouTube

Websockets y Node.js en las nubes – MedellínJS (Medellín) – Meetup

NPM shrinkwrap
Lock down dependency versions

Class Diagram of Node.js
This shows the class structure of Node.js at a glance. This covers most of classes in the node manual but has a few exceptions

Bifocals by Dashron
A node.js View library with support for asynchronous sub-views (aka partials) and interchangeable rendering systems.

Node.js, Express, Mongoose demo

Node.js & WebSocket – Simple chat tutorial

Node.js Application using Socket.io

url routing – Organize routes in Node.js – Stack Overflow

node.js – Using routes in Express-js – Stack Overflow

Node.js: A Todo App with Express | Blog :: The JavaScript Playground

Express.js Tutorial

Creating a basic site with node.js and Express – shapeshed

Getting Started with Express – How To Node – NodeJS

Seattle Node.js (Seattle, WA) – Meetup

Episode 12 – Isaac Schlueter – http://www.jsconflive.com
The man behind NPM and now the newly annointed leader of Node.js, Isaac Schlueter, stops by for a quick chat.

How to Write Portable Node.js Code – Node.js on Windows Azure

Salesforce API Connection Library for Node.js Applications

My Links

Stay tuned!

Angel “Java” Lopez

GrammGen In C# (2) First Rules

Previous Post

Let’s see today how a parser is built with GrammGen using code. The idea is to define using GrammGen how to build a tree with expressions detected in the text under process. The text is written in the programming language that we want to implement. The expression tree is created using the GrammGen definition, given by code.

I presented in the previous post for an example of a console program, which employs GrammGen. A parser is defined using rules. The rules indicate:

– How to process text characters
– How then form text elements, such as numbers, names, operators
– How to go from putting together such elements, expressions, commands that define our language to implement.

In the sample of calculator


the rules are defined by the parser:


The first rules:

private static Rule[] rules = new Rule[]
   Rule.Or(' ', '\t', '\r', '\n').Skip(),
   Rule.Or('+', '-').Generate("Oper0"),
   Rule.Or('*', '/').Generate("Oper1"),
// ...

The idea is to get an Expression. The first rule defines that anyone (Rule.Or) of space, tab, carriage return, new line items are ignored (. Skip ()). You can put more than one rule of this type, for example, to set comments to be ignored from the input text.

The second rule defines both + (the plus sign) and – (minus sign) produce a called terminal Oper0. They differ from * (the token) and / (divide sign) because we want to take precedence among operators.

There is a rule to construct integers:


Rule.Get("0-9").OneOrMore().Generate("Integer", MakeIntegerConstantExpression), 

The Rule.Get allows you to specify a range of characters, and then, with the fluent interface defined, you can attach the .OneOrMore () method, which specifies that the rule can be applied once or several times. When you can not apply more, it ends generating a node called "Integer". But in GrammGen a node, in addition to a name, may have an associated object. Al. A second parameter can be passed to Generate method, with a function that creates the associated object.

MakeIntegerConstantExpression job is:

– Get the object that was formed with the rule, in this case, a concatenated string with all digits were found.

– Transform it to integer

– Create a ConstantExpression with the intever as constant value.

The class ConstantExpression is not from GrammGen. It is defined by us. We have the freedom to define the objects we want to attach to each node of the GrammGen generated tree.

The code of MakeIntegerConstantExpression is:

   private static object MakeIntegerConstantExpression(object obj)
       int value = int.Parse((string)obj);

       return new ConstantExpression(value);

In the next posts we will see how the nodes of binary operations are formed, how operator precedence is implemented, how to manage left recursion, and evaluation of the generated expressions.

Stay tuned!

Angel “Java” Lopez