Splaf  Check-in [21cd97d6f6]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Added boolean variables and statements.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 21cd97d6f6741469adfa2fc1acdfa676671afc5e
User & Date: emanuel.angelo@gmail.com 2012-10-09 23:37:20.000
Context
2012-10-16
19:24
Added alternative functions for I/O ("ler" and "escrever"). check-in: b0380d17ef user: emanuel.angelo@gmail.com tags: trunk
2012-10-09
23:37
Added boolean variables and statements. check-in: 21cd97d6f6 user: emanuel.angelo@gmail.com tags: trunk
2012-10-08
19:57
Added note to implement boolean statements and values. check-in: 68e94abd24 user: emanuel.angelo@gmail.com tags: trunk
Changes
Unified Diff Ignore Whitespace Patch
Changes to .todo.done.

1
2
3
4
5
6
7

Add >=, <=, ==, logical AND, OR and NOT to the grammar | id:274f8bc44e3e6ee7b161d4b522dee61149449e83
Implement parser | id:555828ffa4e59f1ea30d47ace4993ff44475804a
Flowchart automatic construction from the structured language | id:765757bbdeb83d6200c099b9fa756b2323df467c
Saving to server | id:90cc94f0b58513cf08bba408ec8f70ca4585cdaf
Implement the if statement in the interpreter | id:9633335540f23eddbf08018bd7dfb5487c16ff9c
Loading from server | id:9863ee827ab9625d9a0716f03076ee4d3fec613d
Optimize parser by getting rid of scopes | id:af510b25ed70685884d69869eb4c0ccb7334b2b1
>







1
2
3
4
5
6
7
8
Add boolean variables and statements. | id:179a08af0f88c71e4925c7a50272345b46484de1
Add >=, <=, ==, logical AND, OR and NOT to the grammar | id:274f8bc44e3e6ee7b161d4b522dee61149449e83
Implement parser | id:555828ffa4e59f1ea30d47ace4993ff44475804a
Flowchart automatic construction from the structured language | id:765757bbdeb83d6200c099b9fa756b2323df467c
Saving to server | id:90cc94f0b58513cf08bba408ec8f70ca4585cdaf
Implement the if statement in the interpreter | id:9633335540f23eddbf08018bd7dfb5487c16ff9c
Loading from server | id:9863ee827ab9625d9a0716f03076ee4d3fec613d
Optimize parser by getting rid of scopes | id:af510b25ed70685884d69869eb4c0ccb7334b2b1
Changes to grammars/pt.grammar.
27
28
29
30
31
32
33

34
35
36

37
38
39
40
41
42
43
  / "se"

reserved "reservado"
  = functionname
  / "começa"
  / "e"
  / "então"

  / "não"
  / "ou"
  / "termina"


identifiername "identificador"
  = !reserved
    first:[a-zA-Z_áàãâéêíóõôúçÁÀÃÂÉÊÍÓÕÔÚÇ]
    rest:[0-9a-zA-Z_áàãâéêíóõôúçÁÀÃÂÉÊÍÓÕÔÚÇ]* {
      return first + rest.join("")
    }







>



>







27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
  / "se"

reserved "reservado"
  = functionname
  / "começa"
  / "e"
  / "então"
  / "falso"
  / "não"
  / "ou"
  / "termina"
  / "verdadeiro"

identifiername "identificador"
  = !reserved
    first:[a-zA-Z_áàãâéêíóõôúçÁÀÃÂÉÊÍÓÕÔÚÇ]
    rest:[0-9a-zA-Z_áàãâéêíóõôúçÁÀÃÂÉÊÍÓÕÔÚÇ]* {
      return first + rest.join("")
    }
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194





195
196
197
198
199
200
201
      return {
        type: "variable", 
        name:id
      }
    }

literal "literal"
  = val:(real / integer / text) {
      return {
        type: "literal",
        value: val
      }
    }

integer "inteiro"
  = digits:[0-9]+ { 
      return parseInt(digits.join("")); 
    }

real "real"
  = digits:(integer "." integer) { 
      return parseFloat(digits.join("")); 
    }

text "texto"
  = '"' str:([^\"]*) '"' {
      return str.join("")
    }






parenthesis "parêntesis"
  = "(" val:LogicalOrExpression ")" {
      return val
    }

block "bloco"







|




















>
>
>
>
>







169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
      return {
        type: "variable", 
        name:id
      }
    }

