HashLDash/Photon

1.0 --> it is something??2 -- > Traceback (most recent call last):

Samuel-Nonato opened this issue · 3 comments

Those erro happen ..


1. > PS C:\Users\Usuario\Desktop> photon numero.w
2. > 1.0
3. > it is something??2
4. > Traceback (most recent call last):
5. >   File "C:\Photon-main\core\interpreter.py", line 170, in run
6. >     struct, nextLine = self.handleTokenized(tokenized)
7. >   File "C:\Photon-main\core\interpreter.py", line 154, in handleTokenized
8. >     struct = self.handleBlock(tokenized)
9. >   File "C:\Photon-main\core\interpreter.py", line 137, in handleBlock
10. >     block, nextTokenized = self.getBlock(indent)
11. >   File "C:\Photon-main\core\interpreter.py", line 121, in getBlock
12. >     struct, nextLine = self.handleTokenized(blockTokenized)
13. >   File "C:\Photon-main\core\interpreter.py", line 154, in handleTokenized
14. >     struct = self.handleBlock(tokenized)
15. >   File "C:\Photon-main\core\interpreter.py", line 137, in handleBlock
16. >     block, nextTokenized = self.getBlock(indent)
17. >   File "C:\Photon-main\core\interpreter.py", line 114, in getBlock
18. >     struct, nextLine = self.handleTokenized(blockTokenized)
19. >   File "C:\Photon-main\core\interpreter.py", line 154, in handleTokenized
20. >     struct = self.handleBlock(tokenized)
21. >   File "C:\Photon-main\core\interpreter.py", line 137, in handleBlock
22. >     block, nextTokenized = self.getBlock(indent)
23. >   File "C:\Photon-main\core\interpreter.py", line 114, in getBlock
24. >     struct, nextLine = self.handleTokenized(blockTokenized)
25. >   File "C:\Photon-main\core\interpreter.py", line 157, in handleTokenized
26. >     struct = assembly(tokenized)
27. >   File "C:\Photon-main\core\photonParser.py", line 178, in assembly
28. >     reduced = reduceToken(tokens)
29. >   File "C:\Photon-main\core\photonParser.py", line 139, in reduceToken
30. >     parsePhrase = token2word(tokens)
31. >   File "C:\Photon-main\core\photonParser.py", line 116, in token2word
32. >     raise Exception(f'Cannot convert the token {t["token"]} to a word')
33. > Exception: Cannot convert the token value to a word
34. > 
35. > During handling of the above exception, another exception occurred:
36. > 
37. > Traceback (most recent call last):
38. >   File "C:\Photon-main\core\photon.py", line 127, in <module>
39. >     Interpreter(filename = first, lang = lang, standardLibs = os.path.join(PHOTON_INSTALL_PATH, 'libs/'), debug = DEBUG).run()
40. >   File "C:\Photon-main\core\interpreter.py", line 172, in run
41. >     showError(e)
42. >   File "C:\Photon-main\core\photonParser.py", line 197, in showError
43. >     raise SyntaxError(msg)
44. > SyntaxError:
45. > 
46. > 
47. >     Ops!! This is a syntax error or a parser error.
48. >     Common causes: Missing "," ")" "}"
49. >     Cannot convert the token value to a word
50. >     This happened in line numero.w:11.
51. >     Last parsed line is "
52. > 
53. >                          print('1º parte concluida {i*100/v}%')
54. > 
55. > "
56. >     Last Parse attempt was:
57. >  "assign"

For this code


1. > int n = input('n = ')
2. > nome =input('nome = ')
3. > int vezes = input('vezes = ')
4. > v = vezes/3
5. > v2= 2*v
6. > str t = ('')
7. > for i in 0..vazes:
8. >       n = n + 1
9. >       if i:
10. >             if i <=v:
11. >                      print('1º parte concluida {i*100/v}%')
12. >             if i>v and i <=v2:
13. > 		     print('2º parte concluida {i*100/v}%')  
14. >             if i>v and i <=vezes:
15. >                      print('3º parte concluida {i*100/v}%')	
16. >       t = t +str(n) + str('\n')
17. > print(t)
18. > 

Your code have a few errors. For example, line 6 has invalid syntax, line 7 has invalid variable name. Also the function str() doesn't exist in Photon yet. But you can use format strings to achieve the same result

ok, i think that i need more classes of photon, probably i'm used touse python

You could write it this way. (I removed the º because it was breaking the parser, I'll have to fix that later)

int n = input('n = ')
nome = input('nome = ')
int vezes = input('vezes = ')
v = vezes/3
v2= 2*v
t = ''
for i in 0..vezes:
    n = n + 1
    print(n)
    if i:
        if i <=v:
            print('1 parte concluida {i*100/v}%')
        if i>v and i <=v2:
            print('2 parte concluida {i*100/v}%')
        if i>v and i <=vezes:
            print('3 parte concluida {i*100/v}%')
    t = '{t} {n} \n'
print(t)