![]() |
| ||||||||||||||||||||||
Navigation |
Synopsis (Source code) location values.
Syntax
| Uri | ( O, L, <BL, BC> , <EL,EC> )
where:
| ) is optional.
Types
loc
Details AddSegment Equal FieldSelection GreaterThan GreaterThanOrEqual LessThan LessThanOrEqual NotEqual
Description Location values are represented by the type
loc and serve the following purposes:
![]() foo://example.com:8042/over/there?name=ferret#nose \_/ \______________/\_________/ \_________/ \__/ | | | | | scheme authority path query fragment | _____________________|__ / \ / \ urn:example:animal:ferret:noseThe elements of a location value can be accessed and modified using the standard mechanism of field selection and field assignment. The corresponding field names are:
Examples Locations with specific position information should always be generated automatically but for the curious here is an example:
rascal>|file:///home/paulk/pico.trm|(0,1,<2,3>,<4,5>)
loc: |file:///home/paulk/pico.trm|(0,1,<2,3>,<4,5>)
Note that this is equivalent to using the home scheme:
rascal>|home://pico.trm|(0,1,<2,3>,<4,5>)
loc: |home://pico.trm|(0,1,<2,3>,<4,5>)
Accessing a file src/HelloWorld.java in a project with the name example-project in the currently running Eclipse is done as follows:
rascal>|project://example-project/src/HelloWorld.java|
loc: |project://example-project/src/HelloWorld.java|
You could read a webpage: rascal>import IO; ok rascal>println(readFile(|http://www.example.org|)) <!doctype html> <html> <head> <title>Example Domain</title> <meta charset="utf-8" /> <meta http-equiv="Content-type" content="text/html; charset=utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1" /> <style type="text/css"> body { background-color: #f0f0f2; margin: 0; padding: 0; font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; } div { width: 600px; margin: 5em auto; padding: 50px; background-color: #fff; border-radius: 1em; } a:link, a:visited { color: #38488f; text-decoration: none; } @media (max-width: 700px) { body { background-color: #fff; } div { width: auto; margin: 0 auto; border-radius: 0; padding: 1em; } } </style> </head> <body> <div> <h1>Example Domain</h1> <p>This domain is established to be used for illustrative examples in documents. You may use this domain in examples without prior coordination or asking for permission.</p> <p><a href="http://www.iana.org/domains/example">More information...</a></p> </div> </body> </html> okAddition on locations creates longer paths: rascal>x = |tmp://myTempDirectory|; loc: |tmp://myTempDirectory| rascal>x += "myTempFile.txt"; loc: |tmp://myTempDirectory/myTempFile.txt|Check the contents of a folder: rascal>|project://example-project/src|.ls
list[loc]: [
|project://example-project/src/Apple.java|,
|project://example-project/src/Fruit.java|,
|project://example-project/src/HelloWorld.java|,
|project://example-project/src/IFruit.java|
]
![]() |