literal "literal"
  = val:(real / integer / text / boolean) {
      return {
        type: "literal",
        value: val
      }
    }

integer "inteiro"
  = digits:[0-9]+ { 
      return parseInt(digits.join("")); 
    }

real "real"
  = digits:(integer "." integer) { 
      return parseFloat(digits.join("")); 
    }

text "texto"
  = '"' str:([^\"]*) '"' {
      return str.join("")
    }

boolean "booleano"
  = boolval:("verdadeiro" / "falso") {
      return boolval == "verdadeiro" ? true : false
    }

parenthesis "parêntesis"
  = "(" val:LogicalOrExpression ")" {
      return val
    }

block "bloco"
Changes to parser.js.
59
60
61
62
63
64
65

66
67
68
69
70
71
72
        "LogicalOrExpression": parse_LogicalOrExpression,
        "primary": parse_primary,
        "identifier": parse_identifier,
        "literal": parse_literal,
        "integer": parse_integer,
        "real": parse_real,
        "text": parse_text,

        "parenthesis": parse_parenthesis,
        "block": parse_block,
        "if": parse_if,
        "while": parse_while,
        "prompt": parse_prompt,
        "print": parse_print,
        "ws": parse_ws,







>







59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
        "LogicalOrExpression": parse_LogicalOrExpression,
        "primary": parse_primary,
        "identifier": parse_identifier,
        "literal": parse_literal,
        "integer": parse_integer,
        "real": parse_real,
        "text": parse_text,
        "boolean": parse_boolean,
        "parenthesis": parse_parenthesis,
        "block": parse_block,
        "if": parse_if,
        "while": parse_while,
        "prompt": parse_prompt,
        "print": parse_print,
        "ws": parse_ws,
359
360
361
362
363
364
365










366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392












393
394
395
396
397
398
399
              } else {
                result0 = null;
                if (reportFailures === 0) {
                  matchFailed("\"ent\\xE3o\"");
                }
              }
              if (result0 === null) {










                if (input.substr(pos, 3) === "n\xE3o") {
                  result0 = "n\xE3o";
                  pos += 3;
                } else {
                  result0 = null;
                  if (reportFailures === 0) {
                    matchFailed("\"n\\xE3o\"");
                  }
                }
                if (result0 === null) {
                  if (input.substr(pos, 2) === "ou") {
                    result0 = "ou";
                    pos += 2;
                  } else {
                    result0 = null;
                    if (reportFailures === 0) {
                      matchFailed("\"ou\"");
                    }
                  }
                  if (result0 === null) {
                    if (input.substr(pos, 7) === "termina") {
                      result0 = "termina";
                      pos += 7;
                    } else {
                      result0 = null;
                      if (reportFailures === 0) {
                        matchFailed("\"termina\"");












                      }
                    }
                  }
                }
              }
            }
          }







>
>
>
>
>
>
>
>
>
>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
>
>
>
>
>
>
>
>
>
>
>
>







