Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pascal-compiler
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Harbor Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Lior Spach
pascal-compiler
Commits
d98247b9
Commit
d98247b9
authored
9 years ago
by
Lior Spach
Browse files
Options
Downloads
Patches
Plain Diff
combinators first
parent
20e39468
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/scala/comb.scala
+48
-0
48 additions, 0 deletions
src/main/scala/comb.scala
with
48 additions
and
0 deletions
src/main/scala/comb.scala
0 → 100644
+
48
−
0
View file @
d98247b9
package
CombParse
import
scala.util.parsing.combinator._
class
Arith
extends
JavaTokenParsers
{
def
program
:
Parser
[
String
]
=
{
def
programInOut
:
Parser
[
Any
]
=
"("
~
opt
(
ident
~
opt
(
rep
(
","
~
ident
))
)
~
")"
"program"
~>
ident
<~
opt
(
programInOut
)
~
";"
}
def
vars
:
Parser
[
List
[
String
]]
=
"var"
~
ident
~
opt
(
rep
(
","
~>
ident
))
~
":"
~
"integer"
~
";"
^^
{
case
"var"
~
id
~
optlstId
~
":"
~
"integer"
~
";"
=>
optlstId
match
{
case
Some
(
s
)
=>
id
::
s
case
None
=>
List
(
id
)
}
}
lazy
val
page
=
getpage
(
i
.
link
)
lazy
val
metadata
=
i
.
toMetadata
++
getter
.
getMetadata
(
page
)
lazy
val
downLink
=
metadata
.
find
(
_
.
key
==
"DownloadLink"
).
get
.
value
lazy
val
filename
=
metadata
.
find
(
_
.
key
==
"NomeArquivo"
).
get
.
value
def
param
:
Parser
[
String
]
=
ident
~
opt
(
rep
(
","
~>
ident
))
~
":"
~
"integer"
~
";"
// def params:Parser[List[String]] =
// opt("(" ~ param ~ opt(rep("," ~ param)) ~ ")")
// def procedure:Parser[List[String]] =
// "procedure" ~ ident ~ params
}
object
MyParser
extends
Arith
{
val
input
=
Seq
(
"program lala23(adkwopadw23, faw4ea,aduwh28 ) ;"
,
"var a,v,b23,sd :integer;"
)
def
main
(
args
:
Array
[
String
])
{
println
(
parseAll
(
program
,
input
(
0
)).
get
)
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment