Skip to content

Commit

Permalink
fix: Fragment part of URL
Browse files Browse the repository at this point in the history
  • Loading branch information
bbugyi200 committed Aug 31, 2024
1 parent 67238b3 commit 99a5006
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/zorg/grammar/ZorgFile.g4
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,6 @@ url_path : (FSLASH url_path_part+)+ ;
url_path_part : PERCENT | COLON | DASH | ID ;
url_query : QMARK url_key_val (AMP url_key_val)* ;
url_key_val : url_atom EQUAL url_atom* ;
url_fragment : HASH url_path ;
url_fragment : FSLASH? HASH url_path_part+ url_path? ;
url_atom : ID | PERCENT | DASH | COLON | FSLASH ;
https : 'https' | 'http' ;
2 changes: 1 addition & 1 deletion src/zorg/grammar/zorg_file/ZorgFile.interp

Large diffs are not rendered by default.

69 changes: 56 additions & 13 deletions src/zorg/grammar/zorg_file/ZorgFileParser.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

def serializedATN():
return [
4,1,49,588,2,0,7,0,2,1,7,1,2,2,7,2,2,3,7,3,2,4,7,4,2,5,7,5,2,6,7,
4,1,49,597,2,0,7,0,2,1,7,1,2,2,7,2,2,3,7,3,2,4,7,4,2,5,7,5,2,6,7,
6,2,7,7,7,2,8,7,8,2,9,7,9,2,10,7,10,2,11,7,11,2,12,7,12,2,13,7,13,
2,14,7,14,2,15,7,15,2,16,7,16,2,17,7,17,2,18,7,18,2,19,7,19,2,20,
7,20,2,21,7,21,2,22,7,22,2,23,7,23,2,24,7,24,2,25,7,25,2,26,7,26,
Expand Down Expand Up @@ -60,13 +60,14 @@ def serializedATN():
12,58,547,9,58,1,59,1,59,1,59,1,60,1,60,4,60,554,8,60,11,60,12,60,
555,4,60,558,8,60,11,60,12,60,559,1,61,1,61,1,62,1,62,1,62,1,62,
5,62,568,8,62,10,62,12,62,571,9,62,1,63,1,63,1,63,5,63,576,8,63,
10,63,12,63,579,9,63,1,64,1,64,1,64,1,65,1,65,1,66,1,66,1,66,0,0,
10,63,12,63,579,9,63,1,64,3,64,582,8,64,1,64,1,64,4,64,586,8,64,
11,64,12,64,587,1,64,3,64,591,8,64,1,65,1,65,1,66,1,66,1,66,0,0,
67,0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,
44,46,48,50,52,54,56,58,60,62,64,66,68,70,72,74,76,78,80,82,84,86,
88,90,92,94,96,98,100,102,104,106,108,110,112,114,116,118,120,122,
124,126,128,130,132,0,8,3,0,13,14,45,45,47,48,4,0,26,29,35,35,37,
38,45,48,3,0,32,34,39,39,49,49,1,0,39,42,1,1,12,12,4,0,18,18,32,
32,42,42,49,49,5,0,18,18,32,32,34,34,42,42,49,49,1,0,10,11,611,0,
32,42,42,49,49,5,0,18,18,32,32,34,34,42,42,49,49,1,0,10,11,623,0,
134,1,0,0,0,2,141,1,0,0,0,4,145,1,0,0,0,6,152,1,0,0,0,8,175,1,0,
0,0,10,188,1,0,0,0,12,190,1,0,0,0,14,193,1,0,0,0,16,196,1,0,0,0,
18,209,1,0,0,0,20,211,1,0,0,0,22,219,1,0,0,0,24,221,1,0,0,0,26,224,
Expand All @@ -82,7 +83,7 @@ def serializedATN():
507,1,0,0,0,106,511,1,0,0,0,108,515,1,0,0,0,110,519,1,0,0,0,112,
521,1,0,0,0,114,535,1,0,0,0,116,540,1,0,0,0,118,548,1,0,0,0,120,
557,1,0,0,0,122,561,1,0,0,0,124,563,1,0,0,0,126,572,1,0,0,0,128,
580,1,0,0,0,130,583,1,0,0,0,132,585,1,0,0,0,134,136,3,2,1,0,135,
581,1,0,0,0,130,592,1,0,0,0,132,594,1,0,0,0,134,136,3,2,1,0,135,
137,3,6,3,0,136,135,1,0,0,0,136,137,1,0,0,0,137,138,1,0,0,0,138,
139,5,0,0,1,139,1,1,0,0,0,140,142,3,4,2,0,141,140,1,0,0,0,142,143,
1,0,0,0,143,141,1,0,0,0,143,144,1,0,0,0,144,3,1,0,0,0,145,147,5,
Expand Down Expand Up @@ -218,13 +219,16 @@ def serializedATN():
0,568,571,1,0,0,0,569,567,1,0,0,0,569,570,1,0,0,0,570,125,1,0,0,
0,571,569,1,0,0,0,572,573,3,130,65,0,573,577,5,28,0,0,574,576,3,
130,65,0,575,574,1,0,0,0,576,579,1,0,0,0,577,575,1,0,0,0,577,578,
1,0,0,0,578,127,1,0,0,0,579,577,1,0,0,0,580,581,5,39,0,0,581,582,
3,120,60,0,582,129,1,0,0,0,583,584,7,6,0,0,584,131,1,0,0,0,585,586,
7,7,0,0,586,133,1,0,0,0,62,136,143,147,154,159,165,171,177,182,188,
1,0,0,0,578,127,1,0,0,0,579,577,1,0,0,0,580,582,5,34,0,0,581,580,
1,0,0,0,581,582,1,0,0,0,582,583,1,0,0,0,583,585,5,39,0,0,584,586,
3,122,61,0,585,584,1,0,0,0,586,587,1,0,0,0,587,585,1,0,0,0,587,588,
1,0,0,0,588,590,1,0,0,0,589,591,3,120,60,0,590,589,1,0,0,0,590,591,
1,0,0,0,591,129,1,0,0,0,592,593,7,6,0,0,593,131,1,0,0,0,594,595,
7,7,0,0,595,133,1,0,0,0,65,136,143,147,154,159,165,171,177,182,188,
201,206,214,226,233,238,242,247,252,256,261,263,277,283,286,292,
295,297,303,309,318,325,332,341,344,346,359,374,386,428,434,438,
443,450,456,460,465,472,478,482,487,494,500,524,527,530,533,545,
555,559,569,577
555,559,569,577,581,587,590
]