360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
              } else {
                result0 = null;
                if (reportFailures === 0) {
                  matchFailed("\"ent\\xE3o\"");
                }
              }
              if (result0 === null) {
                if (input.substr(pos, 5) === "falso") {
                  result0 = "falso";
                  pos += 5;
                } else {
                  result0 = null;
                  if (reportFailures === 0) {
                    matchFailed("\"falso\"");
                  }
                }
                if (result0 === null) {
                  if (input.substr(pos, 3) === "n\xE3o") {
                    result0 = "n\xE3o";
                    pos += 3;
                  } else {
                    result0 = null;
                    if (reportFailures === 0) {
                      matchFailed("\"n\\xE3o\"");
                    }
                  }
                  if (result0 === null) {
                    if (input.substr(pos, 2) === "ou") {
                      result0 = "ou";
                      pos += 2;
                    } else {
                      result0 = null;
                      if (reportFailures === 0) {
                        matchFailed("\"ou\"");
                      }
                    }
                    if (result0 === null) {
                      if (input.substr(pos, 7) === "termina") {
                        result0 = "termina";
                        pos += 7;
                      } else {
                        result0 = null;
                        if (reportFailures === 0) {
                          matchFailed("\"termina\"");
                        }
                      }
                      if (result0 === null) {
                        if (input.substr(pos, 10) === "verdadeiro") {
                          result0 = "verdadeiro";
                          pos += 10;
                        } else {
                          result0 = null;
                          if (reportFailures === 0) {
                            matchFailed("\"verdadeiro\"");
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
1549
1550
1551
1552
1553
1554
1555



1556
1557
1558
1559
1560
1561
1562
        reportFailures++;
        pos0 = pos;
        result0 = parse_real();
        if (result0 === null) {
          result0 = parse_integer();
          if (result0 === null) {
            result0 = parse_text();



          }
        }
        if (result0 !== null) {
          result0 = (function(offset, val) {
              return {
                type: "literal",
                value: val







>
>
>







1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
        reportFailures++;
        pos0 = pos;
        result0 = parse_real();
        if (result0 === null) {
          result0 = parse_integer();
          if (result0 === null) {
            result0 = parse_text();
            if (result0 === null) {
              result0 = parse_boolean();
            }
          }
        }
        if (result0 !== null) {
          result0 = (function(offset, val) {
              return {
                type: "literal",
                value: val
1742
1743
1744
1745
1746
1747
1748









































1749
1750
1751
1752
1753
1754
1755
        }
        reportFailures--;
        if (reportFailures === 0 && result0 === null) {
          matchFailed("texto");
        }
        return result0;
      }









































      
      function parse_parenthesis() {
        var result0, result1, result2;
        var pos0, pos1;
        
        reportFailures++;
        pos0 = pos;







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
        }
        reportFailures--;
        if (reportFailures === 0 && result0 === null) {
          matchFailed("texto");
        }
        return result0;
      }
      
      function parse_boolean() {
        var result0;
        var pos0;
        
        reportFailures++;
        pos0 = pos;
        if (input.substr(pos, 10) === "verdadeiro") {
          result0 = "verdadeiro";
          pos += 10;
        } else {
          result0 = null;
          if (reportFailures === 0) {
            matchFailed("\"verdadeiro\"");
          }
        }
        if (result0 === null) {
          if (input.substr(pos, 5) === "falso") {
            result0 = "falso";
            pos += 5;
          } else {
            result0 = null;
            if (reportFailures === 0) {
              matchFailed("\"falso\"");
            }
          }
        }
        if (result0 !== null) {
          result0 = (function(offset, boolval) {
              return boolval == "verdadeiro" ? true : false
            })(pos0, result0);
        }
        if (result0 === null) {
          pos = pos0;
        }
        reportFailures--;
        if (reportFailures === 0 && result0 === null) {
          matchFailed("booleano");
        }
        return result0;
      }
      
      function parse_parenthesis() {
        var result0, result1, result2;
        var pos0, pos1;
        
        reportFailures++;
        pos0 = pos;
Changes to todo.
1
2
3
4
5
6
7
8
Add boolean variables and statements. | id:179a08af0f88c71e4925c7a50272345b46484de1
Implement addEventListener with jQuery | id:198c5890a8c7b8d3ec69fc4f52485bc29d937b98
Convert verbose operators into compact ones in the flowchart. | id:282849e19d7c03287572c6ae311de1c1befd9dd7
Verify if source code was modified and warn user on actions that will discard those modifications | id:3bcb598ee0495084dd3881c550fee2e9099637d1
Flowchart editing infrastructure | id:4fd44559f6ef158c5652620ef58259427335578a
Structured language automatic writing from the flowchart editing actions | id:70c70f55ad67c1d3b305d21c30da459b18fa509a
Add arrows to connection lines | id:a21b2d395b3a9f155805347576f4974559618312
Use indentation to define blocks of statements. | id:c6e1342a5193a60399f945977b5482e30f14bba4
<








1
2
3
4
5
6
7

Implement addEventListener with jQuery | id:198c5890a8c7b8d3ec69fc4f52485bc29d937b98
Convert verbose operators into compact ones in the flowchart. | id:282849e19d7c03287572c6ae311de1c1befd9dd7
Verify if source code was modified and warn user on actions that will discard those modifications | id:3bcb598ee0495084dd3881c550fee2e9099637d1
Flowchart editing infrastructure | id:4fd44559f6ef158c5652620ef58259427335578a
Structured language automatic writing from the flowchart editing actions | id:70c70f55ad67c1d3b305d21c30da459b18fa509a
Add arrows to connection lines | id:a21b2d395b3a9f155805347576f4974559618312
Use indentation to define blocks of statements. | id:c6e1342a5193a60399f945977b5482e30f14bba4