Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Cloogle
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Cloogle
Cloogle
Commits
1e1f92b2
Verified
Commit
1e1f92b2
authored
Jun 08, 2018
by
Camil Staps
🚀
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use regular expressions for syntax pattern matching
parent
23b05936
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
14 additions
and
30 deletions
+14
-30
.gitmodules
.gitmodules
+3
-0
CleanRegex
CleanRegex
+1
-0
Cloogle/DB.dcl
Cloogle/DB.dcl
+3
-8
Cloogle/DB.icl
Cloogle/DB.icl
+7
-22
No files found.
.gitmodules
View file @
1e1f92b2
...
...
@@ -7,3 +7,6 @@
[submodule "libcloogle"]
path = libcloogle
url = https://github.com/clean-cloogle/libcloogle.git
[submodule "CleanRegex"]
path = CleanRegex
url = https://github.com/camilstaps/CleanRegex
CleanRegex
@
2c5edcee
Subproject commit 2c5edcee074fff52cd6e5ab188b506a40f362a6c
Cloogle/DB.dcl
View file @
1e1f92b2
...
...
@@ -11,6 +11,8 @@ from Database.Native import :: NativeDB, :: Entry, :: Index
from
System
.
FilePath
import
::
FilePath
from
Text
.
GenJSON
import
generic
JSONEncode
,
generic
JSONDecode
,
::
JSONNode
from
Regex
import
::
Regex
from
Clean
.
Types
import
::
Type
,
::
TypeVar
,
::
TVAssignment
,
::
TypeDef
,
::
TypeContext
,
::
TypeRestriction
,
::
Priority
from
Clean
.
Types
.
Tree
import
::
TypeTree
...
...
@@ -181,7 +183,7 @@ location :: !Library !String !FilePath !LineNr !LineNr !Name -> Location
*/
::
SyntaxEntry
=
{
syntax_title
::
String
//* The name of the construct
,
syntax_patterns
::
[
String
]
//* Patterns to search for the construct
,
syntax_patterns
::
[
Regex
]
//* Patterns to search for the construct
,
syntax_code
::
[
String
]
//* Strings describing the construct, as short as possible
,
syntax_description
::
String
//* A description for documentation
,
syntax_doc_locations
::
[
CleanLangReportLocation
]
//* Where to find documentation on the construct
...
...
@@ -199,13 +201,6 @@ location :: !Library !String !FilePath !LineNr !LineNr !Name -> Location
,
aie_description
::
String
//* A description for documentation
}
/**
* A search pattern for syntax constructs
*/
::
SyntaxPattern
:==
String
patternMatches
::
!
SyntaxPattern
!
String
->
Bool
::
Name
:==
String
::
Library
:==
String
::
Module
:==
String
...
...
Cloogle/DB.icl
View file @
1e1f92b2
...
...
@@ -38,6 +38,8 @@ import System.FilePath
from
Text
import
class
Text
(
concat
),
instance
Text
String
import
Text
.
GenJSON
import
Regex
import
Clean
.
Types
import
Clean
.
Types
.
Tree
import
Clean
.
Types
.
Util
...
...
@@ -64,13 +66,13 @@ derive JSONEncode ClassDoc, ClassEntry, ClassMemberDoc, CloogleEntry,
InstanceEntry
,
Location
,
ModuleDoc
,
ModuleEntry
,
Priority
,
RecordField
,
SyntaxEntry
,
Type
,
TypeDef
,
TypeDefEntry
,
TypeDefRhs
,
TypeDoc
,
TypeRestriction
,
ABCInstructionEntry
,
Property
,
PropertyVarInstantiation
,
MultiLineString
,
NGramIndex
,
PropertyTestGenerator
MultiLineString
,
NGramIndex
,
PropertyTestGenerator
,
Regex
,
GroupId
derive
JSONDecode
ClassDoc
,
ClassEntry
,
ClassMemberDoc
,
CloogleEntry
,
Constructor
,
ConstructorDoc
,
DeriveEntry
,
FunctionDoc
,
FunctionEntry
,
InstanceEntry
,
Location
,
ModuleDoc
,
ModuleEntry
,
Priority
,
RecordField
,
SyntaxEntry
,
Type
,
TypeDef
,
TypeDefEntry
,
TypeDefRhs
,
TypeDoc
,
TypeRestriction
,
ABCInstructionEntry
,
Property
,
PropertyVarInstantiation
,
MultiLineString
,
NGramIndex
,
PropertyTestGenerator
MultiLineString
,
NGramIndex
,
PropertyTestGenerator
,
Regex
,
GroupId
printersperse
::
Bool
a
[
b
]
->
[
String
]
|
print
a
&
print
b
printersperse
ia
a
bs
=
intercalate
(
print
False
a
)
(
map
(
print
ia
)
bs
)
...
...
@@ -131,25 +133,6 @@ where
|
fe
.
fe_kind
==
RecordField
=
"."
+++
f
|
otherwise
=
f
patternMatches
::
!
SyntaxPattern
!
String
->
Bool
patternMatches
p
s
=
m
[
c
\\
c
<-:
p
]
[
c
\\
c
<-:
s
]
where
// %: any character
// *: any number of characters (inefficient!)
// \*: the character '*'
// \w: a word character (a-zA-Z_`)
// \e: a word or digit character (a-zA-Z0-9_`)
// other characters are matched literally
m
::
[
Char
]
[
Char
]
->
Bool
m
[]
[]
=
True
m
[
'%'
:
p
]
[_:
s
]
=
m
p
s
m
[
'*'
:
p
]
s
=
any
(
m
p
)
(
tails
s
)
m
[
'\\'
:
'*'
:
p
]
[
x
:
s
]
=
'*'
==
x
&&
m
p
s
m
[
'\\'
:
'w'
:
p
]
[
x
:
s
]
=
(
isAlpha
x
||
x
==
'_'
||
x
==
'`'
)
&&
m
p
s
m
[
'\\'
:
'e'
:
p
]
[
x
:
s
]
=
(
isAlpha
x
||
isDigit
x
||
x
==
'_'
||
x
==
'`'
)
&&
m
p
s
m
[
c
:
p
]
[
x
:
s
]
=
c
==
x
&&
m
p
s
m
_
_
=
False
location
::
!
Library
!
String
!
FilePath
!
LineNr
!
LineNr
!
Name
->
Location
location
lib
mod
fp
dcl
icl
name
=
Location
lib
mod
fp
dcl
icl
name
...
...
@@ -415,8 +398,10 @@ filterName s wrap=:{db,name_ngrams,syntax,abc_instrs}
where
indices
=
[(
i
,[(
MatchingNGrams
,
n
)])
\\
(
i
,
n
)
<-
'
NGrams
'.
search
s
name_ngrams
]
cs
=
[
c
\\
c
<-:
s
]
syntaxSearch
::
CloogleEntry
->
(
Bool
,
[
a
])
syntaxSearch
(
SyntaxEntry
se
)
=
(
any
(
flip
patternMatches
s
)
se
.
syntax_patterns
,
[])
syntaxSearch
(
SyntaxEntry
se
)
=
(
any
(
not
o
isEmpty
o
flip
match
c
s
)
se
.
syntax_patterns
,
[])
syntaxSearch
_
=
(
False
,
[])
abcSearch
::
CloogleEntry
->
(
Bool
,
[
a
])
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment