Skip to content

Commit 8231f4b

Browse files
committed
தவளை is parsed as "த:உயிர்மெய்க்குறில்:1 வ:உயிர்மெய்க்குறில்:1 ள்:மெய் ஐ:ஐகாரக்குறுக்கம்:1.5" instead of "த:உயிர்மெய்க்குறில்:1 வ:உயிர்மெய்க்குறில்:1 ளை:ஐகாரக்குறுக்கம்:1.5" because "மொழியிடை*" in grammar is greedy. to fix this made it non greedy "மொழியிடை*?"
1 parent d69342f commit 8231f4b

File tree

4 files changed

+47
-33
lines changed

4 files changed

+47
-33
lines changed

docs/setup.md

+14
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,20 @@ settings.json
106106
```
107107

108108
# How to use
109+
110+
## Howto Debug Grammars
111+
112+
On VSCODE
113+
114+
* make sure antlr extension is installed. The launch and settings files have entries like above.
115+
* Create the following files
116+
{workspaceFolder}/pytamil/தமிழ்/resources/வெண்பா-input.txt
117+
{workspaceFolder}/pytamil/தமிழ்/resources/மாத்திரை-input.txt
118+
119+
* Select the config from debug list and run. Antlr extension should be able to generate parse tree graph.
120+
* Make sure the entry in மாத்திரை-input.txt is in விரி form . That is to debug தவளை enter த்அவ்அள்ஐ
121+
122+
109123
## unit tests
110124
cd in to top lelvel folder and run pytest.
111125
```bash

pytamil/tamil19.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@
6262
# print(மாத்திரை.மாத்திரைவரிசை_கொடு("ஊக்கம்"))
6363
# print(மாத்திரை.மாத்திரைவரிசை_கொடு("குழூக்குறி"))
6464
# print(மாத்திரை.மாத்திரைவரிசை_கொடு("ஔவையார்"))
65-
print(மாத்திரை.மாத்திரைவரிசை_கொடு("மழை"))
65+
# print(மாத்திரை.மாத்திரைவரிசை_கொடு("மழை"))
6666
print(மாத்திரை.மாத்திரைவரிசை_கொடு("தவளை"))
67-
print(மாத்திரை.மாத்திரைவரிசை_கொடு("பகைவர்"))
67+
# print(மாத்திரை.மாத்திரைவரிசை_கொடு("பகைவர்"))
6868

6969

7070
# outfilename = os.path.join(os.path.dirname(__file__),'தமிழ்/resources/மாத்திரைoutput.txt')

pytamil/தமிழ்/codegen/மாத்திரைParser.py

