Splaf  Check-in [4277aea5f8]

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

Overview
Comment:Added two more variations for the I/O functions.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:4277aea5f85c193159d15e2dcf28937a6b8aa5fd
User & Date: emanuel.angelo@gmail.com 2012-10-16 23:22:35
Context
2013-03-02
01:39
Eliminated file relative to the Bazaar repository. check-in: c55fc21fb9 user: emanuel.angelo@gmail.com tags: trunk
2012-10-16
23:22
Added two more variations for the I/O functions. check-in: 4277aea5f8 user: emanuel.angelo@gmail.com tags: trunk
19:41
Added square root function. check-in: 2ef952be95 user: emanuel.angelo@gmail.com tags: trunk
Changes

Changes to grammars/pt.grammar.

19
20
21
22
23
24
25

26
27

28
29
30
31
32
33
34
...
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
        value: val 
      } 
    }

functionname "nome de função"
  = "diz"
  / "enquanto"

  / "escrever"
  / "ler"

  / "pede"
  / "raiz_quadrada"
  / "se"

reserved "reservado"
  = functionname
  / "começa"
................................................................................
        type: "while",
        condition: cond,
        value: whileval
      }
    }

prompt "pedido"
  = ("pede" / "ler") ws+ id:identifiername _ lb {
      return {
        type: "prompt",
        name: id
      }
    }

print "apresentação"
  = ("diz" / "escrever") ws+ args:((ws? ComparisonExpression)+)? _ lb {
      return {
        type: "print",
        arguments: args ? args.map(function(a) { return a[1] }) : null
      }
    }

ws "um espaço em branco"







>


>







 







|







|







19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
...
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
        value: val 
      } 
    }

functionname "nome de função"
  = "diz"
  / "enquanto"
  / "escreve"
  / "escrever"
  / "ler"
  / "lê"
  / "pede"
  / "raiz_quadrada"
  / "se"

reserved "reservado"
  = functionname
  / "começa"
................................................................................
        type: "while",
        condition: cond,
        value: whileval
      }
    }

prompt "pedido"
  = ("pede" / "ler" / "lê") ws+ id:identifiername _ lb {
      return {
        type: "prompt",
        name: id
      }
    }

print "apresentação"
  = ("diz" / "escrever" / "escreve") ws+ args:((ws? ComparisonExpression)+)? _ lb {
      return {
        type: "print",
        arguments: args ? args.map(function(a) { return a[1] }) : null
      }
    }

ws "um espaço em branco"

Changes to parser.js.

295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341




















342
343
344
345
346
347
348


349
350
351
352
353
354
355
....
2325
2326
2327
2328
2329
2330
2331











2332
2333
2334
2335
2336
2337
2338
....
2408
2409
2410
2411
2412
2413
2414











2415
2416
2417
2418
2419
2420
2421
          } else {
            result0 = null;
            if (reportFailures === 0) {
              matchFailed("\"enquanto\"");
            }
          }
          if (result0 === null) {
            if (input.substr(pos, 8) === "escrever") {
              result0 = "escrever";
              pos += 8;
            } else {
              result0 = null;
              if (reportFailures === 0) {
                matchFailed("\"escrever\"");
              }
            }
            if (result0 === null) {
              if (input.substr(pos, 3) === "ler") {
                result0 = "ler";
                pos += 3;
              } else {
                result0 = null;
                if (reportFailures === 0) {
                  matchFailed("\"ler\"");
                }
              }
              if (result0 === null) {
                if (input.substr(pos, 4) === "pede") {
                  result0 = "pede";
                  pos += 4;
                } else {
                  result0 = null;
                  if (reportFailures === 0) {
                    matchFailed("\"pede\"");
                  }
                }
                if (result0 === null) {
                  if (input.substr(pos, 13) === "raiz_quadrada") {
                    result0 = "raiz_quadrada";
                    pos += 13;
                  } else {
                    result0 = null;
                    if (reportFailures === 0) {
                      matchFailed("\"raiz_quadrada\"");
                    }
                  }
                  if (result0 === null) {




















                    if (input.substr(pos, 2) === "se") {
                      result0 = "se";
                      pos += 2;
                    } else {
                      result0 = null;
                      if (reportFailures === 0) {
                        matchFailed("\"se\"");


                      }
                    }
                  }
                }
              }
            }
          }