class ZorgFileParser ( Parser ):
Expand Down Expand Up @@ -4628,6 +4632,16 @@ def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
def HASH(self):
return self.getToken(ZorgFileParser.HASH, 0)

def FSLASH(self):
return self.getToken(ZorgFileParser.FSLASH, 0)

def url_path_part(self, i:int=None):
if i is None:
return self.getTypedRuleContexts(ZorgFileParser.Url_path_partContext)
else:
return self.getTypedRuleContext(ZorgFileParser.Url_path_partContext,i)


def url_path(self):
return self.getTypedRuleContext(ZorgFileParser.Url_pathContext,0)

Expand All @@ -4650,12 +4664,41 @@ def url_fragment(self):

localctx = ZorgFileParser.Url_fragmentContext(self, self._ctx, self.state)
self.enterRule(localctx, 128, self.RULE_url_fragment)
self._la = 0 # Token type
try:
self.enterOuterAlt(localctx, 1)
self.state = 580
self.match(ZorgFileParser.HASH)
self.state = 581
self.url_path()
self._errHandler.sync(self)
_la = self._input.LA(1)
if _la==34:
self.state = 580
self.match(ZorgFileParser.FSLASH)


self.state = 583
self.match(ZorgFileParser.HASH)
self.state = 585
self._errHandler.sync(self)
_alt = 1
while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER:
if _alt == 1:
self.state = 584
self.url_path_part()

else:
raise NoViableAltException(self)
self.state = 587
self._errHandler.sync(self)
_alt = self._interp.adaptivePredict(self._input,63,self._ctx)

self.state = 590
self._errHandler.sync(self)
la_ = self._interp.adaptivePredict(self._input,64,self._ctx)
if la_ == 1:
self.state = 589
self.url_path()


except RecognitionException as re:
localctx.exception = re
self._errHandler.reportError(self, re)
Expand Down Expand Up @@ -4708,7 +4751,7 @@ def url_atom(self):
self._la = 0 # Token type
try:
self.enterOuterAlt(localctx, 1)
self.state = 583
self.state = 592
_la = self._input.LA(1)
if not((((_la) & ~0x3f) == 0 and ((1 << _la) & 567369475031040) != 0)):
self._errHandler.recoverInline(self)
Expand Down Expand Up @@ -4753,7 +4796,7 @@ def https(self):
self._la = 0 # Token type
try:
self.enterOuterAlt(localctx, 1)
self.state = 585
self.state = 594
_la = self._input.LA(1)
if not(_la==10 or _la==11):
self._errHandler.recoverInline(self)
Expand Down
2 changes: 1 addition & 1 deletion tests/__snapshots__/test_run_compile.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,7 @@
'https://mail.google.com/chat/u/0/#chat/space/AAAAKA-qATI',
'contexts': ['footnote'],
'create_date': FakeDate(2024, 8, 31),
'links': ['x:https://mail.google.com/chat/u/0'],
'links': ['x:https://mail.google.com/chat/u/0/#chat/space/AAAAKA-qATI'],
'modify_date': FakeDate(2024, 8, 31),
'people': [],
'projects': [],
Expand Down
2 changes: 1 addition & 1 deletion tests/__snapshots__/test_run_db.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
'x:https://go/foo?a=/&b=2&c=/',
'x:https://go/foo?bar=%s',
'x:https://go/foo?env=dev&bar=2&baz=3',
'x:https://mail.google.com/chat/u/0',
'x:https://mail.google.com/chat/u/0/#chat/space/AAAAKA-qATI',
'x:https://www.bazbuz.com',
'x:https://www.foobar.com',
'xmind/zorg_e2e_query_arch.xmind',
Expand Down
4 changes: 2 additions & 2 deletions tests/__snapshots__/test_run_query.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -1756,7 +1756,7 @@
x:https://go/foo?a=/&b=2&c=/
x:https://go/foo?bar=%s
x:https://go/foo?env=dev&bar=2&baz=3
x:https://mail.google.com/chat/u/0
x:https://mail.google.com/chat/u/0/#chat/space/AAAAKA-qATI
x:https://www.bazbuz.com
x:https://www.foobar.com
xmind/zorg_e2e_query_arch.xmind
Expand Down Expand Up @@ -1786,7 +1786,7 @@
x:https://go/foo?a=/&b=2&c=/
x:https://go/foo?bar=%s
x:https://go/foo/bar/%s
x:https://mail.google.com/chat/u/0
x:https://mail.google.com/chat/u/0/#chat/space/AAAAKA-qATI
bar.sh
baz
buz#fuzz
Expand Down

0 comments on commit 99a5006

Please sign in to comment.