+30-30
Original file line numberDiff line numberDiff line change
@@ -21,34 +21,34 @@ def serializedATN():
2121
buf.write("\3\6\3\6\3\6\5\6P\n\6\3\7\3\7\3\7\3\b\3\b\3\t\3\t\3\t")
2222
buf.write("\3\n\3\n\3\n\3\n\5\n^\n\n\3\13\3\13\3\13\3\13\5\13d\n")
2323
buf.write("\13\3\f\3\f\3\f\3\r\3\r\3\r\3\16\3\16\3\17\3\17\3\20\3")
24-
buf.write("\20\3\21\3\21\3\22\3\22\3\23\3\23\3\24\3\24\3\24\2\2\25")
25-
buf.write("\2\4\6\b\n\f\16\20\22\24\26\30\32\34\36 \"$&\2\b\4\2\3")
26-
buf.write("\3\6\t\4\2\4\5\n\16\3\2\20!\3\2\20\25\3\2\"(\3\2)\63\2")
27-
buf.write("y\2(\3\2\2\2\4\67\3\2\2\2\6@\3\2\2\2\bG\3\2\2\2\nO\3\2")
28-
buf.write("\2\2\fQ\3\2\2\2\16T\3\2\2\2\20V\3\2\2\2\22]\3\2\2\2\24")
29-
buf.write("c\3\2\2\2\26e\3\2\2\2\30h\3\2\2\2\32k\3\2\2\2\34m\3\2")
30-
buf.write("\2\2\36o\3\2\2\2 q\3\2\2\2\"s\3\2\2\2$u\3\2\2\2&w\3\2")
31-
buf.write("\2\2(,\5\4\3\2)+\5\6\4\2*)\3\2\2\2+.\3\2\2\2,*\3\2\2\2")
32-
buf.write(",-\3\2\2\2-/\3\2\2\2.,\3\2\2\2/\60\5\b\5\2\60\3\3\2\2")
33-
buf.write("\2\618\5\24\13\2\628\5\22\n\2\638\5\32\16\2\648\5\34\17")
34-
buf.write("\2\658\5\26\f\2\668\5\30\r\2\67\61\3\2\2\2\67\62\3\2\2")
35-
buf.write("\2\67\63\3\2\2\2\67\64\3\2\2\2\67\65\3\2\2\2\67\66\3\2")
36-
buf.write("\2\28\5\3\2\2\29A\5\22\n\2:A\5 \21\2;A\5\26\f\2<A\5\30")
37-
buf.write("\r\2=A\5\36\20\2>A\5\f\7\2?A\5\16\b\2@9\3\2\2\2@:\3\2")
38-
buf.write("\2\2@;\3\2\2\2@<\3\2\2\2@=\3\2\2\2@>\3\2\2\2@?\3\2\2\2")
39-
buf.write("A\7\3\2\2\2BH\5\f\7\2CH\5\22\n\2DH\5\20\t\2EH\5\26\f\2")
40-
buf.write("FH\5 \21\2GB\3\2\2\2GC\3\2\2\2GD\3\2\2\2GE\3\2\2\2GF\3")
41-
buf.write("\2\2\2H\t\3\2\2\2IJ\5\32\16\2JK\5\26\f\2KP\3\2\2\2LM\5")
42-
buf.write("\26\f\2MN\5\26\f\2NP\3\2\2\2OI\3\2\2\2OL\3\2\2\2P\13\3")
43-
buf.write("\2\2\2QR\5 \21\2RS\5$\23\2S\r\3\2\2\2TU\5&\24\2U\17\3")
44-
buf.write("\2\2\2VW\5\"\22\2WX\7\3\2\2X\21\3\2\2\2YZ\5 \21\2Z[\7")
45-
buf.write("\4\2\2[^\3\2\2\2\\^\7\4\2\2]Y\3\2\2\2]\\\3\2\2\2^\23\3")
46-
buf.write("\2\2\2_d\7\5\2\2`a\5 \21\2ab\7\5\2\2bd\3\2\2\2c_\3\2\2")
47-
buf.write("\2c`\3\2\2\2d\25\3\2\2\2ef\5 \21\2fg\5\32\16\2g\27\3\2")
48-
buf.write("\2\2hi\5 \21\2ij\5\34\17\2j\31\3\2\2\2kl\t\2\2\2l\33\3")
49-
buf.write("\2\2\2mn\t\3\2\2n\35\3\2\2\2op\7\17\2\2p\37\3\2\2\2qr")
50-
buf.write("\t\4\2\2r!\3\2\2\2st\t\5\2\2t#\3\2\2\2uv\t\6\2\2v%\3\2")
51-
buf.write("\2\2wx\t\7\2\2x\'\3\2\2\2\t,\67@GO]c")
24+
buf.write("\20\3\21\3\21\3\22\3\22\3\23\3\23\3\24\3\24\3\24\3,\2")
25+
buf.write("\25\2\4\6\b\n\f\16\20\22\24\26\30\32\34\36 \"$&\2\b\4")
26+
buf.write("\2\3\3\6\t\4\2\4\5\n\16\3\2\20!\3\2\20\25\3\2\"(\3\2)")
27+
buf.write("\63\2y\2(\3\2\2\2\4\67\3\2\2\2\6@\3\2\2\2\bG\3\2\2\2\n")
28+
buf.write("O\3\2\2\2\fQ\3\2\2\2\16T\3\2\2\2\20V\3\2\2\2\22]\3\2\2")
29+
buf.write("\2\24c\3\2\2\2\26e\3\2\2\2\30h\3\2\2\2\32k\3\2\2\2\34")
30+
buf.write("m\3\2\2\2\36o\3\2\2\2 q\3\2\2\2\"s\3\2\2\2$u\3\2\2\2&")
31+
buf.write("w\3\2\2\2(,\5\4\3\2)+\5\6\4\2*)\3\2\2\2+.\3\2\2\2,-\3")
32+
buf.write("\2\2\2,*\3\2\2\2-/\3\2\2\2.,\3\2\2\2/\60\5\b\5\2\60\3")
33+
buf.write("\3\2\2\2\618\5\24\13\2\628\5\22\n\2\638\5\32\16\2\648")
34+
buf.write("\5\34\17\2\658\5\26\f\2\668\5\30\r\2\67\61\3\2\2\2\67")
35+
buf.write("\62\3\2\2\2\67\63\3\2\2\2\67\64\3\2\2\2\67\65\3\2\2\2")
36+
buf.write("\67\66\3\2\2\28\5\3\2\2\29A\5\22\n\2:A\5 \21\2;A\5\26")
37+
buf.write("\f\2<A\5\30\r\2=A\5\36\20\2>A\5\f\7\2?A\5\16\b\2@9\3\2")
38+
buf.write("\2\2@:\3\2\2\2@;\3\2\2\2@<\3\2\2\2@=\3\2\2\2@>\3\2\2\2")
39+
buf.write("@?\3\2\2\2A\7\3\2\2\2BH\5\f\7\2CH\5\22\n\2DH\5\20\t\2")
40+
buf.write("EH\5\26\f\2FH\5 \21\2GB\3\2\2\2GC\3\2\2\2GD\3\2\2\2GE")
41+
buf.write("\3\2\2\2GF\3\2\2\2H\t\3\2\2\2IJ\5\32\16\2JK\5\26\f\2K")
42+
buf.write("P\3\2\2\2LM\5\26\f\2MN\5\26\f\2NP\3\2\2\2OI\3\2\2\2OL")
43+
buf.write("\3\2\2\2P\13\3\2\2\2QR\5 \21\2RS\5$\23\2S\r\3\2\2\2TU")
44+
buf.write("\5&\24\2U\17\3\2\2\2VW\5\"\22\2WX\7\3\2\2X\21\3\2\2\2")
45+
buf.write("YZ\5 \21\2Z[\7\4\2\2[^\3\2\2\2\\^\7\4\2\2]Y\3\2\2\2]\\")
46+
buf.write("\3\2\2\2^\23\3\2\2\2_d\7\5\2\2`a\5 \21\2ab\7\5\2\2bd\3")
47+
buf.write("\2\2\2c_\3\2\2\2c`\3\2\2\2d\25\3\2\2\2ef\5 \21\2fg\5\32")
48+
buf.write("\16\2g\27\3\2\2\2hi\5 \21\2ij\5\34\17\2j\31\3\2\2\2kl")
49+
buf.write("\t\2\2\2l\33\3\2\2\2mn\t\3\2\2n\35\3\2\2\2op\7\17\2\2")
50+
buf.write("p\37\3\2\2\2qr\t\4\2\2r!\3\2\2\2st\t\5\2\2t#\3\2\2\2u")
51+
buf.write("v\t\6\2\2v%\3\2\2\2wx\t\7\2\2x\'\3\2\2\2\t,\67@GO]c")
5252
return buf.getvalue()
5353

5454

@@ -214,8 +214,8 @@ def மாத்திரை(self):
214214
self.state = 42
215215
self._errHandler.sync(self)
216216
_alt = self._interp.adaptivePredict(self._input,0,self._ctx)
217-
while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER:
218-
if _alt==1:
217+
while _alt!=1 and _alt!=ATN.INVALID_ALT_NUMBER:
218+
if _alt==1+1:
219219
self.state = 39
220220
self.மொழியிடை()
221221
self.state = 44

pytamil/தமிழ்/resources/மாத்திரை.g4

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ grammar மாத்திரை;
22

33
// start: மாத்திரை ;
44

5-
மாத்திரை : மொழிமுதல் மொழியிடை* மொழியிறுதி;
5+
மாத்திரை : மொழிமுதல் மொழியிடை*? மொழியிறுதி;
66

77
மொழிமுதல் : ஔகாரக்குறுக்கம் | ஐகாரக்குறுக்கம் | உயிர்க்குறில் | உயிர்நெடில் | உயிர்மெய்க்குறில்
88
| உயிர்மெய்நெடில் ;

0 commit comments

Comments
 (0)