................................................................................
            pos += 3;
          } else {
            result0 = null;
            if (reportFailures === 0) {
              matchFailed("\"ler\"");
            }
          }











        }
        if (result0 !== null) {
          result2 = parse_ws();
          if (result2 !== null) {
            result1 = [];
            while (result2 !== null) {
              result1.push(result2);
................................................................................
            result0 = "escrever";
            pos += 8;
          } else {
            result0 = null;
            if (reportFailures === 0) {
              matchFailed("\"escrever\"");
            }











          }
        }
        if (result0 !== null) {
          result2 = parse_ws();
          if (result2 !== null) {
            result1 = [];
            while (result2 !== null) {







|
|
|



|



|
|
|



|



|
|
|



|



|
|
|



|



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







 







>
>
>
>
>
>
>
>
>
>
>







 







>
>
>
>
>
>
>
>
>
>
>







295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
....
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
....
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
          } else {
            result0 = null;
            if (reportFailures === 0) {
              matchFailed("\"enquanto\"");
            }
          }
          if (result0 === null) {
            if (input.substr(pos, 7) === "escreve") {
              result0 = "escreve";
              pos += 7;
            } else {
              result0 = null;
              if (reportFailures === 0) {
                matchFailed("\"escreve\"");
              }
            }
            if (result0 === null) {
              if (input.substr(pos, 8) === "escrever") {
                result0 = "escrever";
                pos += 8;
              } else {
                result0 = null;
                if (reportFailures === 0) {
                  matchFailed("\"escrever\"");
                }
              }
              if (result0 === null) {
                if (input.substr(pos, 3) === "ler") {
                  result0 = "ler";
                  pos += 3;
                } else {
                  result0 = null;
                  if (reportFailures === 0) {
                    matchFailed("\"ler\"");
                  }
                }
                if (result0 === null) {
                  if (input.substr(pos, 2) === "l\xEA") {
                    result0 = "l\xEA";
                    pos += 2;
                  } else {
                    result0 = null;
                    if (reportFailures === 0) {
                      matchFailed("\"l\\xEA\"");
                    }
                  }
                  if (result0 === null) {
                    if (input.substr(pos, 4) === "pede") {
                      result0 = "pede";
                      pos += 4;
                    } else {
                      result0 = null;
                      if (reportFailures === 0) {
                        matchFailed("\"pede\"");
                      }
                    }
                    if (result0 === null) {
                      if (input.substr(pos, 13) === "raiz_quadrada") {
                        result0 = "raiz_quadrada";
                        pos += 13;
                      } else {
                        result0 = null;
                        if (reportFailures === 0) {
                          matchFailed("\"raiz_quadrada\"");
                        }
                      }
                      if (result0 === null) {
                        if (input.substr(pos, 2) === "se") {
                          result0 = "se";
                          pos += 2;
                        } else {
                          result0 = null;
                          if (reportFailures === 0) {
                            matchFailed("\"se\"");
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
................................................................................
            pos += 3;
          } else {
            result0 = null;
            if (reportFailures === 0) {
              matchFailed("\"ler\"");
            }
          }
          if (result0 === null) {
            if (input.substr(pos, 2) === "l\xEA") {
              result0 = "l\xEA";
              pos += 2;
            } else {
              result0 = null;
              if (reportFailures === 0) {
                matchFailed("\"l\\xEA\"");
              }
            }
          }
        }
        if (result0 !== null) {
          result2 = parse_ws();
          if (result2 !== null) {
            result1 = [];
            while (result2 !== null) {
              result1.push(result2);
................................................................................
            result0 = "escrever";
            pos += 8;
          } else {
            result0 = null;
            if (reportFailures === 0) {
              matchFailed("\"escrever\"");
            }
          }
          if (result0 === null) {
            if (input.substr(pos, 7) === "escreve") {
              result0 = "escreve";
              pos += 7;
            } else {
              result0 = null;
              if (reportFailures === 0) {
                matchFailed("\"escreve\"");
              }
            }
          }
        }
        if (result0 !== null) {
          result2 = parse_ws();
          if (result2 !== null) {
            result1 = [];
            while (result2 !== null) {